#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    134
    Rep Power
    0

    Converting onto XYZ from vector, need help.


    Hello people.

    I have a vector that defines a rotation in degrees.
    I must transform this onto XYZ (supposedly: world) so I can properly apply an impulse using a physics engine.

    How can I do this?.
    I'm stuck!.

    Shorter question: How can I transform a vector onto XYZ components, if the vector defines a rotation angle in degrees.

    My vector magnitude is used as a "power" multiplier for the final impulse, I think this can be left alone on the actual computation of the XYZ components.


    Thanks in advance
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    134
    Rep Power
    0
    I forgot to add: I'm using SIN and COS right now, however I was seeking for a more optimized solution. Sorry for not adding this on the original post.

    I hope I'm making some sense here.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    81
    Rep Power
    12
    if you are using cyclidrical coordinates, R = length and W (theta) = angle
    then X (or adjacent angle) = R Cos W
    and Y (or opposite angle) = R Sin W
    If you are using spherical coordinates it is different
  6. #4
  7. C# Addict.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Earth
    Posts
    283
    Rep Power
    29
    Take a look at this link.
    http://mathworld.wolfram.com/EulerAngles.html
    You should have learned this stuff in school though.
    There are none so blind as those who will not see. Jonathan Swift

    My 2D Physics Engine.
    My Remake of UQM.
    Both are written in C#.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    8
    Rep Power
    0
    Originally Posted by BioSlayer
    Take a look at this link.
    http://mathworld.wolfram.com/EulerAngles.html
    You should have learned this stuff in school though.
    If you plan on using a matrix to transform the vector using trigonomic operations, its HIGHLY recommended that you create something known as a Trigonomic Lookup Table, which contains basically an array of floating point numbers containing the results of a sin or cosine operation. Then the only magic is figuring out how the shift the array access index by 1/4 that of a full circle.

    This is important to bear in mind that trigonomic operations basically kill the CPU, looking up a predefined trigonomic value is much more efficient.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    May 2004
    Posts
    3,417
    Rep Power
    887
    I think you might want to investigate quaternions
    I no longer wish to be associated with this site.
  12. #7
  13. C# Addict.
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Location
    Earth
    Posts
    283
    Rep Power
    29
    Originally Posted by MassKiller
    This is important to bear in mind that trigonomic operations basically kill the CPU, looking up a predefined trigonomic value is much more efficient.
    I looked around and I couldn't find much on this subject. Would you be willing to post a link or 2 about this?
    There are none so blind as those who will not see. Jonathan Swift

    My 2D Physics Engine.
    My Remake of UQM.
    Both are written in C#.

IMN logo majestic logo threadwatch logo seochat tools logo