PDA

Click to See Complete Forum and Search --> : how do u find the angle of these points?


voidflux
Dec 30th, 2003, 11:17 PM
Hello everyone, I was reading next semesters programming book and I can't even figure out how to do this problem on paper, so It doesn't look like i'll be programming it anytime soon. Here's my question, They say, design and implement a class called circle_location to keep track of the postion of a single point that travels around a circle. An object of this clas records the position of the point as an angle, measured in a clockwise direction from the top of the circle. Programming this isn't my problem, but I'm confused on how i'm suppose to figure out the angle of the point. So say I have a point at (0,0) and (3,3) this would make a line then I could draw a vertical line down to make a right angle, but how would I find the angle of that? with just given 2 points? Or am i misunderstanding what they really want me to do?
Thanks! :wave:

kedaman
Dec 31st, 2003, 01:08 AM
google on trigonometry

jemidiah
Jan 1st, 2004, 12:31 PM
You can use tan-1 (abs(y1 - y2))/(abs(x1 - x2))

With the originating point being (x2, y2) and the other being (x1, y1). Now, you'll have to use whether (y1 - y2) and (x1 - x2) or positive or negative to tell you which quadrant it's in.

- , + = quadrant 4
- , - = quadrant 3
+ , - = quadrant 2
+ , + = quadrant 1

I'm sure there are other ways (like somehow using the parametric representation of a circle and solving for T), but that *should* work with some fiddling around.

voidflux
Jan 2nd, 2004, 10:52 AM
Thanks jemidiah, That will work great!
:D

jemidiah
Jan 2nd, 2004, 08:56 PM
One thing I remembered: when x1 - x2 = 0, you'd get a divide by zero error (duh), so the angle'll be 90 :)

sw_is_great
Jan 4th, 2004, 04:14 AM
yeh its infinity and tan 90 is infinity

TheManWhoCan
Jan 4th, 2004, 12:27 PM
I haven't nit-picked for a while, so here goes:

tan90o is infinite not infinity, they are different.

kedaman
Jan 4th, 2004, 02:43 PM
I thought tan 90° was not defined, likewise cot 0° csc 0° and sec 90°

jemidiah
Jan 4th, 2004, 04:56 PM
They're all divide by zero errors, so you could debate about anything you want (search the forums if you really want to see war ;))

kedaman
Jan 4th, 2004, 05:41 PM
yeah but i dont like war.. or nit picking for that matter ;) I just thought some general info on how to use trigonometry would do good.