Kostya hit it:

float angleDegrees = Math.toDegrees(Math.atan2((y1 - y2) / (x1 -
x2)));

On Sep 15, 11:32 am, Kostya Vasilyev <kmans...@gmail.com> wrote:
>   Pedro,
>
> Java (and pretty much any language's) trig functions work with angles
> expressed in radians.
>
> http://en.wikipedia.org/wiki/Radian
>
> To convert to degrees, multiply by 180 / 3,1415926.... (in Java, that's
> Math.PI). Or just call Math.toDegrees.
>
> Better yet - use Math.atan2 ( difference along Y, different along X).
> This one correctly handles the case of value3-value4 being zero (or very
> close thereof).
>
> -- Kostya
>
> 15.09.2010 20:22, Pedro Teixeira пишет:
>
> > Hi,
>
> > I'm having problems with JAva and trigonometry to calculate a
> > direction from a point to a certain point...
>
> > I want to translate this equation to Java-wise:
>
> > tg^-1 = |value1-value2| / |value3-value4|
>
> > And I'd like the result in degrees.. how can I do this? any ideia?
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget 
> --http://kmansoft.wordpress.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to