Results 1 to 2 of 2

Math Help - Angle from 3d Vectors

  1. #1
    Newbie
    Joined
    Apr 2008
    Posts
    2

    Angle from 3d Vectors

    I'm not sure if I'm posting this in the right place (this is my first post) but I figured I'd give it a shot.

    I'm working on a project in a 3d engine involving a tank running around a landscape and shooting. The turret of the tank can rotated 360 degrees and the barrel can have its elevation angle set anywhere from 0 to 90 degrees.

    What I needed to do was ensure that the elevation of barrel took into account the angle of the tank itself, as it would be travelling up and down hills.

    In the end, here's what I did to figure out the actual elevation angle of the barrel (taking into consideration what the user had set for the barrel elevation as well as the angle of the tank itself).

    BarrelVector = VNormalize(VSubtract(BaseOfBarrel, EndOfBarrel))
    PlaneVector = VNormalize(VSbutract(BaseOfBarrel, EndOfBarrelWithYSetToBase))
    DotProd = VDotProduct(BarrelVector,PlaneVector)
    TrueElevation = ACos(DotProd)

    Now, this returns an angle from 0 to 90 and therein lies my problem. If the barrel is pointed parrell to the Y plane, the angle is 0, no problem there. But if the barrel is pointed 10 degrees below the Y plane, the angle returned is 10, the same as it is when the barrel is 10 degrres above the Y plane. What I really need is the to return as -10. The same issue happens at the 90 degree angle, where an 80 degree and a 100 degree both return 80.

    I know this is a result of the ACos function but I have no idea how to get around this. Any advice would be appreciated.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Apr 2008
    Posts
    2
    Wow, no one? No other alternative to get a true angle other than ACos? Ugh...
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Vectors and an angle
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: April 6th 2011, 10:24 AM
  2. Angle between two vectors
    Posted in the Math Software Forum
    Replies: 6
    Last Post: November 22nd 2010, 08:40 AM
  3. Angle between Vectors
    Posted in the Advanced Algebra Forum
    Replies: 2
    Last Post: November 26th 2009, 08:44 AM
  4. angle between the vectors
    Posted in the Calculus Forum
    Replies: 2
    Last Post: March 25th 2009, 07:27 PM
  5. Angle between vectors
    Posted in the Advanced Applied Math Forum
    Replies: 4
    Last Post: December 28th 2007, 09:30 AM

Search Tags


/mathhelpforum @mathhelpforum