Top Description Fields Constructors Methods
org.apache.commons.math3.geometry.euclidean.threed

public Class Line

extends Object
implements Embedding<Euclidean3D, Euclidean1D>
Class Inheritance
All Implemented Interfaces
org.apache.commons.math3.geometry.partitioning.Embedding
Imports
org.apache.commons.math3.exception.MathIllegalArgumentException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.geometry.Point, .Vector, org.apache.commons.math3.geometry.euclidean.oned.Euclidean1D, .IntervalsSet, .Vector1D, org.apache.commons.math3.geometry.partitioning.Embedding, org.apache.commons.math3.util.FastMath, .Precision

The class represent lines in a three dimensional space.

Each oriented line is intrinsically associated with an abscissa which is a coordinate on the line. The point at abscissa 0 is the orthogonal projection of the origin on the line, another equivalent way to express this is to say that it is the point of the line which is closest to the origin. Abscissa increases in the line direction.

Since
3.0

Field Summary

Modifier and TypeField and Description
private static final double
DEFAULT_TOLERANCE

Default value for tolerance.

private Vector3D
direction

Line direction.

private final double
tolerance

Tolerance below which points are considered identical.

private Vector3D
zero

Line point closest to the origin.

Constructor Summary

AccessConstructor and Description
public
Line(final Vector3D
first point belonging to the line (this can be any point)
p1
,
final Vector3D
second point belonging to the line (this can be any point, different from p1)
p2
,
final double
tolerance below which points are considered identical
tolerance
)

Build a line from two points.

public
Line(final Line
line to copy
line
)

Copy constructor.

public
Line(final Vector3D
first point belonging to the line (this can be any point)
p1
,
final Vector3D
second point belonging to the line (this can be any point, different from p1)
p2
)
Deprecated as of 3.3, replaced with Line(Vector3D, Vector3D, double)

Build a line from two points.

Method Summary

Modifier and TypeMethod and Description
public Vector3D

Returns:

point of the instance closest to another line
closestPoint
(final Line
line to check against the instance
line
)

Compute the point of the instance closest to another line.

public boolean

Returns:

true if p belongs to the line
contains
(final Vector3D
point to check
p
)

Check if the instance contains a point.

public double

Returns:

distance between the instance and the point
distance
(final Vector3D
to check
p
)

Compute the distance between the instance and a point.

public double

Returns:

shortest distance between the instance and the line
distance
(final Line
line to check against the instance
line
)

Compute the shortest distance between the instance and another line.

public double

Returns:

abscissa of the point
getAbscissa
(final Vector3D
point to check
point
)

Get the abscissa of a point with respect to the line.

public Vector3D

Returns:

normalized direction vector
getDirection
()

Get the normalized direction vector.

public Vector3D

Returns:

line point closest to the origin
getOrigin
()

Get the line point closest to the origin.

public double

Returns:

tolerance below which points are considered identical
getTolerance
()

Get the tolerance below which points are considered identical.

public Vector3D

Returns:

intersection point of the instance and the other line or null if there are no intersection points
intersection
(final Line
other line
line
)

Get the intersection point of the instance and another line.

public boolean

Returns:

true if the lines are similar
isSimilarTo
(final Line
line to which instance should be compared
line
)

Check if the instance is similar to another line.

public Vector3D

Returns:

one point belonging to the line, at specified abscissa
pointAt
(final double
desired abscissa for the point
abscissa
)

Get one point from the line.

public void
reset(final Vector3D
first point belonging to the line (this can be any point)
p1
,
final Vector3D
second point belonging to the line (this can be any point, different from p1)
p2
)

Reset the instance as if built from two points.

public Line

Returns:

a new instance, with reversed direction
revert
()

Get a line with reversed direction.

public Vector3D

Returns:

n-dimension point of the space corresponding to the specified sub-space point
toSpace
(Vector<Euclidean1D>
(n-1)-dimension point of the sub-space
vector
)

Transform a sub-space point into a space point.

public Vector3D
toSpace(final Point<Euclidean1D>
(n-1)-dimension point of the sub-space
point
)

Implements org.apache.commons.math3.geometry.partitioning.Embedding.toSpace.

Transform a sub-space point into a space point.

public Vector1D

Returns:

(n-1)-dimension point of the sub-space corresponding to the specified space point
toSubSpace
(Vector<Euclidean3D>
n-dimension point of the space
vector
)

Transform a space point into a sub-space point.

public Vector1D
toSubSpace(final Point<Euclidean3D>
n-dimension point of the space
point
)

Implements org.apache.commons.math3.geometry.partitioning.Embedding.toSubSpace.

Transform a space point into a sub-space point.

public SubLine

Returns:

a sub-line covering the whole line
wholeLine
()

Build a sub-line covering the whole line.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_TOLERANCEback to summary
private static final double DEFAULT_TOLERANCE

Default value for tolerance.

directionback to summary
private Vector3D direction

Line direction.

toleranceback to summary
private final double tolerance

Tolerance below which points are considered identical.

zeroback to summary
private Vector3D zero

Line point closest to the origin.

Constructor Detail

Lineback to summary
public Line(final Vector3D p1, final Vector3D p2, final double tolerance) throws MathIllegalArgumentException

Build a line from two points.

Parameters
p1:Vector3D

first point belonging to the line (this can be any point)

