Euler rotation ==> Quaternion rotation
Blitz3D Forums/Blitz3D Programming/Euler rotation ==> Quaternion rotation
| ||
hi! i think you heard of my software render lib. my problem now is that i'm using euler rotation and i dont know how to use the real rotation - i mean quaternion rotation... this example shows pretty good what i mean Graphics3D 800, 600, 32, 2 SetBuffer BackBuffer() ;Camera Cam = CreateCamera() RotateEntity CreateLight(), 70, 20, 0 ;Cubes Cube1 = CreateCube() PositionEntity Cube1, -2, 0, 5 Cube2 = CreateCube() PositionEntity Cube2, 2, 0, 5 SetFont LoadFont("Arial", 30, True) While Not KeyHit(1) ;Cube 1 rotation (Euler; WRONG!) rot = rot + 2 RotateEntity Cube1, rot, rot, rot ;Cube 2 rotation (Quaternion; RIGHT!) TurnEntity Cube2, 2, 2, 2 RenderWorld Text 40, 100, "Euler rotation:" Text 40, 140, "(Like in my software renderer)" Text 500, 100, "Quaternion rotation:" Text 500, 140, "(I need that)" Rect 400, 0, 1, 600 Flip Wend End this is my matrix lib so far. it is fully working, but the euler rotation is just bothering me ;D thank you for any help :) |
| ||
I'm not sure if it helps, but for my saveanimmesh routine, i needed to convert euler angles to quaternions. After a while, I learnt that Blitz has it's own system for quats, and with the help of a routine by LeadWerks, I could convert from p/y/r to w/x/y/z: |
| ||
hmh. i dont know what that is, but i tried to implement this in a few ways, it might work. but it aint... sorry |
| ||
;this code was written by LeadWerks That should read: This code was copied from other people's code by Leadwerks. Hehe. |
| ||
hm. whatever there must be a very simple formula which converts euler to quaternion angles. |
| ||
But quaternions need 4 parameters, right ? That is what this function does, it converts the 3 parameter pitch/yaw/roll rotation to a 4 parameter quaternion. The problem you're having it a bit above my head. I understand what the trouble is, but I'm not sure how to solve it. It might be related to the 'gimbal lock'. I've had some problems with that when reading angles from a rotated object, and I found some code that solves that. But that is the reverse of your problem. After a search on gimbal lock, I found this: http://www.dscho.co.uk/blitz/tutorials/quaternions.shtml (there is a link for quat.bb) I hope it helps. |
| ||
this code there simply rotates a cube. what i wanted to know is how to do this with simple vectors and matrices... |
| ||
Have you seen this page? First one that came up on Google. Seems to explain how to do Euler to Quat. |
| ||
hm. it seems like i have to do this the hard way - search till my fingers bleed. thank you guys anyway:) |
| ||
Doesn't that article tell you what you need, then? |
| ||
I think he require a code for copy&paste :/ |
| ||
i did not ask for a someone who gets me tons of code... i'm rather looking for something that can help me out. i think this article offers a lot of good stuff. |