How would I go about mirroring a CFrame
? I tried multiplying the Rotation vectors by math.rad(180)
- individually by code, and simultaneously.
It was close but still obviously inaccurate. The part is merely rotated on the Y axis, and the mirror part was slightly etched on all three axis. It was close, though.
Does CFrame:inverse()
do this? If not, is there a method/equation that does?
Thanks for reading.
Edit: I didn't want to mirror the CFrame, I wanted to mimic the rotation from a second person perspective - 180 degrees flip.
Here's what I understand:
CFrame: 1,1,1 What you want: -1,-1,-1 Right?
If so, All you need to do is Multiply the current CFrame by -1 (-1*1 = -1)
This function mirrors a CFrame about one of the origin's planes:
function mirrorCFrame(cf) local mi = Vector3.new(-1,1,1); local np = cf.p * mi; local mi = CFrame.new( np , np + cf.lookVector * mi * -1 ); local up = CFrame.new(cf.p,cf.p + cf.lookVector); local from = up:toObjectSpace(cf); return mi:toWorldSpace(from) * CFrame.Angles(0,math.pi,0); end