• Create Account

# Positioning rotated alieron (torque rotation)

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1WiredCat  Members   -  Reputation: 67

Like
0Likes
Like

Posted 02 October 2012 - 12:39 PM

Look at this image.
The thing is i want to find new position of the blue dot if i rotate aircraft

I start from positioning the center of an aircraft then i move whole model to geometric center (red dot)
i already have fixed airframe (alieron) position so i know where to translate it when no rotation is applied. But then rotation appears:

I know the front direction of an aircraft, its up direction and its right direction, but i have strange feelings about my solution so i ask here:
I want to do something like this:
- go to red dot
- multiple vector AB X value by normalized right direction
- multiple vector AB Y value by normalized up direction
- multiple vector AB Z value by normalized front direction

and here is the deal i think this will position the airfoil in the right direction but with wrong distances? am i right what i need to do?

Edited by ___, 02 October 2012 - 04:29 PM.

### #2freakchild  Members   -  Reputation: 557

Like
0Likes
Like

Posted 02 October 2012 - 02:25 PM

Your solution should involve rotating the aircraft by using a specific rotation matrix, or packing that same rotational information into a full transform matrix. Really, I think all the operations you describe above are concatenations of matrix transformations (both translations and rotation matrix operations combined together).

You should be able to use the same matrix to rotate and/or transform (meaning rotate and translate) the aircraft and apply the same to the blue dot in order to find the transformed position of it.

If you want to animate the ailerons then you'll want to rotate the aileron first about it's own local axis in order to deflect them as a real aircraft would in response to a stick input and then apply the aircraft transformation to it afterwards in order to position and orient it correctly on the aircraft. This can again be concatenated into one matrix transformation.

Edited by freakchild, 02 October 2012 - 03:17 PM.

### #3WiredCat  Members   -  Reputation: 67

Like
0Likes
Like

Posted 04 October 2012 - 07:27 AM

Yeah that is quite simple : ) I will check it in the near future, because i need to create airplane model, code cameras etc. but it looks like the answer to my problem
I only have a question about rotating using opengl ( i don't have much time i prefer to code something else rather than check it ;p ) if i have alieron center position not in 0,0,0 but in x,y,z and if i want to rotate(glrotate)it by X,0,0 or 0,Y,0 0,0,Z axises i just need to transalte it to 0,0,0 point ( -x,-y,-z)

and second question: you have told me that i need to rotate it by local axis then just multiple matrices [ alieron with airplane modelview (simple glMultMatrixf) ] right? this should do the work?

### #4freakchild  Members   -  Reputation: 557

Like
0Likes
Like

Posted 04 October 2012 - 03:33 PM

i have alieron center position not in 0,0,0 but in x,y,z and if i want to rotate(glrotate)it by X,0,0 or 0,Y,0 0,0,Z axises i just need to transalte it to 0,0,0 point ( -x,-y,-z)

Yes, that sounds right. Translate by (-x,-y,-z) and then do the rotations you need, then translate by (x,y,z) in order to put it back in place.

and second question: you have told me that i need to rotate it by local axis then just multiple matrices [ alieron with airplane modelview (simple glMultMatrixf) ] right? this should do the work?

glMultMatrix along with glRotate, glTranslate and so on, operating on the modelview matrix can work yes but do bear in mind that all these functions apply operations to the 'current' matrix, which will be determined by glMatrixMode and whatever you initially loaded by glLoadMatrix.

While that version of the API has handy functions like glPush/PopMatrix which can help too it can get a little cumbersome and difficult to debug, especially if you're new.

As an alternative many people do author or use a matrix library, working outside of opengl first and then submitting the final results to the GL_MODELVIEW matrix via LoadMatrix. This can offer a little more flexibility as far as manipulating matrices goes and can help in understanding things.

### #5WiredCat  Members   -  Reputation: 67

Like
0Likes
Like

Posted 04 October 2012 - 07:38 PM

no worry i am rather advanced ;] just want to be sure before writing ; P tommorow i will check it, just need to scale model and add a new class, that ?will?be using aircraft and airlierons and other things, i forget many things because i drink too much beer o:! it is good to ask someone else rather than cdoe carp and then figuring whats wrong (read as know what is wrong but how to fix it ) god bless you ;d;d;d enough of this crap over and out! :X

Edited by ___, 04 October 2012 - 07:42 PM.

### #6WiredCat  Members   -  Reputation: 67

Like
0Likes
Like

Posted 06 October 2012 - 11:18 AM

Now i have this:

http://youtu.be/IfjROPkTTAM

and i use this:

not important stuff like drawing jet model
glPushMatrix();

gluLookAt(kold.x,kold.y,kold.z,kold.x+ksp.x,
kold.y-ksp.y,kold.z-ksp.z,0,1,0); //camera dude
glDisable(GL_DEPTH_TEST);//only to see the airlieron
glColor3f(1,0,0);
glTranslatef(PHYSIC_MODEL->AIRLIERON_LEFT->model->CENTER_POINT.x,PHYSIC_MODEL->AIRLIERON_LEFT->model->CENTER_POINT.y,PHYSIC_MODEL->AIRLIERON_LEFT->model->CENTER_POINT.z);
glRotatef(PHYSIC_MODEL->AIRLIERON_LEFT->pitcha,1.0f,0.0f,0.0f);
glTranslatef(-PHYSIC_MODEL->AIRLIERON_LEFT->model->CENTER_POINT.x,-PHYSIC_MODEL->AIRLIERON_LEFT->model->CENTER_POINT.y,-PHYSIC_MODEL->AIRLIERON_LEFT->model->CENTER_POINT.z);

glMultMatrixf(PHYSIC_MODEL->YPRangle.AIR_MATRIX);

PHYSIC_MODEL->AIRLIERON_LEFT->model->DrawSimpleModel();
glEnable(GL_DEPTH_TEST);
glPopMatrix();


I will explain some things

i have an airlieron model in position (CENTER_POINT [x,y,z] i don't know what is the center but i do now that is not 0,0,0 ;x)
so in order to simple rotate for test purposes i do [opengl uses stupid ordering ;P]
i translate airlieron to 0,0,0 point, then i am rotating it and then translating to its position, then i apply JET matrix as seen above.
Any suggestions to make it work ?:X

SOLVED. The thing was that i called glMultMatrixf last instead of first x_X right after glulookat

Edited by ___, 07 October 2012 - 07:10 AM.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS