Package com.treasure.hunt.jts.geom
Class Ray
- java.lang.Object
-
- org.locationtech.jts.geom.LineSegment
-
- com.treasure.hunt.jts.geom.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
LineSegmentrepresentation with oneCoordinatebeing the start of the ray and the secondCoordinatebeing a point one length-unit away from the start in the direction of the ray.- See Also:
- Serialized Form
-
-
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.Vector2DgetDirection()Get the ray's direction vector.doublegetLength()Get the rays length, which is positive infinite by definition.booleaninLine(org.locationtech.jts.geom.Coordinate coordinate)Checks if a coordinate lays in the infinite line.booleaninRay(org.locationtech.jts.geom.Coordinate coordinate)Checks, if a givenCoordinatelays in the ray.booleaninSegment(org.locationtech.jts.geom.Coordinate coordinate)Checks, if a givenCoordinatelays in the segment.org.locationtech.jts.geom.Coordinateintersection(Line line)Intersect ray withLineorg.locationtech.jts.geom.Coordinateintersection(Ray ray)Intersect ray withRayorg.locationtech.jts.geom.Coordinateintersection(org.locationtech.jts.geom.LineSegment line)Intersect ray withLineSegmentbooleanintersects(org.locationtech.jts.geom.LineSegment line)java.awt.ShapetoShape(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
-
-
-
-
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 coordinatetarget- 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 coordinatedirection- ray direction vector
-
-
Method Detail
-
intersection
public org.locationtech.jts.geom.Coordinate intersection(org.locationtech.jts.geom.LineSegment line)
Intersect ray withLineSegment- Overrides:
intersectionin classorg.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 withRay- 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 withLine- 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:
getLengthin classorg.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.
-
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 givenCoordinatelays 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 givenCoordinatelays 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
-
-