public static Vector2D_F64 computeTangent ( double t , EllipseRotated_F64 ellipse , Vector2D_F64 output ) { if ( output == null ) output = new Vector2D_F64 ( ) ; double ct = Math . cos ( t ) ; double st = Math . sin ( t ) ; double cphi = Math . cos ( ellipse . phi ) ; double sphi = Math . sin ( ellipse . phi ) ; // point in ellipse frame multiplied by b^2 and a^2 double x = ellipse . a * ct * ellipse . b * ellipse . b ; double y = ellipse . b * st * ellipse . a * ellipse . a ; // rotate vector normal into world frame double rx = x * cphi - y * sphi ; double ry = x * sphi + y * cphi ; // normalize and change into tangent double r = Math . sqrt ( rx * rx + ry * ry ) ; output . x = - ry / r ; output . y = rx / r ; return output ; }
Computes the tangent to the ellipse at the specified location