[Nottingham] Trigonometry!

Jonathan john00 at gmail.com
Wed Jan 24 23:41:25 GMT 2007


If you have two pairs of coordinates (x_1, y_1) and (x_2, y_2) in the
first quadrant of R^2 (x_1, x_2 > 0 and y_1, y_2 > 0) and want to
determine the angle the line x = x_1 forms with the hypotenuse (which
from your description is what you want to do...I think!) just use a
bit of elementary trig:

Consider the triangle formed with opposite 'y_2 - y_1' and adjacent
'x_2 - x_1'.
tan(theta) = opposite / adjacent = (y_2 - y_1) / (x_2 - x_1).
Now just apply the inverse tan function...
'atan' in C, not sure about PHP...

Best Regards, Jonathan.

On 24/01/07, Richard Hayes <ricky at domainarena.net> wrote:
>
>
> Hello guys.
>
> Slightly off topic, but it's something I'm programming in PHP on a Linux
> server so it kind of counts.
>
> I'm writing some stuff in GD lib (php) which draws me nice graphs. Except I
> can't remember a thing about trigonometry from school and I'm struggling.
>
> I have two set of coordinates, eg:
>
> 1. 0,0
> 2. 25,25
>
> With a line drawn between them.
>
> I know that this line is at 135 degrees from 0 (correct me if i'm wrong!).
> What calculation can I do on these number to give this this amount in
> degrees?
>
> (Or, let's say my coords are 0,0 drawn to 50,0, then my angle is 90 degrees
> (a right angle).)
>
> It's really as simple as that.
>
> I've googled and googled and googled, but I'm beat.
>
> Any help?
>
> Thanks!
>
> Kind regards,
>
> Richard Hayes
> DomainArena
> ricky at domainarena.net
> _______________________________________________
> Nottingham mailing list
> Nottingham at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/nottingham
>
>



More information about the Nottingham mailing list