Class Line
- All Implemented Interfaces:
Embedding<Euclidean2D,,Vector2D, Euclidean1D, Vector1D> Hyperplane<Euclidean2D,Vector2D, Line, SubLine>
An oriented line can be defined either by prolongating a line segment between two points past these points, or by one point and an angular direction (in trigonometric orientation).
Since it is oriented the two half planes at its two sides are unambiguously identified as a left half plane and a right half plane. This can be used to identify the interior and the exterior in a simple way by local properties only when part of a line is used to define part of a polygon boundary.
A line can also be used to completely define a reference frame in the plane. It is sufficient to select one specific point in the line (the orthogonal projection of the original reference frame on the line) and to use the unit vector in the line direction and the orthogonal vector oriented from left half plane to right half plane. We define two coordinates by the process, the abscissa along the line, and the offset across the line. All points of the plane are uniquely identified by these two coordinates. The line is the set of points at zero offset, the left half plane is the set of points with negative offsets and the right half plane is the set of points with positive offsets.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet an arbitrary point in the hyperplane.booleanCheck if the line contains a point.copySelf()Copy the instance.doubleCompute the distance between the instance and a point.Build a sub-hyperplane covering nothing.doublegetAngle()Get the angle of the line.doubleGet the offset (oriented distance) of a parallel line.doubleGet the offset (oriented distance) of a point.doubleGet the offset of the origin.getPointAt(Vector1D abscissa, double offset) Get one point from the plane.Get the reverse of the instance.doubleGet the tolerance below which points are considered to belong to the hyperplane.static Transform<Euclidean2D, Vector2D, Line, SubLine, Euclidean1D, Vector1D, OrientedPoint, SubOrientedPoint> getTransform(double cXX, double cYX, double cXY, double cYY, double cX1, double cY1) Get aTransformembedding an affine transform.intersection(Line other) Get the intersection point of the instance and another line.booleanisParallelTo(Line line) Check the instance is parallel to another line.moveToOffset(Vector2D point, double offset) Move point up to specified offset.Project a point to the hyperplane.voidReset the instance as if built from a line and an angle.voidReset the instance as if built from two points.voidRevert the instance.booleansameOrientationAs(Line other) Check if the instance has the same orientation as another hyperplane.voidsetAngle(double angle) Set the angle of the line.voidsetOriginOffset(double offset) Set the offset of the origin.Transform a sub-space point into a space point.toSubSpace(Vector2D point) Transform a space point into a sub-space point.voidTranslate the line to force it passing by a point.Build a sub-hyperplane covering the whole hyperplane.Build a region covering the whole space.
-
Constructor Details
-
Line
Build a line from two points.The line is oriented from p1 to p2
- Parameters:
p1- first pointp2- second pointtolerance- tolerance below which points are considered identical
-
Line
Build a line from a point and an angle.- Parameters:
p- point belonging to the lineangle- angle of the line with respect to abscissa axistolerance- tolerance below which points are considered identical
-
Line
Copy constructor.The created instance is completely independent of the original instance, it is a deep copy.
- Parameters:
line- line to copy
-
-
Method Details
-
copySelf
Copy the instance.The instance created is completely independent of the original one. A deep copy is used, none of the underlying objects are shared (except for immutable objects).
- Specified by:
copySelfin interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Returns:
- a new hyperplane, copy of the instance
-
reset
Reset the instance as if built from two points.The line is oriented from p1 to p2
- Parameters:
p1- first pointp2- second point
-
reset
Reset the instance as if built from a line and an angle.- Parameters:
p- point belonging to the linealpha- angle of the line with respect to abscissa axis
-
revertSelf
public void revertSelf()Revert the instance. -
getReverse
Get the reverse of the instance.Get a line with reversed orientation with respect to the instance.
As long as neither the instance nor its reverse are modified (i.e. as long as none of the
reset(Vector2D, Vector2D),reset(Vector2D, double),revertSelf(),setAngle(double)orsetOriginOffset(double)methods are called), then the line and its reverse remain linked together so thatline.getReverse().getReverse() == line. When one of the line is modified, the link is deleted as both instance becomes independent.- Returns:
- a new line, with orientation opposite to the instance orientation
-
toSubSpace
Transform a space point into a sub-space point.- Specified by:
toSubSpacein interfaceEmbedding<Euclidean2D,Vector2D, Euclidean1D, Vector1D> - Parameters:
point- n-dimension point of the space- Returns:
- (n-1)-dimension point of the sub-space corresponding to the specified space point
- See Also:
-
toSpace
Transform a sub-space point into a space point.- Specified by:
toSpacein interfaceEmbedding<Euclidean2D,Vector2D, Euclidean1D, Vector1D> - Parameters:
point- (n-1)-dimension point of the sub-space- Returns:
- n-dimension point of the space corresponding to the specified sub-space point
- See Also:
-
intersection
Get the intersection point of the instance and another line.- Parameters:
other- other line- Returns:
- intersection point of the instance and the other line or null if there are no intersection points
-
project
Project a point to the hyperplane.- Specified by:
projectin interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Parameters:
point- point to project- Returns:
- projected point
-
getTolerance
public double getTolerance()Get the tolerance below which points are considered to belong to the hyperplane.- Specified by:
getTolerancein interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Returns:
- tolerance below which points are considered to belong to the hyperplane
-
wholeHyperplane
Build a sub-hyperplane covering the whole hyperplane.- Specified by:
wholeHyperplanein interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Returns:
- a sub-hyperplane covering the whole hyperplane
-
emptyHyperplane
Build a sub-hyperplane covering nothing.- Specified by:
emptyHyperplanein interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Returns:
- a sub-hyperplane covering nothing
-
wholeSpace
Build a region covering the whole space.- Specified by:
wholeSpacein interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Returns:
- a region containing the instance (really a
PolygonsSetinstance)
-
getOffset
Get the offset (oriented distance) of a parallel line.This method should be called only for parallel lines otherwise the result is not meaningful.
The offset is 0 if both lines are the same, it is positive if the line is on the right side of the instance and negative if it is on the left side, according to its natural orientation.
- Parameters:
line- line to check- Returns:
- offset of the line
-
getOffset
Get the offset (oriented distance) of a point.The offset is 0 if the point is on the underlying hyperplane, it is positive if the point is on one particular side of the hyperplane, and it is negative if the point is on the other side, according to the hyperplane natural orientation.
- Specified by:
getOffsetin interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Parameters:
point- point to check- Returns:
- offset of the point
-
moveToOffset
Move point up to specified offset.Motion is orthogonal to the hyperplane
- Specified by:
moveToOffsetin interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Parameters:
point- point to moveoffset- desired offset- Returns:
- moved point at desired offset
-
arbitraryPoint
Get an arbitrary point in the hyperplane.- Specified by:
arbitraryPointin interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Returns:
- arbirary point in the hyperplane
-
sameOrientationAs
Check if the instance has the same orientation as another hyperplane.This method is expected to be called on parallel hyperplanes. The method should not re-check for parallelism, only for orientation, typically by testing something like the sign of the dot-products of normals.
- Specified by:
sameOrientationAsin interfaceHyperplane<Euclidean2D,Vector2D, Line, SubLine> - Parameters:
other- other hyperplane to check against the instance- Returns:
- true if the instance and the other hyperplane have the same orientation
-
getPointAt
Get one point from the plane.- Parameters:
abscissa- desired abscissa for the pointoffset- desired offset for the point- Returns:
- one point in the plane, with given abscissa and offset relative to the line
-
contains
Check if the line contains a point.- Parameters:
p- point to check- Returns:
- true if p belongs to the line
-
distance
Compute the distance between the instance and a point.This is a shortcut for invoking FastMath.abs(getOffset(p)), and provides consistency with what is in the org.hipparchus.geometry.euclidean.threed.Line class.
- Parameters:
p- to check- Returns:
- distance between the instance and the point
-
isParallelTo
Check the instance is parallel to another line.- Parameters:
line- other line to check- Returns:
- true if the instance is parallel to the other line (they can have either the same or opposite orientations)
-
translateToPoint
Translate the line to force it passing by a point.- Parameters:
p- point by which the line should pass
-
getAngle
public double getAngle()Get the angle of the line.- Returns:
- the angle of the line with respect to the abscissa axis
-
setAngle
public void setAngle(double angle) Set the angle of the line.- Parameters:
angle- new angle of the line with respect to the abscissa axis
-
getOriginOffset
public double getOriginOffset()Get the offset of the origin.- Returns:
- the offset of the origin
-
setOriginOffset
public void setOriginOffset(double offset) Set the offset of the origin.- Parameters:
offset- offset of the origin
-
getTransform
public static Transform<Euclidean2D,Vector2D, getTransformLine, SubLine, Euclidean1D, Vector1D, OrientedPoint, SubOrientedPoint> (double cXX, double cYX, double cXY, double cYY, double cX1, double cY1) throws MathIllegalArgumentException Get aTransformembedding an affine transform.- Parameters:
cXX- transform factor between input abscissa and output abscissacYX- transform factor between input abscissa and output ordinatecXY- transform factor between input ordinate and output abscissacYY- transform factor between input ordinate and output ordinatecX1- transform addendum for output abscissacY1- transform addendum for output ordinate- Returns:
- a new transform that can be applied to either
Vector2D,LineorSubHyperplaneinstances - Throws:
MathIllegalArgumentException- if the transform is non invertible
-