# Help with CFrames

Hello. I’m stupid bad with CFrames and math in general so I apologise for the question. How would I get the CFrames of points A and B from the CFrame of the part in the Image I have attached?

I’ve tried subtracting and adding half the size of the part to it’s CFrame to get A and B respectively but they don’t seem to change when I’ve tried rotating the part.

I would appreciate any help. Thanks.

Hello!

You can do this with some simple CFrame math:

Part.CFrame = Part.CFrame * CFrame.new(Part.Size.X/2, 0, 0)
You can play around with that code to see what you will get.
You should only change the “Part.Size.X/2” either by dividing by less or by adding a minus to it.

Part.CFrame = Part.CFrame * CFrame.new(Part.Size.X/2, 0, 0) * CFrame.Angles(0, math.rad(25), 0)
The code above will rotate the part 25 degrees in the end of the part.

I hope this helped! Please message me if you have any questions!

1 Like

I think I should have worded this better.

Here is a visual of what is happenning:
https://gofile.io/?c=KO3cN1

The two parts at the end of the part are not following the ends of the centre part when rotate it. They seems to only rotate.

Here is the code I wrote to experiment:

``````while true do
local Part = script.Parent
local p1 = Instance.new("Part",workspace)
local p2 = Instance.new("Part",workspace)
local leftwardBoundCFrame = Part.CFrame - Vector3.new(0, 0, Part.Size.Z/2)
local rightwardBoundCFrame = Part.CFrame + Vector3.new(0, 0, Part.Size.Z/2)
p1.CFrame = leftwardBoundCFrame
p2.CFrame = rightwardBoundCFrame
p1.Anchored = true
p2.Anchored = true
wait(0.1)
p1:Destroy()
p2:Destroy()
end``````

Make sure you learn about `Object` and `World` space.
Object space is relative to the CFrame
World space is relative to to the origin

`part.CFrame * CFrame.new(0,0,Z/2)` (a:ToWorldSpace(b)) for example will be a local transformation because it assumes <0,0,Z/2> is local to part.CFrame, converting it into world space (transforming part.CFrame)
`part.CFrame + Vector3.new(0,0,Z/2)` is a global transformation

1 Like