Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- copy(Line3D)
- set(Point3D, Vector3D)
- set(Point3D, Point3D)
- setOrigin(Point3D)
- setEnd(Point3D)
- set(double, double, double, double, double, double)
- setOrigin(double, double, double)
- setEnd(double, double, double)
- origin()
- originDir()
- end()
- length()
- midpoint()
- lerpPoint(double)
- toVector()
- distance(Point3D)
- distanceRay(Point3D)
- distanceSegment(Point3D)
- distance(Line3D)
- distanceSegments(Line3D)
- translateXYZ(double, double, double)
- rotateX(double)
- rotateY(double)
- rotateZ(double)
- show()
- toString()
- direction()
- projection(Point3D)
- projection(Vector3D)
Class Line3D
java.lang.Object
org.jlab.geom.prim.Line3D
- All Implemented Interfaces:
Transformable
,Showable
A 3D line represented by two points, the origin point and the end point. The
line can be treated as an infinite line, a ray bounded by only the origin
point, or a line segment bounded by both the origin point and the end point.
The direction of the line can be obtained via toVector()
. Points on
the line can be obtained via lerpPoint(double)
. Distances from the a
line to a point and from one line to another line can be obtained via
distance(Point3D)
and
distance(Line3D)
.
- Author:
- gavalian
-
Constructor Summary
ConstructorsConstructorDescriptionLine3D()
Constructs a newLine3D
such that the newLine3D
's bounding points both coincide at the origin.Line3D
(double x0, double y0, double z0, double x1, double y1, double z1) Constructs a new suchLine3D
that the newLine3D
's bounding points coincide with the points specified by the given coordinates.Constructs a newLine3D
such that the newLine3D
's bounding points coincide with the given line's bounding points.Constructs a newLine3D
such that the newLine3D
's bounding points coincide with the given points.Constructs a newLine3D
such that the the given point is at the origin of the line and the vector from the origin to the end of the line is equal to the given vector. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets the bounding points of this line to coincide with the bounding points of the given line.direction vector from begin to end pointConstructs a newLine3D
from this line to the given line such that the origin point of the constructed line coincides with this line, the end point of the constructed line coincides with the given line, and the length of the constructed line is minimal.Constructs a newLine3D
from this infinite line to the given point such that the origin point of the constructed line coincides with this infinite line, the end point of the constructed line coincides with the given point, and the length of the constructed line is minimal.distanceRay
(Point3D point) Constructs a newLine3D
from this ray line to the given point such that the origin point of the constructed line coincides with this ray line, the end point of the constructed line coincides with the given point, and the length of the constructed line is minimal.distanceSegment
(Point3D point) Constructs a newLine3D
from this line segment to the given point such that the origin point of the constructed line coincides with this line segment, the end point of the constructed line coincides with the given point, and the length of the constructed line is minimal.distanceSegments
(Line3D line) Constructs a newLine3D
from this line segment to the given line segment such that the origin point of the constructed line coincides with this line segment, the end point of the constructed line segment coincides with the given line segment, and the length of the constructed line is minimal.end()
Returns the end point.double
length()
Returns the length of this line.lerpPoint
(double t) Constructs a newPoint3D
on the line by linearly interpolating from this point to the given point by the amount specified.midpoint()
Constructs a newPoint3D
at the midpoint between the two bounding points.origin()
Returns the origin point.projection of a point onto this linevoid
rotateX
(double angle) Rotates this object clockwise around the x axis.void
rotateY
(double angle) Rotates this object clockwise around the y axis.void
rotateZ
(double angle) Rotates this object clockwise around the z axis.void
set
(double x0, double y0, double z0, double x1, double y1, double z1) Sets the origin and end points using the given coordinates.void
Sets the line origin and end point to given points.void
Sets the line origin at the given point and the end point at the position of the origin point plus the given vector.void
setEnd
(double x, double y, double z) Sets the end point.void
Sets the end point.void
setOrigin
(double x, double y, double z) Sets the origin point.void
Sets the origin point.void
show()
InvokesSystem.out.println(this)
.toString()
toVector()
Returns a vector from the origin point to the end point.void
translateXYZ
(double x, double y, double z) Translates this object linearly by the amounts specified.
-
Constructor Details
-
Line3D
public Line3D()Constructs a newLine3D
such that the newLine3D
's bounding points both coincide at the origin. This line will have zero length. -
Line3D
public Line3D(double x0, double y0, double z0, double x1, double y1, double z1) Constructs a new suchLine3D
that the newLine3D
's bounding points coincide with the points specified by the given coordinates.- Parameters:
x0
- x component of the origin pointy0
- y component of the origin pointz0
- z component of the origin pointx1
- x component of the end pointy1
- y component of the end pointz1
- z component of the end point
-
Line3D
-
Line3D
-
Line3D
Constructs a newLine3D
such that the newLine3D
's bounding points coincide with the given line's bounding points.- Parameters:
line
- the line to copy
-
-
Method Details
-
copy
Sets the bounding points of this line to coincide with the bounding points of the given line.- Parameters:
line
- the line to copy
-
set
-
set
-
setOrigin
Sets the origin point.- Parameters:
point0
- the new origin point
-
setEnd
-
set
public void set(double x0, double y0, double z0, double x1, double y1, double z1) Sets the origin and end points using the given coordinates.- Parameters:
x0
- x component of the origin pointy0
- y component of the origin pointz0
- z component of the origin pointx1
- x component of the end pointy1
- y component of the end pointz1
- z component of the end point
-
setOrigin
public void setOrigin(double x, double y, double z) Sets the origin point.- Parameters:
x
- the x coordinate of the origin pointy
- the y coordinate of the origin pointz
- the z coordinate of the origin point
-
setEnd
public void setEnd(double x, double y, double z) Sets the end point.- Parameters:
x
- the x coordinate of the end pointy
- the y coordinate of the end pointz
- the z coordinate of the end point
-
origin
-
originDir
-
end
-
length
public double length()Returns the length of this line.- Returns:
- the distance from one bounding point to the other
-
midpoint
Constructs a newPoint3D
at the midpoint between the two bounding points.- Returns:
- the midpoint of this line
-
lerpPoint
Constructs a newPoint3D
on the line by linearly interpolating from this point to the given point by the amount specified. If t==0, then the returned point is equal to the origin point. If t==0.5, then the returned point half way between both points. If t==1, then the returned point is equal to the end point.- Parameters:
t
- the interpolation coefficient- Returns:
- the newly constructed point
-
toVector
Returns a vector from the origin point to the end point.- Returns:
- a vector from the origin point to the end point
-
distance
Constructs a newLine3D
from this infinite line to the given point such that the origin point of the constructed line coincides with this infinite line, the end point of the constructed line coincides with the given point, and the length of the constructed line is minimal.- Parameters:
point
- the given point- Returns:
- the line of closest approach
-
distanceRay
Constructs a newLine3D
from this ray line to the given point such that the origin point of the constructed line coincides with this ray line, the end point of the constructed line coincides with the given point, and the length of the constructed line is minimal.- Parameters:
point
- the given point- Returns:
- the line of closest approach
-
distanceSegment
Constructs a newLine3D
from this line segment to the given point such that the origin point of the constructed line coincides with this line segment, the end point of the constructed line coincides with the given point, and the length of the constructed line is minimal.- Parameters:
point
- the given point- Returns:
- the line of closest approach
-
distance
Constructs a newLine3D
from this line to the given line such that the origin point of the constructed line coincides with this line, the end point of the constructed line coincides with the given line, and the length of the constructed line is minimal.- Parameters:
line
- the given infinite line- Returns:
- the line of closest approach
-
distanceSegments
Constructs a newLine3D
from this line segment to the given line segment such that the origin point of the constructed line coincides with this line segment, the end point of the constructed line segment coincides with the given line segment, and the length of the constructed line is minimal.- Parameters:
line
- the given line segment- Returns:
- the line of closest approach
-
translateXYZ
public void translateXYZ(double x, double y, double z) Description copied from interface:Transformable
Translates this object linearly by the amounts specified.- Specified by:
translateXYZ
in interfaceTransformable
- Parameters:
x
- amount to translate along the x axisy
- amount to translate along the y axisz
- amount to translate along the z axis
-
rotateX
public void rotateX(double angle) Description copied from interface:Transformable
Rotates this object clockwise around the x axis.- Specified by:
rotateX
in interfaceTransformable
- Parameters:
angle
- rotation angle in radians
-
rotateY
public void rotateY(double angle) Description copied from interface:Transformable
Rotates this object clockwise around the y axis.- Specified by:
rotateY
in interfaceTransformable
- Parameters:
angle
- rotation angle in radians
-
rotateZ
public void rotateZ(double angle) Description copied from interface:Transformable
Rotates this object clockwise around the z axis.- Specified by:
rotateZ
in interfaceTransformable
- Parameters:
angle
- rotation angle in radians
-
show
-
toString
-
direction
direction vector from begin to end point -
projection
-
projection
-