Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- addPoint(double, double, double)
- addPoint(Point3D)
- size()
- point(int)
- clear()
- getNumLines()
- getLine(int)
- distance(Point3D)
- distance(double, double, double)
- distance(Line3D)
- closestNodeIndex(Point3D)
- length(int)
- generate(double, double, double, double, double, double, double, int)
- generate(Point3D, Vector3D, double, int)
- generateRandom(double, double, double, double, double, double, double, double, int)
- generateRandom(Point3D, double, double, double, double, double, int)
- translateXYZ(double, double, double)
- rotateX(double)
- rotateY(double)
- rotateZ(double)
- show()
- toString()
Class Path3D
java.lang.Object
org.jlab.geom.prim.Path3D
- All Implemented Interfaces:
Transformable
,Showable
A polyline represented by a sequence of points. Polylines are useful for
representing the path of a particle.
Points in the polyline can added or retrieved via
addPoint(org.jlab.geom.prim.Point3D)
and point(int)
.
Alternatively, polylines can be interpreted as a sequence of lines accessible
via getLine(int)
.
For testing purposes, polylines can be randomly generated using the
generate(org.jlab.geom.prim.Point3D, org.jlab.geom.prim.Vector3D, double, int)
and
generateRandom(org.jlab.geom.prim.Point3D, double, double, double, double, double, int)
methods.
- Author:
- gavalian
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPoint
(double x, double y, double z) Adds a point to the path with given coordinates (x,y,z).void
Adds a point to the path with same coordinates as the given point.void
clear()
Clears the path so that it has no points and size() == 0.int
closestNodeIndex
(Point3D point) Finds the index of the closest point in this path to the given point.distance
(double x, double y, double z) Constructs a newLine3D
from a line contained in this path to the given point such that the length of the constructed line is minimal.Constructs a newLine3D
from a line contained in this path to the given point such that the length of the constructed line is minimal.void
generate
(double px, double py, double pz, double vx, double vy, double vz, double length, int npoints) Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at (px,py,pz), the points are collinear along the vector (vx,vy,vz), and the total length of the path is equal to the given length.void
Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at the given origin point, the points are collinear along the given direction vector, and the total length of the path is equal to the given length.void
generateRandom
(double px, double py, double pz, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at the given origin point, the points are collinear along a randomly generated vector bounded by theta min and max and phi min and max, and the total length of the path is equal to the given length.void
generateRandom
(Point3D origin, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at the given origin point, the points are collinear along a randomly generated vector bounded by theta min and max and phi min and max, and the total length of the path is equal to the given length.getLine
(int index) Constructs a newLine3D
from the point at the given index to the point with the next larger index.int
Returns the number of lines contained in this path.double
length
(int numPoints) Returns the length of the path starting at the origin and using the specified number points.point
(int index) Returns the point at the given index or null if there is no such point.void
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
show()
InvokesSystem.out.println(this)
.int
size()
Returns the number of points in this path.toString()
void
translateXYZ
(double dx, double dy, double dz) Translates this object linearly by the amounts specified.
-
Constructor Details
-
Method Details
-
addPoint
public void addPoint(double x, double y, double z) Adds a point to the path with given coordinates (x,y,z).- Parameters:
x
- x coordinate of the pointy
- y coordinate of the pointz
- z coordinate of the point
-
addPoint
Adds a point to the path with same coordinates as the given point.- Parameters:
point
- point to be added to the path.
-
size
public int size()Returns the number of points in this path.- Returns:
- the number of points in this path
-
point
Returns the point at the given index or null if there is no such point.- Parameters:
index
- the index of the point to return- Returns:
- the point at the given index or null if there is no such point
-
clear
public void clear()Clears the path so that it has no points and size() == 0. -
getNumLines
public int getNumLines()Returns the number of lines contained in this path.- Returns:
- the number of lines
-
getLine
Constructs a newLine3D
from the point at the given index to the point with the next larger index. Returns null if such a line cannot be constructed.- Parameters:
index
- the index of the point at the origin of the line- Returns:
- the line from the point at the given index to the next point or null if no such line can be constructed
-
distance
Constructs a newLine3D
from a line contained in this path to the given point such that the length of the constructed line is minimal.- Parameters:
point
- the point- Returns:
- the line with minimum distance from the path to the point, or null if this path contains fewer than 2 points
-
distance
-
distance
Constructs a newLine3D
from a line contained in this path to the given point such that the length of the constructed line is minimal.- Parameters:
pl
- the line- Returns:
- the line with minimum distance from the path to the point, or null if this path contains fewer than 2 points
-
closestNodeIndex
Finds the index of the closest point in this path to the given point.- Parameters:
point
- the point- Returns:
- the index of the closest points in this path or -1 if this path contains no points
-
length
public double length(int numPoints) Returns the length of the path starting at the origin and using the specified number points. If the given number of points exceeds the number of points in this path then the total path length is returned.- Parameters:
numPoints
- number of points to use in the calculation- Returns:
- the length
-
generate
public void generate(double px, double py, double pz, double vx, double vy, double vz, double length, int npoints) Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at (px,py,pz), the points are collinear along the vector (vx,vy,vz), and the total length of the path is equal to the given length.- Parameters:
px
- x coordinate of the originpy
- y coordinate of the originpz
- z coordinate of the originvx
- direction vector x componentvy
- direction vector y componentvz
- direction vector z componentlength
- length of the path to generatenpoints
- number of nodes in the path
-
generate
Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at the given origin point, the points are collinear along the given direction vector, and the total length of the path is equal to the given length.- Parameters:
origin
- vector of the origin pointdirection
- direction vectorlength
- path lengthnpoints
- number of nodes in the path
-
generateRandom
public void generateRandom(double px, double py, double pz, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at the given origin point, the points are collinear along a randomly generated vector bounded by theta min and max and phi min and max, and the total length of the path is equal to the given length.- Parameters:
px
- origin x coordinatepy
- origin y coordinatepz
- origin z coordinatethetaMin
- minimum theta angle in radiansthetaMax
- maximum theta angle in radiansphiMin
- minimum phi angle in radiansphiMax
- maximum phi angle in radianslength
- length of the path in cmnpoints
- number of points along the path
-
generateRandom
public void generateRandom(Point3D origin, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3D
such that the path contains the specified number of evenly spaced points, the origin of the path is at the given origin point, the points are collinear along a randomly generated vector bounded by theta min and max and phi min and max, and the total length of the path is equal to the given length.- Parameters:
origin
- the origin pointthetaMin
- minimum theta angle in radiansthetaMax
- maximum theta angle in radiansphiMin
- minimum phi angle in radiansphiMax
- maximum phi angle in radianslength
- length of the path in cmnpoints
- number of points along the path
-
translateXYZ
public void translateXYZ(double dx, double dy, double dz) Description copied from interface:Transformable
Translates this object linearly by the amounts specified.- Specified by:
translateXYZ
in interfaceTransformable
- Parameters:
dx
- amount to translate along the x axisdy
- amount to translate along the y axisdz
- 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
-