Package org.jlab.geom.prim
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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddPoint(double x, double y, double z) Adds a point to the path with given coordinates (x,y,z).voidAdds a point to the path with same coordinates as the given point.voidclear()Clears the path so that it has no points and size() == 0.intclosestNodeIndex(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 newLine3Dfrom a line contained in this path to the given point such that the length of the constructed line is minimal.Constructs a newLine3Dfrom a line contained in this path to the given point such that the length of the constructed line is minimal.voidgenerate(double px, double py, double pz, double vx, double vy, double vz, double length, int npoints) Modifies the contents of thisPath3Dsuch 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.voidModifies the contents of thisPath3Dsuch 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.voidgenerateRandom(double px, double py, double pz, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3Dsuch 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.voidgenerateRandom(Point3D origin, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3Dsuch 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 newLine3Dfrom the point at the given index to the point with the next larger index.intReturns the number of lines contained in this path.doublelength(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.voidrotateX(double angle) Rotates this object clockwise around the x axis.voidrotateY(double angle) Rotates this object clockwise around the y axis.voidrotateZ(double angle) Rotates this object clockwise around the z axis.voidshow()InvokesSystem.out.println(this).intsize()Returns the number of points in this path.toString()voidtranslateXYZ(double dx, double dy, double dz) Translates this object linearly by the amounts specified.
- 
Constructor Details- 
Path3Dpublic Path3D()Constructs a new emptyPath3D.
- 
Path3DConstructs a newPath3Dfrom the given points.- Parameters:
- points- the points to copy into the new- Path3D
 
 
- 
- 
Method Details- 
addPointpublic 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 point
- y- y coordinate of the point
- z- z coordinate of the point
 
- 
addPointAdds a point to the path with same coordinates as the given point.- Parameters:
- point- point to be added to the path.
 
- 
sizepublic int size()Returns the number of points in this path.- Returns:
- the number of points in this path
 
- 
pointReturns 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
 
- 
clearpublic void clear()Clears the path so that it has no points and size() == 0.
- 
getNumLinespublic int getNumLines()Returns the number of lines contained in this path.- Returns:
- the number of lines
 
- 
getLineConstructs a newLine3Dfrom 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
 
- 
distanceConstructs a newLine3Dfrom 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
- 
distanceConstructs a newLine3Dfrom 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
 
- 
closestNodeIndexFinds 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
 
- 
lengthpublic 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
 
- 
generatepublic void generate(double px, double py, double pz, double vx, double vy, double vz, double length, int npoints) Modifies the contents of thisPath3Dsuch 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 origin
- py- y coordinate of the origin
- pz- z coordinate of the origin
- vx- direction vector x component
- vy- direction vector y component
- vz- direction vector z component
- length- length of the path to generate
- npoints- number of nodes in the path
 
- 
generateModifies the contents of thisPath3Dsuch 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 point
- direction- direction vector
- length- path length
- npoints- number of nodes in the path
 
- 
generateRandompublic void generateRandom(double px, double py, double pz, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3Dsuch 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 coordinate
- py- origin y coordinate
- pz- origin z coordinate
- thetaMin- minimum theta angle in radians
- thetaMax- maximum theta angle in radians
- phiMin- minimum phi angle in radians
- phiMax- maximum phi angle in radians
- length- length of the path in cm
- npoints- number of points along the path
 
- 
generateRandompublic void generateRandom(Point3D origin, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints) Modifies the contents of thisPath3Dsuch 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 point
- thetaMin- minimum theta angle in radians
- thetaMax- maximum theta angle in radians
- phiMin- minimum phi angle in radians
- phiMax- maximum phi angle in radians
- length- length of the path in cm
- npoints- number of points along the path
 
- 
translateXYZpublic void translateXYZ(double dx, double dy, double dz) Description copied from interface:TransformableTranslates this object linearly by the amounts specified.- Specified by:
- translateXYZin interface- Transformable
- Parameters:
- dx- amount to translate along the x axis
- dy- amount to translate along the y axis
- dz- amount to translate along the z axis
 
- 
rotateXpublic void rotateX(double angle) Description copied from interface:TransformableRotates this object clockwise around the x axis.- Specified by:
- rotateXin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
rotateYpublic void rotateY(double angle) Description copied from interface:TransformableRotates this object clockwise around the y axis.- Specified by:
- rotateYin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
rotateZpublic void rotateZ(double angle) Description copied from interface:TransformableRotates this object clockwise around the z axis.- Specified by:
- rotateZin interface- Transformable
- Parameters:
- angle- rotation angle in radians
 
- 
showpublic void show()InvokesSystem.out.println(this).
- 
toString
 
-