Rotate a direction vector around pitch/yaw

This is a discussion on Rotate a direction vector around pitch/yaw within the Game Programming forums, part of the General Programming Boards category; hi! let's say i have a vector pointing into a direction. i want to rotate the vector arount some yaw/pitch ...

  1. #1
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244

    Rotate a direction vector around pitch/yaw

    hi!
    let's say i have a vector pointing into a direction. i want to rotate the vector arount some yaw/pitch to make it point into another direction.
    how can i do this without having to implement a matrix system into my project?

    thanks in advance

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Devils Child View Post
    hi!
    let's say i have a vector pointing into a direction. i want to rotate the vector arount some yaw/pitch to make it point into another direction.
    how can i do this without having to implement a matrix system into my project?

    thanks in advance
    To distinguish between yaw and pitch you need to know which way is "up" which means you need another vector. Vectors, vectors, vectors... And you DON'T want to use matrices?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    no. since in my raytracer (c#) the only place for the use of matrices would be this:
    i send a ray for each pixel on the screen. but the camera can be rotated, so i need this ray of the pixel to rotate with the camera, know what i mean?

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Axis-angle rotation would work for this. Just because your system does not currently use matrices does not mean you will not need them for basic 3D operations.

  5. #5
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    well, do you have an algorithm (code) for that? something with sines and cosines should do the trick but i just don't get it...

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    1,205

  7. #7
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    call me stupid but i either find 2D stuff, some complex mathematic constructs or porn, but not what i'm looking for.
    i just neet this damn formula ;(

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    some complex mathematic constructs
    If you don't like math then don't attempt 3D graphics or raytracers. If you can read the formulas then stop complaining and figure it out.

  9. #9
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    don't attempt raytracers?

    this is a pic of my raytracer yet: http://www.dev-ch.de/upload/files/De.../Screen329.png
    regarding this picture, i'm not stupid, heh :P

  10. #10
    Registered User Devils Child's Avatar
    Join Date
    Jan 2008
    Posts
    244
    ALRIGHT, i bothered my brother until he gave me this:

    Code:
    nx * cos(yaw) + (ny * sin(pitch) + nz * cos(pitch)) * sin(yaw)
    ny * cos(pitch) - nz * sin(pitch)
    -nx * sin(yaw) + (ny * sin(pitch) + nz * cos(pitch)) * cos(yaw)
    that's what i really needed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Camera rotate to function
    By VirtualAce in forum Game Programming
    Replies: 0
    Last Post: 11-15-2008, 11:22 AM
  2. Mouse Maze Problem
    By Furbiesandbeans in forum C++ Programming
    Replies: 13
    Last Post: 04-28-2008, 04:20 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Algorithm to walk through a maze.
    By Nutshell in forum C Programming
    Replies: 30
    Last Post: 01-21-2002, 12:54 AM
  5. Classic problem doesn't accept direction
    By cheesehead in forum C++ Programming
    Replies: 5
    Last Post: 11-13-2001, 05:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21