Results 1 to 2 of 2

Thread: Finding a direction vector.

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2009
    Invercargill, Southland, New Zealand

    Finding a direction vector.

    Ok. Say I have two angles. A roll angle (around z-axis) and a pitch angle (around x-axis) for the orientation of a spaceship. This is all I need it seems to point the spaceship and draw it. Problem is I want to move it forward. How do I calculate a direction vector?


  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Los Angeles

    Re: Finding a direction vector.

    Blain - the phrase "I want it to move forward" is pretty vague, particularly considering you are working with a spaceship. I'm going to assume that you want your ship to fly like a plane, i.e. you want it to fly along the reoriented Z axis (roll axis). If this is true, try the following:

    glPushMatrix ();
    glRotatef (pitch_angle, 1,0,0);
    glRotatef ( roll_angle, 0,0,1);
    glTranslatef (0, 0, distance);
    Draw_Spaceship ();
    glPopMatrix ();

    If this doesn't work, try switching the order of the rotations. Using this approach you don't have to explicitly compute the direction vector. The translation and spaceship will be reoriented by the rotations. This only works if you want the ship to move in a straight line along the spaceship's Z axis. Good luck.
    Am I doing your homework for you?

Similar Threads

  1. Replies: 1
    Last Post: 07-20-2017, 05:44 PM
  2. Getting Eye direction vector
    By Rodrigo in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-20-2013, 11:05 PM
  3. Need help finding direction in opengl programming
    By oglmedi in forum OpenGL: General
    Replies: 0
    Last Post: 11-05-2012, 05:33 PM
  4. Direction and vector
    By giugio in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 09-30-2011, 09:39 AM
  5. Replies: 2
    Last Post: 01-07-2004, 11:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean