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:
1 | function mirrorCFrame(cf) |
2 | local mi = Vector 3. new(- 1 , 1 , 1 ); |
3 | local np = cf.p * mi; |
4 | local mi = CFrame.new( np , np + cf.lookVector * mi * - 1 ); |
5 | local up = CFrame.new(cf.p,cf.p + cf.lookVector); |
6 | local from = up:toObjectSpace(cf); |
7 | return mi:toWorldSpace(from) * CFrame.Angles( 0 ,math.pi, 0 ); |
8 | end |