Results 1 to 3 of 3
  1. #1
    imorio is offline Senior Member
    Join Date
    Aug 2010
    Posts
    127
    Rep Power
    0

    Default calculating the angle between 3 points

    I have 3 points: A, B and C. These are just pairs of doubles defining their x and y values. Now I need to calculate the angle between the lines AB and BC. Is there a methode in the standard java library that does this? I thought there was one in the Math class, but I was wrong.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,370
    Blog Entries
    1
    Rep Power
    21

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,043
    Blog Entries
    7
    Rep Power
    23

    Default

    Quote Originally Posted by imorio View Post
    I have 3 points: A, B and C. These are just pairs of doubles defining their x and y values. Now I need to calculate the angle between the lines AB and BC. Is there a methode in the standard java library that does this? I thought there was one in the Math class, but I was wrong.
    The dot product of two vectors AB and BC is defined as |AB|*|BC|* cos(a) where |x| is the length of vector x and a is the angle between the vectors AB and BC. The dot product also is AB_x*BC_x+AB_y*BC_y; do your math.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. Angle to Radians and Calculate the Cosine
    By coldplay7588 in forum New To Java
    Replies: 7
    Last Post: 09-26-2010, 08:12 PM
  2. AffineTransform begin at custom angle
    By crazycat03 in forum AWT / Swing
    Replies: 3
    Last Post: 01-25-2010, 09:00 AM
  3. Java3D Vector3d.angle(Vector3d)
    By Duesentrieb in forum Advanced Java
    Replies: 5
    Last Post: 01-20-2009, 08:47 PM
  4. Replies: 2
    Last Post: 08-24-2008, 12:30 AM
  5. Calculate X and Y given starting angle and distance
    By nidhirastogi in forum Java 2D
    Replies: 5
    Last Post: 08-18-2008, 10:24 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
  •