Class Ray

  • All Implemented Interfaces:
    Shapeable, java.io.Serializable, java.lang.Comparable
    Direct Known Subclasses:
    Line

    public class Ray
    extends org.locationtech.jts.geom.LineSegment
    implements Shapeable

    The Ray class is a line segment with one side being infinitely long.


    It has an internal LineSegment representation with one Coordinate being the start of the ray and the second Coordinate being a point one length-unit away from the start in the direction of the ray.

    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class org.locationtech.jts.geom.LineSegment

        p0, p1
    • Constructor Summary

      Constructors 
      Constructor Description
      Ray​(org.locationtech.jts.geom.Coordinate start, org.locationtech.jts.geom.Coordinate target)
      Ray constructor from two coordinates.
      Ray​(org.locationtech.jts.geom.Coordinate start, org.locationtech.jts.math.Vector2D direction)
      Ray constructor from a start coordinate and a direction vector.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.locationtech.jts.math.Vector2D getDirection()
      Get the ray's direction vector.
      double getLength()
      Get the rays length, which is positive infinite by definition.
      boolean inLine​(org.locationtech.jts.geom.Coordinate coordinate)
      Checks if a coordinate lays in the infinite line.
      boolean inRay​(org.locationtech.jts.geom.Coordinate coordinate)
      Checks, if a given Coordinate lays in the ray.
      boolean inSegment​(org.locationtech.jts.geom.Coordinate coordinate)
      Checks, if a given Coordinate lays in the segment.
      org.locationtech.jts.geom.Coordinate intersection​(Line line)
      Intersect ray with Line
      org.locationtech.jts.geom.Coordinate intersection​(Ray ray)
      Intersect ray with Ray
      org.locationtech.jts.geom.Coordinate intersection​(org.locationtech.jts.geom.LineSegment line)
      Intersect ray with LineSegment
      boolean intersects​(org.locationtech.jts.geom.LineSegment line)  
      java.awt.Shape toShape​(AdvancedShapeWriter shapeWriter)
      Convert the ray to a line shape, if it lays inside of the visual boundary.
      • Methods inherited from class org.locationtech.jts.geom.LineSegment

        angle, closestPoint, closestPoints, compareTo, distance, distance, distancePerpendicular, equals, equalsTopo, getCoordinate, hashCode, isHorizontal, isVertical, lineIntersection, maxX, maxY, midPoint, midPoint, minX, minY, normalize, orientationIndex, orientationIndex, pointAlong, pointAlongOffset, project, project, projectionFactor, reverse, segmentFraction, setCoordinates, setCoordinates, toGeometry, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • Ray

        public Ray​(org.locationtech.jts.geom.Coordinate start,
                   org.locationtech.jts.geom.Coordinate target)
        Ray constructor from two coordinates.
        Parameters:
        start - ray starting coordinate
        target - ray direction coordinate
      • Ray

        public Ray​(org.locationtech.jts.geom.Coordinate start,
                   org.locationtech.jts.math.Vector2D direction)
        Ray constructor from a start coordinate and a direction vector.
        Parameters:
        start - ray starting coordinate
        direction - ray direction vector
    • Method Detail

      • intersection

        public org.locationtech.jts.geom.Coordinate intersection​(org.locationtech.jts.geom.LineSegment line)
        Intersect ray with LineSegment
        Overrides:
        intersection in class org.locationtech.jts.geom.LineSegment
        Parameters:
        line - segment to intersect ray with
        Returns:
        intersection between segment and ray, if there is none: null
      • intersection

        public org.locationtech.jts.geom.Coordinate intersection​(Ray ray)
        Intersect ray with Ray
        Parameters:
        ray - ray to intersect ray with
        Returns:
        intersection between two ray, if there is none: null
      • intersection

        public org.locationtech.jts.geom.Coordinate intersection​(Line line)
        Intersect ray with Line
        Parameters:
        line - infinite line to intersect ray with
        Returns:
        intersection between ray and infinite line, if there is none: null
      • intersects

        public boolean intersects​(org.locationtech.jts.geom.LineSegment line)
      • getLength

        public double getLength()
        Get the rays length, which is positive infinite by definition.
        Overrides:
        getLength in class org.locationtech.jts.geom.LineSegment
        Returns:
        the rays length = positive infinite
      • toShape

        public java.awt.Shape toShape​(AdvancedShapeWriter shapeWriter)
        Convert the ray to a line shape, if it lays inside of the visual boundary.
        Specified by:
        toShape in interface Shapeable
        Parameters:
        shapeWriter - writer for shapes, holds the visual boundary
        Returns:
        line shape, or if not visible, null
      • inLine

        public boolean inLine​(org.locationtech.jts.geom.Coordinate coordinate)
        Checks if a coordinate lays in the infinite line.
        Parameters:
        coordinate - coordinate to check
        Returns:
        whether or not the coordinate lays in the infinite line
      • inRay

        public boolean inRay​(org.locationtech.jts.geom.Coordinate coordinate)
        Checks, if a given Coordinate lays in the ray.
        Parameters:
        coordinate - coordinate to check
        Returns:
        whether point lays in ray or not
      • inSegment

        public boolean inSegment​(org.locationtech.jts.geom.Coordinate coordinate)
        Checks, if a given Coordinate lays in the segment.
        Parameters:
        coordinate - coordinate to check
        Returns:
        whether point lays in segment or not
      • getDirection

        public org.locationtech.jts.math.Vector2D getDirection()
        Get the ray's direction vector.
        Returns:
        direction vector of ray