Class StraightLine2D

java.lang.Object
inra.ijpb.geometry.StraightLine2D

public class StraightLine2D
extends java.lang.Object
A straight line in the plane. Defined by an origin and a direction.
Author:
dlegland
  • Constructor Summary

    Constructors
    Constructor Description
    StraightLine2D​(java.awt.geom.Point2D origin, Vector2D direction)
    Creates a new straight line from an origin and a direction vector.
    StraightLine2D​(java.awt.geom.Point2D source, java.awt.geom.Point2D target)
    Creates a new straight line from two points belonging to the line
  • Method Summary

    Modifier and Type Method Description
    double distance​(java.awt.geom.Point2D point)
    Computes the distance between this line and a query point.
    Vector2D getDirection()  
    java.awt.geom.Point2D getOrigin()  

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StraightLine2D

      public StraightLine2D​(java.awt.geom.Point2D origin, Vector2D direction)
      Creates a new straight line from an origin and a direction vector.
      Parameters:
      origin - the origin of the line
      direction - the direction vector of the line
    • StraightLine2D

      public StraightLine2D​(java.awt.geom.Point2D source, java.awt.geom.Point2D target)
      Creates a new straight line from two points belonging to the line
      Parameters:
      source - the first point (used as origin)
      target - the second point (used to compute the direction vector)
  • Method Details

    • getOrigin

      public java.awt.geom.Point2D getOrigin()
      Returns:
      the origin of this line
    • getDirection

      public Vector2D getDirection()
      Returns:
      the direction vector of this line
    • distance

      public double distance​(java.awt.geom.Point2D point)
      Computes the distance between this line and a query point.
      Parameters:
      point - the query point
      Returns:
      the distance between the point and the line