If you require high double
precision, besides replacing Processing’s math functions w/ corresponding Java’s Math, avoid Processing’s constants like DEG_TO_RAD as well; b/c they’re float
type, not double
:
final double DEG_TO_RAD_D = Math.PI / 180, RAD_TO_DEG_D = 180 / Math.PI;
final double phi = 43.95_13_81d, dist = 1.13d / 6_371_000, theta = 351.4d;
final double lat = Math.asin(
Math.sin(phi * DEG_TO_RAD_D) * Math.cos(dist) +
Math.cos(phi * DEG_TO_RAD_D) * Math.sin(dist) * Math.cos(theta * DEG_TO_RAD_D)
);
println(lat, lat * RAD_TO_DEG_D);
For further reading about double
type in Processing/Java, go to this thread below: