intersectRayLineSegment

Determine whether the ray with given origin <code>(originX, originY)</code> and direction <code>(dirX, dirY)</code> intersects the undirected line segment given by the two end points <code>(aX, bY)</code> and <code>(bX, bY)</code>, and return the value of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the intersection point, if any. <p> This method returns <code>-1.0</code> if the ray does not intersect the line segment.

@see #intersectRayLineSegment(Vector2d, Vector2d, Vector2d, Vector2d)

@param originX the x coordinate of the ray's origin @param originY the y coordinate of the ray's origin @param dirX the x coordinate of the ray's direction @param dirY the y coordinate of the ray's direction @param aX the x coordinate of the line segment's first end point @param aY the y coordinate of the line segment's first end point @param bX the x coordinate of the line segment's second end point @param bY the y coordinate of the line segment's second end point @return the value of the parameter <i>t</i> in the ray equation <i>p(t) = origin + t * dir</i> of the intersection point, if the ray intersects the line segment; <code>-1.0</code> otherwise

  1. double intersectRayLineSegment(double originX, double originY, double dirX, double dirY, double aX, double aY, double bX, double bY)
    public static
    double
    intersectRayLineSegment
    (
    double originX
    ,
    double originY
    ,
    double dirX
    ,
    double dirY
    ,
    double aX
    ,
    double aY
    ,
    double bX
    ,
    double bY
    )
  2. double intersectRayLineSegment(Vector2d origin, Vector2d dir, Vector2d a, Vector2d b)

Meta