Why CFrame rotation aspect returns -8.74227766e-08 and not 0?

About CFrame: I have these two parts. The green with orientation=0,0,0 and the blue with orientation=0,180,0.

To show both CFrames:

print('green CFrame: ', workspace.green.CFrame)
print('blue CFrame: ', workspace.blue.CFrame)

I get:

  green CFrame:  0, 0.5, -5, 1, 0, 0, 0, 1, 0, 0, 0, 1
  blue CFrame:  0, 0.5, 5, -1, 0, -8.74227766e-08, 0, 1, 0, 8.74227766e-08, 0, -1

8.74227766e-08 is actually 8.74227766 * 10 ^ -8.

-8.74227766e-08 is almost zero.

So the result for the blue CFrame should be 0, 0.5, 5, -1, 0, 0, 0, 1, 0, 0, 0, -1.

Why not ZERO?

I’ve had things like this happen to me when working with cframes too, ignoring the small issue might be easier than trying to fix it, so it is neat.

Floating point error will accumulate as your rotate and move objects in Roblox. One way that most engineers attempt to resolve this is by using an Epsilon value, which is essentially a very small number. We can consider a value to be zero when it is in the bounds of Epsilon.

1 Like