Embedding<Euclidean2D,Euclidean1D>, Hyperplane<Euclidean2D>public class Line extends Object implements Hyperplane<Euclidean2D>, Embedding<Euclidean2D,Euclidean1D>
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 | Description |
|---|---|
Line(Cartesian2D p,
double angle,
double tolerance) |
Build a line from a point and an angle.
|
Line(Cartesian2D p1,
Cartesian2D p2,
double tolerance) |
Build a line from two points.
|
Line(Line line) |
Copy constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
contains(Cartesian2D p) |
Check if the line contains a point.
|
Line |
copySelf() |
Copy the instance.
|
double |
distance(Cartesian2D p) |
Compute the distance between the instance and a point.
|
double |
getAngle() |
Get the angle of the line.
|
double |
getOffset(Cartesian2D cartesian) |
Get the offset (oriented distance) of a point.
|
double |
getOffset(Line line) |
Get the offset (oriented distance) of a parallel line.
|
double |
getOffset(Point<Euclidean2D> point) |
Get the offset (oriented distance) of a point.
|
double |
getOffset(Vector<Euclidean2D> vector) |
Get the offset (oriented distance) of a vector.
|
double |
getOriginOffset() |
Get the offset of the origin.
|
Cartesian2D |
getPointAt(Cartesian1D abscissa,
double offset) |
Get one point from the plane.
|
Line |
getReverse() |
Get the reverse of the instance.
|
double |
getTolerance() |
Get the tolerance below which points are considered to belong to the hyperplane.
|
static Transform<Euclidean2D,Euclidean1D> |
getTransform(double cXX,
double cYX,
double cXY,
double cYY,
double cX1,
double cY1) |
Get a
Transform embedding an affine transform. |
Cartesian2D |
intersection(Line other) |
Get the intersection point of the instance and another line.
|
boolean |
isParallelTo(Line line) |
Check the instance is parallel to another line.
|
Point<Euclidean2D> |
project(Point<Euclidean2D> point) |
Project a point to the hyperplane.
|
void |
reset(Cartesian2D p,
double alpha) |
Reset the instance as if built from a line and an angle.
|
void |
reset(Cartesian2D p1,
Cartesian2D p2) |
Reset the instance as if built from two points.
|
void |
revertSelf() |
Revert the instance.
|
boolean |
sameOrientationAs(Hyperplane<Euclidean2D> other) |
Check if the instance has the same orientation as another hyperplane.
|
void |
setAngle(double angle) |
Set the angle of the line.
|
void |
setOriginOffset(double offset) |
Set the offset of the origin.
|
Cartesian2D |
toSpace(Cartesian1D cartesian) |
Transform a sub-space point into a space point.
|
Cartesian2D |
toSpace(Point<Euclidean1D> point) |
Transform a sub-space point into a space point.
|
Cartesian2D |
toSpace(Vector<Euclidean1D> vector) |
Transform a sub-space point into a space point.
|
Cartesian1D |
toSubSpace(Cartesian2D cartesian) |
Transform a space point into a sub-space point.
|
Cartesian1D |
toSubSpace(Point<Euclidean2D> point) |
Transform a space point into a sub-space point.
|
Cartesian1D |
toSubSpace(Vector<Euclidean2D> vector) |
Transform a space point into a sub-space point.
|
void |
translateToPoint(Cartesian2D p) |
Translate the line to force it passing by a point.
|
SubLine |
wholeHyperplane() |
Build a sub-hyperplane covering the whole hyperplane.
|
PolygonsSet |
wholeSpace() |
Build a region covering the whole space.
|
public Line(Cartesian2D p1, Cartesian2D p2, double tolerance)
The line is oriented from p1 to p2
p1 - first pointp2 - second pointtolerance - tolerance below which points are considered identicalpublic Line(Cartesian2D p, double angle, double tolerance)
p - point belonging to the lineangle - angle of the line with respect to abscissa axistolerance - tolerance below which points are considered identicalpublic Line(Line line)
The created instance is completely independent from the original instance, it is a deep copy.
line - line to copypublic Line copySelf()
The instance created is completely independant of the original one. A deep copy is used, none of the underlying objects are shared (except for immutable objects).
copySelf in interface Hyperplane<Euclidean2D>public void reset(Cartesian2D p1, Cartesian2D p2)
The line is oriented from p1 to p2
p1 - first pointp2 - second pointpublic void reset(Cartesian2D p, double alpha)
p - point belonging to the linealpha - angle of the line with respect to abscissa axispublic void revertSelf()
public Line getReverse()
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(Cartesian2D, Cartesian2D),
reset(Cartesian2D, double), revertSelf(),
setAngle(double) or setOriginOffset(double)
methods are called), then the line and its reverse remain linked
together so that line.getReverse().getReverse() == line.
When one of the line is modified, the link is deleted as both
instance becomes independent.
public Cartesian1D toSubSpace(Vector<Euclidean2D> vector)
vector - n-dimension point of the spacepublic Cartesian2D toSpace(Vector<Euclidean1D> vector)
vector - (n-1)-dimension point of the sub-spacepublic Cartesian1D toSubSpace(Point<Euclidean2D> point)
toSubSpace in interface Embedding<Euclidean2D,Euclidean1D>point - n-dimension point of the spaceEmbedding.toSpace(org.apache.commons.math4.geometry.Point<T>)public Cartesian2D toSpace(Point<Euclidean1D> point)
toSpace in interface Embedding<Euclidean2D,Euclidean1D>point - (n-1)-dimension point of the sub-spaceEmbedding.toSubSpace(org.apache.commons.math4.geometry.Point<S>)public Cartesian1D toSubSpace(Cartesian2D cartesian)
cartesian - n-dimension point of the spacepublic Cartesian2D toSpace(Cartesian1D cartesian)
cartesian - (n-1)-dimension point of the sub-spacepublic Cartesian2D intersection(Line other)
other - other linepublic Point<Euclidean2D> project(Point<Euclidean2D> point)
project in interface Hyperplane<Euclidean2D>point - point to projectpublic double getTolerance()
getTolerance in interface Hyperplane<Euclidean2D>public SubLine wholeHyperplane()
wholeHyperplane in interface Hyperplane<Euclidean2D>public PolygonsSet wholeSpace()
wholeSpace in interface Hyperplane<Euclidean2D>PolygonsSet instance)public double getOffset(Line 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.
line - line to checkpublic double getOffset(Vector<Euclidean2D> vector)
vector - vector to checkpublic double getOffset(Point<Euclidean2D> 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.
getOffset in interface Hyperplane<Euclidean2D>point - point to checkpublic double getOffset(Cartesian2D cartesian)
cartesian - point to checkpublic boolean sameOrientationAs(Hyperplane<Euclidean2D> other)
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.
sameOrientationAs in interface Hyperplane<Euclidean2D>other - other hyperplane to check against the instancepublic Cartesian2D getPointAt(Cartesian1D abscissa, double offset)
abscissa - desired abscissa for the pointoffset - desired offset for the pointpublic boolean contains(Cartesian2D p)
p - point to checkpublic double distance(Cartesian2D p)
This is a shortcut for invoking FastMath.abs(getOffset(p)), and provides consistency with what is in the org.apache.commons.math4.geometry.euclidean.threed.Line class.
p - to checkpublic boolean isParallelTo(Line line)
line - other line to checkpublic void translateToPoint(Cartesian2D p)
p - point by which the line should passpublic double getAngle()
public void setAngle(double angle)
angle - new angle of the line with respect to the abscissa axispublic double getOriginOffset()
public void setOriginOffset(double offset)
offset - offset of the originpublic static Transform<Euclidean2D,Euclidean1D> getTransform(double cXX, double cYX, double cXY, double cYY, double cX1, double cY1) throws MathIllegalArgumentException
Transform embedding an affine transform.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 ordinateCartesian2D, Line or SubHyperplane instancesMathIllegalArgumentException - if the transform is non invertibleCopyright © 2003–2017 The Apache Software Foundation. All rights reserved.