Calculating the angle between two lines without having to calculate the slope? (Java)

The atan2 function eases the pain of dealing with atan. It is declared as double atan2(double y, double x) and converts rectangular coordinates (x,y) to the angle theta from the polar coordinates (r,theta) So I’d rewrite your code as public static double angleBetween2Lines(Line2D line1, Line2D line2) { double angle1 = Math.atan2(line1.getY1() – line1.getY2(), line1.getX1() – … Read more

Java BigDecimal trigonometric methods

ApFloat is a library which contains arbitrary-precision approximations of trigometric functions and non-integer powers both; however, it uses its own internal representations, rather than BigDecimal and BigInteger. I haven’t used it before, so I can’t vouch for its correctness or performance characteristics, but the api seems fairly complete.