Science Forums: given 2 points, calculate angle - Science Forums

Jump to content

Welcome to ScienceForums.Net!

Welcome to ScienceForums.Net! We welcome science discussion at all levels — from beginners to researchers, covering topics from biology to computer science, and much more. Registration is fast and free, and allows you to post on the forums, so register now and join the discussions!
  
After you've registered, come in and introduce yourself, or visit the forum index. If you need any help  registering, posting, or if you just have some questions about our site, please feel free to contact us at staff at scienceforums dot net.

  • Start new topics and reply to others
  • Subscribe to topics and forums to get automatic updates
  • Create a ScienceForums.Net Blog!
Guest Message © 2012 DevFuse
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

given 2 points, calculate angle Rate Topic: -----

#1 gib65 


Protist
I'm not sure if this is in the right sub-forums. If not, please move it.

If I were given two points (x,y) and (x',y'), how can I determine the angle they form? Let's assume that (x,y) is the vertex of the angle, and the other line the angle is to be measured from is (x+1,y). If the angle is to be defined by the area swept from (x+1,y), pivoting around (x,y) is a counterclockwise direction, and reaching the line connecting (x,y) and (x',y'), how would one calculate the angle?
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
-Albert Einstein
0

#2 Fuzzwood 


Formerly known as Fswd
You need to find the intersecting point first, and how far each point is from that intersection, then do a pythagoras on it?
0

#3 Shadow 


Atom
You can use the dot product to calculate the angle between two vectors. However, you have to be careful how you choose your vectors if you want the specific angle you were talking about.
This applies to the above post and any new ideas or media presented in it.

- "Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
0

#4 gib65 


Protist
Thanks both,

The dot product works for angles from 0 to 180, but beyond that it starts repeating. For example, if (x',y') = (-1,-1) and (x,y) = (0, 0), then theta = 2.356, but if I set (x',y') = (-1,1) then theta = 2.356 - exactly the same. Obviously, I can deduce the angle on the other side by subtracting this result from 2*pi, but it would be best if I had a formula in which I didn't have to do this - the reason being I'm implementing this into a computer program, and I can't just tell it to "eye ball" the angle to tell whether or not it needs to subtract the result from 2*pi. What I need is a formula that gives results that span the whole range from 0 degrees to 360.

Fuzzwood,

Would your suggestion do this? I'm not sure what you mean by "finding the intersecting point". Do you mean the vertex (which wouldn't necessarily be at the origin)?
"I know not with what weapons World War III will be fought, but World War IV will be fought with sticks and stones."
-Albert Einstein
0

#5 Physicsfan 


Meson
I think you need to find the angle that the line joining the two points makes with the x axis.
In that case find the tan by:
y'-y/x'-x

then search the trigonometric tables for the angle
(x-a)(x-b)(x-c)(x-d)..............(x-z)= 0 know why?:eyebrow::eyebrow:>:D:eyebrow::eyebrow:
0

#6 Shadow 


Atom
If the angle with the x-axis is what you want, it's easier to calculate the inverse tan of the slope. But again, be careful; if the angle is larger than 90°, the angle will be negative, and you have to add it, or subtract it's absolute value, to/from 180°.
This applies to the above post and any new ideas or media presented in it.

- "Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users