public static double acuteAngle ( LineGeneral2D_F64 a , LineGeneral2D_F64 b ) { double la = Math . sqrt ( a . A * a . A + a . B * a . B ) ; double lb = Math . sqrt ( b . A * b . A + b . B * b . B ) ; // numerical round off error can cause it to be barely greater than 1, which is outside the allowed // domain of acos() double value = ( a . A * b . A + a . B * b . B ) / ( la * lb ) ; if ( value < - 1.0 ) value = - 1.0 ; else if ( value > 1.0 ) value = 1.0 ; return Math . acos ( value ) ; }
Returns the acute angle between the slope of two lines . Lines do not need to ever intersect . Found using the dot product .