p2:Vector3D

second point belonging to the line (this can be any point, different from p1)

tolerance:double

tolerance below which points are considered identical

Exceptions
MathIllegalArgumentException:
if the points are equal
Since
3.3
Lineback to summary
public Line(final Line line)

Copy constructor.

The created instance is completely independent from the original instance, it is a deep copy.

Parameters
line:Line

line to copy

Lineback to summary
public Line(final Vector3D p1, final Vector3D p2) throws MathIllegalArgumentException

Deprecated

as of 3.3, replaced with Line(Vector3D, Vector3D, double)

Build a line from two points.

Parameters
p1:Vector3D

first point belonging to the line (this can be any point)

p2:Vector3D

second point belonging to the line (this can be any point, different from p1)

Annotations
@Deprecated
Exceptions
MathIllegalArgumentException:
if the points are equal

Method Detail

closestPointback to summary
public Vector3D closestPoint(final Line line)

Compute the point of the instance closest to another line.

Parameters
line:Line

line to check against the instance

Returns:Vector3D

point of the instance closest to another line

containsback to summary
public boolean contains(final Vector3D p)

Check if the instance contains a point.

Parameters
p:Vector3D

point to check

Returns:boolean

true if p belongs to the line

distanceback to summary
public double distance(final Vector3D p)

Compute the distance between the instance and a point.

Parameters
p:Vector3D

to check

Returns:double

distance between the instance and the point

distanceback to summary
public double distance(final Line line)

Compute the shortest distance between the instance and another line.

Parameters
line:Line

line to check against the instance

Returns:double

shortest distance between the instance and the line

getAbscissaback to summary
public double getAbscissa(final Vector3D point)

Get the abscissa of a point with respect to the line.

The abscissa is 0 if the projection of the point and the projection of the frame origin on the line are the same point.

Parameters
point:Vector3D

point to check

Returns:double

abscissa of the point

getDirectionback to summary
public Vector3D getDirection()

Get the normalized direction vector.

Returns:Vector3D

normalized direction vector

getOriginback to summary
public Vector3D getOrigin()

Get the line point closest to the origin.

Returns:Vector3D

line point closest to the origin

getToleranceback to summary
public double getTolerance()

Get the tolerance below which points are considered identical.

Returns:double

tolerance below which points are considered identical

Since
3.3
intersectionback to summary
public Vector3D intersection(final Line line)

Get the intersection point of the instance and another line.

Parameters
line:Line

other line

Returns:Vector3D

intersection point of the instance and the other line or null if there are no intersection points

isSimilarToback to summary
public boolean isSimilarTo(final Line line)

Check if the instance is similar to another line.

Lines are considered similar if they contain the same points. This does not mean they are equal since they can have opposite directions.

Parameters
line:Line

line to which instance should be compared

Returns:boolean

true if the lines are similar

pointAtback to summary
public Vector3D pointAt(final double abscissa)

Get one point from the line.

Parameters
abscissa:double

desired abscissa for the point

Returns:Vector3D

one point belonging to the line, at specified abscissa

resetback to summary
public void reset(final Vector3D p1, final Vector3D p2) throws MathIllegalArgumentException

Reset the instance as if built from two points.

Parameters
p1:Vector3D

first point belonging to the line (this can be any point)

p2:Vector3D

second point belonging to the line (this can be any point, different from p1)

Exceptions
MathIllegalArgumentException:
if the points are equal
revertback to summary
public Line revert()

Get a line with reversed direction.

Returns:Line

a new instance, with reversed direction

toSpaceback to summary
public Vector3D toSpace(Vector<Euclidean1D> vector)

Transform a sub-space point into a space point.

Parameters
vector:Vector<Euclidean1D>

(n-1)-dimension point of the sub-space

Returns:Vector3D

n-dimension point of the space corresponding to the specified sub-space point

toSpaceback to summary
public Vector3D toSpace(final Point<Euclidean1D> point)

Implements org.apache.commons.math3.geometry.partitioning.Embedding.toSpace.

Doc from org.apache.commons.math3.geometry.partitioning.Embedding.toSpace.

Transform a sub-space point into a space point.

Parameters
point:Point<Euclidean1D>

(n-1)-dimension point of the sub-space

Returns:Vector3D

n-dimension point of the space corresponding to the specified sub-space point

See Also
pointAt(double)
toSubSpaceback to summary
public Vector1D toSubSpace(Vector<Euclidean3D> vector)

Transform a space point into a sub-space point.

Parameters
vector:Vector<Euclidean3D>

n-dimension point of the space

Returns:Vector1D

(n-1)-dimension point of the sub-space corresponding to the specified space point

toSubSpaceback to summary
public Vector1D toSubSpace(final Point<Euclidean3D> point)

Implements org.apache.commons.math3.geometry.partitioning.Embedding.toSubSpace.

Doc from org.apache.commons.math3.geometry.partitioning.Embedding.toSubSpace.

Transform a space point into a sub-space point.

Parameters
point:Point<Euclidean3D>

n-dimension point of the space

Returns:Vector1D

(n-1)-dimension point of the sub-space corresponding to the specified space point

See Also
getAbscissa(Vector3D)
wholeLineback to summary
public SubLine wholeLine()

Build a sub-line covering the whole line.

Returns:SubLine

a sub-line covering the whole line