How to get the edges of a part that has a orientation?

Hi! I was wandering if someone could help me with a problem I am having its more of a mathematical one. Say for example i want to get the x edges of a part i could do this:

local part = --some random part
local partSize = part.Size
local partPosition = part.Position
local xEdges = {}

xEdges[1] = partPosition.X - partSize.X/2
xEdges[2] = partPosition.X + partSize.X/2

--this would be fine if the orientation on the x axis is 0
--[[
however if this part is rotated on the x axis it will be 
wrong because the x axis is not aligned with the true axis in 
world space
]]--
2 Likes

Use CFrame. This will take orientation into account and give you a result that is translated in local space, not world space.

edge = part.CFrame * CFrame.new(part.Size.X * 0.5, 0, 0)
5 Likes

thank you i will test this out now and get back to you