obj-magic icon indicating copy to clipboard operation
obj-magic copied to clipboard

rotate command can not handle floats and is in radians instead of degrees

Open DanielBalog86 opened this issue 6 years ago • 1 comments

The --rotate[xyz] command states that it rotates a mesh in degrees around a specified axis.

Doing some experiments I have drawn 2 conclusions:

  1. This is actually RADIANS
  2. I can not pass a floating point number (like 0.234) to the command. It only seems to parse integers.

I have worked around this issue by using the nearest multiple of 2*PI that resulted in a rough round number. This worked, which seems to confirm my suspicion.

DanielBalog86 avatar Nov 19 '19 07:11 DanielBalog86

Due to the keen observation of @DanielBalog86 concerning radians instead of degrees, an easy fix is possible. In obj-magic.cpp, add radians function calls around the 2nd parameter for the calls to rotate, like the following: if (rotangles.x != 0.0f) temprot = rotate(temprot, radians(rotangles.x), vec3(1,0,0)); if (rotangles.y != 0.0f) temprot = rotate(temprot, radians(rotangles.y), vec3(0,1,0)); if (rotangles.z != 0.0f) temprot = rotate(temprot, radians(rotangles.z), vec3(0,0,1));

However, I do not observe that floating point numbers cannot be properly used as input. Instead, I noticed that negative numbers cannot be used properly, similar to #5. If I supply -90, it's using -9. Fortunately, for rotation degrees, 270 can be used instead of -90. For translation, not so much.

In summary, this issue should be resolved with the fix above, leaving the float vs integers portion to another issue. From what I can tell, resolving #5 would improve things a bit if not fix any input parsing related issues.

puzzud avatar Jul 11 '22 00:07 puzzud