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