Rotating an object sometimes rotates by less than 90*

Using the studio default tools, if you grab an object, and rotate it(R key), it’s rotation is sometimes by 89.98/89.875/etc, I noticed that while I was building, all my parts were creeping out of alignment little by little, and just realized why, after the creep started again, I noticed it after posting this thread: someone please make this into a plugin

Shouldn’t Roblox be using matrices to avoid this floating point imprecision problem?

2 Likes

This is exactly what causes the imprecision. They’re not just adding numbers to the values in Rotation, they get calculated from the CFrame of the object.

? matrices at a normal rotation have something like [1,0,0][0,1,0][0,0,1], and their rotation math is easily computed to be exact, so, a 90* rotation on the Y axis will produce [0,0,-1][0,1,0][1,0,0], floating point imprecision shouldn’t affect something as simple at that, my own game engine has no issues at all with 90* rotations, and roblox used to have no issues as well… it just kinda seems like this started happening

Does this happen with default parts, or is there a specific object this occurs with? What OS are you using? Have you tried it without using any plugins?

1 Like

I was saying this:

> c = CFrame.new(0, 0, 0, 0, 0, -1, 1, 0, 0, 0, -1 ,0)
> x, y, z = c:toEulerAnglesXYZ()
> print(math.deg(x), math.deg(y), math.deg(z))
-90.000002504478 -90.000002504478 0

The floating point imprecision is due to obtaining the angles from the CFrame. The Properties window uses a similar method to update the Rotation property every time the CFrame property changes of the object. So while the angle may seem incorrect in Rotation, it might actually be just fine.

[quote]

toEulerAnglesXYZ() [/quote]

Found the problem.

Normal parts, Windows 8/8.1, I’ve only seen it happen with the default Studio rotate tool.

EDIT: Also, this isn’t new. I’ve seen it for months, which is one reason why I prefer CmdUtil’s rotate tool (it doesn’t seem to have this problem).

What could possibly go wrong with 90 degree rotations ending up at 89.98? Thanks for the find!

Windows 8.1, normal parts, happens whenever I rotate any part in this one place of mine, I don’t use anything but the default rotate tool, you can have a simple repro place/screenshots if it helps any

It seems to happen on more than 8/8.1 for me so it looks like a more systematic issue, although I still haven’t had it occur with only using R to rotate the object. The steps are fairly simple so no repro place is needed. Thanks for the help!

R to rotate, along with using the rotate draggers (on both grid size settings) both produce the same 90* rotation problems

This is still happening (to me anyway).
I have noticed that Wedges seem to have the issue more than Parts.
I have a Wedge in my place that I’m trying to Union with other Parts. I’ve noticed that negative angles, or angles that have decimals don’t Union well, so I tried setting the Rotation of the Wedge to 0,0,0 and using the Studio Rotate tool to place it the correct way.
After using the 1 stud grid (45 degree angle movements) to rotate the Wedge by 90 degrees in 2 planes, I get a Wedge that appears to be aligned with the other Parts correctly, but when I check the Rotation I find it’s at -128.927, 89.98, -141.073.
By that Position the Wedge shouldn’t be aligned to any x,y,z plane at all!
Also, changing any value in the Rotation manually (say, the 89.98 y axis to 0) completely changes the other angles.
This makes Unioning parts very much a pain in the ass.

I’m using OSX 10.10.4 and it also happens to me.

Plus, dragging two or more parts seems to raise the parts by about 0.02, especially when placing the parts against another part.

:oops: Oh yeah, Windows 8.1 on an HP AMD FX 3.5 GHz 770K Quad core.
Does using a mouse or touch screen make any difference here? I’m using a mouse…

I’m on Windows 10 and I’m having the same issue.

I want to scream.
blob.png
Bumping this because my OCD is off the charts right now and I don’t even have OCD.

6 Likes

If you use cmdutl or another plugin that circumvents the default studio tools, rounding errors don’t happen.

¯\_(ツ)_/¯

Instead of multiplying the cframe by a 90 degree matrix, it should flip the components of the two perpendicular vectors, and make one negative. I recently updated my geometry plugin to do 90 degree rotations without matrix creep (the “Part Flip” tool):

Edit: CFrame.Angles(math.pi/2, 0, 0) wont create a perfect 90 degree matrix because radians aren’t exact (you can get values like 0.0000000437 instead of 0). Multiplying by a perfectly aligned matrix composed of 0’s, 1’s, and -1’s should be okay.

1 Like

What OS are you on and can you send a copy of the model or an image of it?

Repro.rbxl (11.4 KB)

Rotating the part in the repro file (starting at <0,-90,0>) gives rotation values of <-179.998, -44.998, -179.997> and <-0.002, -45.002, -0.003> when rotated left/right using the default rotate tool and the 1-stud increment.

OS: Windows 10. Pretty sure this happened when I was using Windows 7 as well.