It uses the point of the player (p1) as the center of the circle. The object (p2) would then be the point resting on the radius of that circle. So the distance from p1 to p2 is the radius.
Thats just the concept, the turing program just displays it. Mind blank as to how I should calculate it though. I've tried a few things but I end up with 0 or 1...
Sponsor Sponsor
rdrake
Posted: Mon Nov 13, 2006 9:10 pm Post subject: (No subject)
Use trig.
Clayton
Posted: Mon Nov 13, 2006 9:11 pm Post subject: (No subject)
triangulate the points, then use trigonometry to find the points. In other words, find the distance between p1 and p2, then find the distance of one of the other preferred sides, then use the accompanying trig functions (sin, cos, tan)
Flikerator
Posted: Mon Nov 13, 2006 9:43 pm Post subject: (No subject)
How do right angle triangles help me here? o....o That would only find the angle inside the triangle between the points, and not in relation to a circle.
In Degrees (Radians);
East 0/360 (0,6.28)
North 90 (1.57)
West 180 (3.14)
South 270 (4.71)
I assume you mean like this?;
code:
var x, y : int := 10
var mx, my : int := 100
Draw.Line (x, y, mx, my, black)
Draw.Line (mx, my, x, my, blue)
Draw.Line (x, y, x, my, red)
[/code]
zylum
Posted: Mon Nov 13, 2006 10:13 pm Post subject: (No subject)
there are many topics like this in the turing help section plus googling yeilds many results. i dont think you tried very hard to find the answer.
anyhoo, in grade 10 math, you learn sohcahtoa or something like that. what you are looking for is the 'toa' part, or tan(theta) = opposite/adjacent. so theta = arctan(opposite/adjacent).
Flikerator
Posted: Mon Nov 13, 2006 11:34 pm Post subject: (No subject)
SohCahToa
Sin -> Opposite over Hyp
Cos -> Adjacent over Hyp
Tan -> Op of Adj
No one seems to read my posts. Right Angle triangle equations (trig) will NOT work. I just need the equation to find the angle in a triangle with Side-Side-Side.
I've done all this before, I just don't memorize equations.
It has something to do with Cosine, but that returns me wrong equations when I google it (too many results )
Clayton
Posted: Mon Nov 13, 2006 11:43 pm Post subject: (No subject)
see, the funny thing is, trig is exactly what you need.
zylum
Posted: Tue Nov 14, 2006 12:19 am Post subject: (No subject)
wtf
dx = P2.x - P1.x
dy = P2.y - P1.y
theta = arctan(dy/dx)
what exactly do you need this angle for anyways?
angle.JPG
Description:
Filesize:
5.13 KB
Viewed:
3848 Time(s)
Sponsor Sponsor
Flikerator
Posted: Thu Nov 16, 2006 11:44 pm Post subject: (No subject)
"Trig is exactly what you need", yet you don't say why. Explain, show me why. I'm here for help not your elitist attitude.
I do not want the INTERNAL angle. I don't care if the angle is "30 degrees". I want to know it related to a circle. Here, take this program as an example.
code:
var x1 : int := 150
var y1 : int := 250
var x2 : int := 100
var y2 : int := 300
180 degrees is a flat line traveling right/traveling east. A line going the right direction would be 0 or 360 degrees.
I did not mean that TRIG would not be useful, I meant that RIGHT ANGLE trig would do no good. ie SohCahToa
md
Posted: Fri Nov 17, 2006 12:48 am Post subject: (No subject)
If you have the internal angle, and you know the up/down left/right direction the line points in then you can find hte real angle (ie in 360 degrees) fairly easily.
Draw an xy axis graph, draw a line in each of the four quadrants. See how the sign of the directions is different in each quadrant?
Like everyone said; very simple!
zylum
Posted: Fri Nov 17, 2006 7:59 am Post subject: (No subject)
maybe you need to explain the problem a bit better.. in you first post you said you need the angle between 2 points. in your last post, your program draws 3 points - the centre of the circle and 2 perimeter points. so what exactly are you looking for?
which angle in the progrom do you want?
Flikerator
Posted: Sat Nov 18, 2006 5:06 pm Post subject: (No subject)
zylum wrote:
maybe you need to explain the problem a bit better.. in you first post you said you need the angle between 2 points. in your last post, your program draws 3 points - the centre of the circle and 2 perimeter points. so what exactly are you looking for?
which angle in the progrom do you want?
Edit: I do not mean this sarcastically
I do need the angle between two points, in relation to a circle. I even made a program, in my first post, showing what I meant since "in relation to a circle" might not make any sense.
If you look at the program (Turing) it only has two points.
The second program was to show that the two points didn't always make right angle triangles (When relating them to a circle).
I could use the SohCahToa trig rule for which quadrant. Yes in that case it would work, thank you. Although I would still like that forumula since it would cut down on if statements;
2 of the 4 quadrants;
Quad1=(if x1 > x2 and y1 > y2 then)
Angle = SohCahToa + 0
Quad4=(if x1 > x2 and y1 < y2 then)
Angle = SohCahToa + 270
It was like Cos (a) = A(A)+B(B)+C(C)-2ABC
Something like that[/b]
md
Posted: Sat Nov 18, 2006 6:40 pm Post subject: (No subject)
There is no way of doing it without if statements; or if there is finding it is more work then using if statements. Really, if your trying to "optimize" the code by using fewer lines I think you've got bigger issues... especially since line count very rarely has anything to do with speed.
Brightguy
Posted: Sat Nov 18, 2006 7:43 pm Post subject: Re: Math Question
Your description is confusing... and it doesn't help that most people can't run Turing programs.
I think you are looking for the angle between two vectors... the angle between x and y is given by arccos[(x·y)/(|x||y|)].
zylum
Posted: Sat Nov 18, 2006 11:47 pm Post subject: (No subject)
yes, you can use the dot product like brightguy mintioned or you can use the cosine rule. im sure you can find both formulas somewhere.