Re: [android-developers] Re: How to calculate the distance between two degree values? (for example: 350º to 15º = 25º / 250º to 190º = 60º)

2011-09-30 Thread Johannes Kingma
But if you mean distance in degrees it would be 'x mod 360'
Op 29 sep. 2011 17:42 schreef "JackN"  het volgende:

-- 
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

[android-developers] Re: How to calculate the distance between two degree values? (for example: 350º to 15º = 25º / 250º to 190º = 60º)

2011-09-29 Thread Studio LFP
If you already have the two numbers in degress that are between 0 and 360...

int iDiff = Math.abs( degree1 - degree2 );

If you need to find them from points or latitude/longitude, then you are 
entering into linear math and you would need to look at things like:

http://chortle.ccsu.edu/VectorLessons/vectorIndex.html

Steven
Studio LFP
http://www.studio-lfp.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

[android-developers] Re: How to calculate the distance between two degree values? (for example: 350º to 15º = 25º / 250º to 190º = 60º)

2011-09-29 Thread Ken H
I would like to reiterate what JackN said -- you don't have enough
info. But a good place to start would here: 
http://www.movable-type.co.uk/scripts/latlong.html

For those interested, a routine for the distance between two points
(on Earth) in kilometers is:

public double gps2m(double lat_a, double lng_a, double lat_b, double
lng_b) {
double R = 6371;//km
double dLat = (lat_b - lat_a) * (Math.PI / 180.0);
double dLon = (lng_b - lng_a) * (Math.PI / 180.0);
double a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat_a *
(Math.PI / 180.0))
* Math.cos(lat_b * (Math.PI / 180.0)) * Math.sin(dLon/2) *
Math.sin(dLon/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
return R * c;
}

where lat_a and lng_a are your start coordinates and lat_b and lng_b
are your stop coordinates.

Ken H

-- 
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


[android-developers] Re: How to calculate the distance between two degree values? (for example: 350º to 15º = 25º / 250º to 190º = 60º)

2011-09-29 Thread JackN
Distance is the space between two points. You don't have enough info
to calculate the distance.


On Sep 27, 9:58 am, Lew Bloch  wrote:
> On Tuesday, September 27, 2011 7:29:09 AM UTC-7, saex wrote:
>
> > there is a function or something on Java to calculate the distance
> > between two degree values? (min 0º and max 360º)
>
> > for example:
>
> > 350º to 15º = 25º
>
> > 250º to 190º = 60º
>
> Which way do you want it?  They cannot both be correct.
>
> Bearing is conventionally calculated positive-clockwise with 0° at North (or
> "face forward" for relative bearing), most maths work
> positive-counterclockwise with 0° corresponding to the positive x axis.
>
> Either way, 350° to 15° is +25° or -335°, and 250° to 190° is -60° or +300°,
> depending on how you want to play it.
>
> You can use the remainder operator or manually add or subtract 360° to make
> things fall into your desired target range.  Your basic operation is
> subtraction modulo 360.  A conventional range is [-180°, 180°).
>
> etc...
>
> "Etc." takes a single period to end the abbreviation.  The term "etc." only
> makes sense once you have established a consistent pattern, which your post
> did not.
>
> --
> Lew

-- 
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


[android-developers] Re: How to calculate the distance between two degree values? (for example: 350º to 15º = 25º / 250º to 190º = 60º)

2011-09-27 Thread Lew Bloch


On Tuesday, September 27, 2011 7:29:09 AM UTC-7, saex wrote:
>
> there is a function or something on Java to calculate the distance 
> between two degree values? (min 0º and max 360º) 
>
> for example: 
>
> 350º to 15º = 25º 
>
> 250º to 190º = 60º 
>
>
Which way do you want it?  They cannot both be correct.

Bearing is conventionally calculated positive-clockwise with 0° at North (or 
"face forward" for relative bearing), most maths work 
positive-counterclockwise with 0° corresponding to the positive x axis.
 
Either way, 350° to 15° is +25° or -335°, and 250° to 190° is -60° or +300°, 
depending on how you want to play it.

You can use the remainder operator or manually add or subtract 360° to make 
things fall into your desired target range.  Your basic operation is 
subtraction modulo 360.  A conventional range is [-180°, 180°).

etc... 
>
>
"Etc." takes a single period to end the abbreviation.  The term "etc." only 
makes sense once you have established a consistent pattern, which your post 
did not.

-- 
Lew

-- 
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

[android-developers] Re: How to calculate the distance between two degree values? (for example: 350º to 15º = 25º / 250º to 190º = 60º)

2011-09-27 Thread Skip Morrow
This is not an android question, nor is it even a java question. But I can 
try to help anyway. You would probably get more help in a general purpose 
programming forum such as codeguru. Anyway, you didn't give enough 
information. Do you always want to go clockwise or counter-clockwise from 
the start degree to the finish degree. Or do you want the shortest path, no 
matter what direction?

-- 
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