Rotation above 360º
On 07/11/2013 at 12:04, xxxxxxxx wrote:
Cinema 4D Version: R13-R14
Platform: Windows ;
Language(s) : C++ ;
Hi everybody, I am sure some of you have been where I am now. I am not a mathematician, not a scientist, I am just a mortal programmer by profession. And a 3D amateur who wants to write some plugins.
The rotation system in C4D is currently my main "enemy". I have tried all kinds of methods, functions and the like, but whatever I do, I cannot make it work. I have a post here pending, on how to reduce the amount of rotation by a percentage value. C4D has no problems doing this on the time line, but I can't. Now I have a very basic question: How do you get degrees above 360º?
Look at the screen shot. I have rotated this cube several times. Both the dial above the cube, and the coordinates window in the attributes manager show 747.512º. But look at the Console window, it shows 27.512º. This window shows data I emit using GePrint() in my C++ code. I just cannot get any result above 360º, and this is the cause (I think) for some of the things I cannot get working.
Is there a place I can find out more about how rotation in C4D works? Does folks from C4D peer into this group, I am sure they would know how to do this.
On 07/11/2013 at 13:54, xxxxxxxx wrote:
rotation values beyond 360° are a theoretical construct which only does exist in the GUI
for the user. it is quite similar to the object axis, which also only does exist as theoretical
construct, as the point origin relation is written into each point value.
747 % 360 = 27
There is also HBP-rotation system trying to avoid gimbal locks, quaternions are the logic behind
that behaviour. But that is some rather nasty math, so you have to either read about that topic
for yourself or just stick with the quaternion classes the cpp sdk does expose.
On 07/11/2013 at 22:28, xxxxxxxx wrote:
Ok, this I fully accept.
>or just stick with the quaternion classes
That would be my solution. I have done some experiments with them, but I have little success so far. While for example Qslerp works fine in the area of 0º..179º, weird effects are introduced when the second parameter's matrix ( the q2 ) goes by the 180º degree point. See my recent post in this forum about adjusting a rotation by a percentage.
I do not know enough math to ask intelligent questions. But in this mentioned case, I just want one object's rotation to be anything from zero to 100% of a given other objects's rotation in 3D space. And it works like magic using Quaternions, until I pass the 180º dergee point..
On 16/07/2014 at 10:10, xxxxxxxx wrote:
I don't know if you solved your problem already, but I'm in a similar situation as you were. Here's what I know:
If you consider a quaternion as a mechanism to rotate your object and get results in euler angles, you soon find out that you will never get angles beyond 180º, so a rotation of 360º or 720º or 0º will return the same quaternion.
That said, the Qslerp method will only interpolate the rotation in the same interval (>-180º, <180º). Which means that an angle of 190º is the same as an angle of -10º.
In order to work around this issue, I'm using the rotation read from the C4D file, and then apply this calculations:
rotate = beginTransf.rotation * (1.0f - transformPercent) + endTransf.rotation * transformPercent;
beginTransf and endTransf represent transformations for a specific interval of keyframes, for example beginTransf could be keyframe 0 and endTransf the keyframe 1
After that I convert the rotation into a quaternion and multiply it by my main transform matrix.
On 16/07/2014 at 12:27, xxxxxxxx wrote:
Hi magemau, interesting!
Currently, I am not writing C4D C++ code, so my head is not loaded with much C4D knowledge. I will start in August again, and relearn some of this, to get me up and running again. Then I will post to this forum also, again. Thanks for your post!