You are not logged in.

#1 2011-03-08 22:26:51

owen
Member

GRRLIB_ObjectView() and object rotation

Good Day,

The problem I have now is that I am rotating my shape on the z axis by 10 using;

GRRLIB_ObjectView( x, y,z, 0,0,10,sx,sy,sz);

It creates a sorta clockwise or anticlockwise movement.  Which is strange but works fine on its own.  Problem is I can't seem to calculate where the top edge of the object view will fall once I start rotating it.  My math is not the best

Code:

rotation+=rotation_speed;
if(rotation > 360) p.rotation=0; 
        
radians = rotation * M_PI / 180;

dz = sinf( radians );        
        
do_draw_sphere( x, y, z+(p.distance * dz), scale, colour );

so I'm trying to make the circle follow the top edge of the shape.  but no matter what I do I cannot replicate the rotation at all.  I have no idea what calculation is being used.  Any body have an idea as to how I can calculate where the top edge is?

Offline

 

#2 2011-03-18 04:03:09

owen
Member

Re: GRRLIB_ObjectView() and object rotation

I managed to find something on euclidean rotation but it suffers from gimbal lock.  Then I tried looking in quaternions but it was so confusing that I just quit that topic all together.  Single axis rotate only from now on.

Offline

 

#3 2011-03-20 18:20:14

mdbrim
Member

Re: GRRLIB_ObjectView() and object rotation

quaternions was the only way i could get mine to work... like you said, i had gimbal lock with euclidean.  I had an easier time with quaternions cuz my shapes were cubes... so they would always with a surface flat on axis system.

Offline

 

#4 2011-03-20 20:03:49

owen
Member

Re: GRRLIB_ObjectView() and object rotation

How simple is your implentation of quaternions?  i cannot seem to understand it or get it to work.  All I want to do is rotate a point around another point by 1 or more angles.

Offline

 

#5 2011-03-21 01:57:41

mdbrim
Member

Re: GRRLIB_ObjectView() and object rotation

well it was very hard for me to comprehend... and i still don't fully get it, but mine is dif in the fact taht i was using a physics engine that was giving me the results of the physics in quaternions... i would just pass those onto grrlib to draw the resulting dice... the hard part was being able to take the resulting quaternoins when the dice came to a rest, and tell the game what face was up... i was able to figure that out using google (for about three hours) and finding the mathmatical relationship between the four parts of the quaternioin... (angle.w, angle.x, angle.y, angle.z)  i'll be happy to pass those on to you if they help...  if YOU are the one editing your quaternion values, you could just play with the .w, .x, .y, and .z values to see what they do.  it seemed pretty easy, i just kinda skipped that step since the physics engine was doing that work for me.  Check your email for the GRRLIB code i used to mess with the quaternions.

Offline

 

#6 2011-03-21 17:23:50

owen
Member

Re: GRRLIB_ObjectView() and object rotation

I spent the last couple a weeks on it, no progress, I am leaving it until next month.  Hopefully next month I will be lucky enough to find a simple Vextor -> Quat Rotation Around Point -> Vector

Offline

 

Board footer

Powered by FluxBB