Jump to content
  • Advertisement
Sign in to follow this  
Therion__

aircraft rotation code problem

This topic is 3753 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

here i got an very complicated thing with some source, its about airplane rotation. my plan is. getting the camera matrix(ok) calculate a target point in the direction of the camera a bit away with a litte y++ ->that point is after rotation the nose of the airplane the new point the plane and the camera should look at i try to recalculate the new point (angle yaw,angle pitch)..and thats all for the theory i dont now if rotation of the plane(pulling the stick back) change the roll angle.. all i get are strange randomly look like roations.i am very confused i only want to rotate the planes nose up (using the roll angle)..
..eclipse java + openGL(jogl)

//calculate angle
public float winkel(float wtx,float wty)
	{
	float e;
	wtx+=0.00000001f;
	wty+=0.00000001f;
        wiii=(float) ((Math.atan2( wtx ,wty)*180)/3.141593)-90;
        if (wtx<0 && wty<0.0001) wiii+=360;
        if (wty>0) wiii=360+wiii;
	return wiii;	
	}
	
//Calculate distance
	public float entf(float wtx,float wty)
	{
	float e=(float) (Math.sqrt( (wtx*wtx)+(wty*wty) ));
	return e;
	}


// get the Matrix of the Camera
...
	  gl.glLoadIdentity();    	  

	  gl.glTranslatef(0.0f,0.0f,0.0f);
	  gl.glRotatef(-view_r3, 0, 0, 1); //roll
	  gl.glRotatef(-view_r2, 1, 0, 0); //pitch
	  gl.glRotatef(-view_r1, 0, 1, 0); //yaw

gl.glGetFloatv(GL.GL_MODELVIEW_MATRIX, mvm, 0);
...


// view_r1 = yaw // view_r2= pitch // view_r3=roll



float tx=0.0f;	  float ty=0.1f;	  float tz=10.0f;
	 
 
float tx1,ty1,tz1;
  
      tx1= (mvm[0]*tx)+(mvm[1]*ty)+(mvm[2]*tz);
      ty1= (mvm[4]*tx)+(mvm[5]*ty)+(mvm[6]*tz);
      tz1= (mvm[8]*tx)+(mvm[9]*ty)+(mvm[10]*tz);
      
      //New Angle view_r1  
      new_view_r1=winkel(-tx1,-tz1)-90; // the result looks ok ...

	  
      float en=entf(tx1,tz1); //getting distance
	  
      new_view_r2=winkel(en,ty1); //totally bug



Share this post


Link to post
Share on other sites
Advertisement
hello grhodes_at_work,

yes, i wrote the code and its open for everybody
if somebody need it.

'Are you looking for advice on a bug, or are you interested in understanding the theory of rotations?'

i am intressting in both.
a direct advice on the code would be perfect,
but its very important to understand the rotation itself.

i was trying a lot of things, but i know there
is an logical error where i need help

:)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!