How do I rotate a group of positions around a point?

Say I have an array containing nothing but positions (x, y, z) to make up an object (such as a cube). But I would like rotate the object around a given point that is also a position in the world.

Here’s a visual representation of what I am looking for.
Note that the red cube below is the origin point, and all the blue cubes are my group of positions formatted as the usual (x, y, z).

This:

To this: (rotated -45 degrees along the Y axis)

How can I achieve this effect without the assistance of CFrame or Vectors? Is there a simple way to achieve this?

local Origin = {0, 0, 0} -- The pivot position in the world (formatted as (x, y, z))
local TargetAngles = {0, -45, 0} -- The angle(s) that we want to rotate our positions to based on the pivot point

local Vertices = { -- Our group of positions or coordinates in the world (Formatted as (x, y, z))
    {1, 1, 1},
    {2, 1, 1},
    {2, 2, 1},
    {2, 2, 2},
    {1, 2, 2},
    {1, 1, 2},
    {1, 2, 1},
    {2, 1, 2},
}
2 Likes

So, i might be rong but you should try bodyforce since ive seen an model of an moon before circling an earth and it used bodyforce and i think rope constraints to do it. Il get in touch if i find it.

I was just using parts as a visualisation for what i was trying to achieve. No parts will be used in what im trying to make. I want to achieve this effect through lua and math

Ah, I acuttaly im quite new to scripting and an basic/medium scripter so I cant really help that much but i would just mess around with scripts and postions.

No, there not an easy way to do it.
You do have to use CFrame and Vectors.

part.Orientation is also a thing, but it will be hard for a model.
I Suggest you to use CFrame.

1 Like

Assuming you want something like this (sorry for the laggy recording):


Here’s what I came up with:

local workspace = game:GetService("Workspace")

local vertices = workspace.Vertices:GetChildren() -- Vertices (I used parts, its not hard to change it to an array of Vector3 positions)
local pivot = workspace.Pivot -- Same like vertices, I used a part
local angle = Vector3.new(0, -45, 0) -- Doesn't really matter in this script because its getting changed below anyways

local function getPosition(pos)
	return (
		CFrame.new(pivot.Position) * -- Convert the pivot Position to CFrame
		CFrame.Angles(math.rad(angle.X), math.rad(angle.Y), math.rad(angle.Z)) * -- Multiply the angle to the pivot position
		CFrame.new(pos - pivot.Position) -- Finally add the distance between pivot and the vertice
	).p -- Return the position, not the CFrame
end

while true do
	angle = Vector3.new(0, math.random(-180, 180), 0) -- Pick a random angle
	print("Current angle Y:", angle.Y)
	
	for _,p in ipairs(vertices) do -- Loop through each vertice
		p.Position = getPosition(p.Position) -- Set its position to the position fetched from the above function
	end
	
	wait(3)
end

Place file:
custom pivot points test.rbxl (29.7 KB)

Assuming you want this result that I coded, it’s not hard to change the parts to an array of Vector3’s. I hope you can do it yourself or I could help.
Thanks.

3 Likes

Oh hello again. This is exactly what i was trying to do. Though initially i tried doing this without the assistance of CFrame, but i find this to be probably the simplest.
Thanks again!

1 Like

Hey, sorry to bring up this topic again. But do you know if there’s a way that I can eliminate the vertices shifting from left to right when you move your origin point forwards or backwards in world space when there is an angle?

here’s the issue visualized: (red block represents the origin)