Class Path3D

java.lang.Object
org.jlab.geom.prim.Path3D
All Implemented Interfaces:
Transformable, Showable

public class Path3D extends Object implements 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 Link icon

    Constructors
    Constructor
    Description
    Constructs a new empty Path3D.
    Path3D(Point3D... points)
    Constructs a new Path3D from the given points.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    void
    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
    Clears the path so that it has no points and size() == 0.
    int
    Finds the index of the closest point in this path to the given point.
    distance(double x, double y, double z)
     
    Constructs a new Line3D from a line contained in this path to the given point such that the length of the constructed line is minimal.
    Constructs a new Line3D 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 this Path3D 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
    generate(Point3D origin, Vector3D direction, double length, int npoints)
    Modifies the contents of this Path3D 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 this Path3D 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 this Path3D 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 new Line3D 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
    Invokes System.out.println(this).
    int
    Returns the number of points in this path.
     
    void
    translateXYZ(double dx, double dy, double dz)
    Translates this object linearly by the amounts specified.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details Link icon

    • Path3D Link icon

      public Path3D()
      Constructs a new empty Path3D.
    • Path3D Link icon

      public Path3D(Point3D... points)
      Constructs a new Path3D from the given points.
      Parameters:
      points - the points to copy into the new Path3D
  • Method Details Link icon

    • addPoint Link icon

      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 point
      y - y coordinate of the point
      z - z coordinate of the point
    • addPoint Link icon

      public void addPoint(Point3D point)
      Adds a point to the path with same coordinates as the given point.
      Parameters:
      point - point to be added to the path.
    • size Link icon

      public int size()
      Returns the number of points in this path.
      Returns:
      the number of points in this path
    • point Link icon

      public Point3D point(int index)
      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 Link icon

      public void clear()
      Clears the path so that it has no points and size() == 0.
    • getNumLines Link icon

      public int getNumLines()
      Returns the number of lines contained in this path.
      Returns:
      the number of lines
    • getLine Link icon

      public Line3D getLine(int index)
      Constructs a new Line3D 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 Link icon

      public Line3D distance(Point3D point)
      Constructs a new Line3D 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 Link icon

      public Line3D distance(double x, double y, double z)
    • distance Link icon

      public Line3D distance(Line3D pl)
      Constructs a new Line3D 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 Link icon

      public int closestNodeIndex(Point3D point)
      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 Link icon

      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 Link icon

      public void generate(double px, double py, double pz, double vx, double vy, double vz, double length, int npoints)
      Modifies the contents of this Path3D 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 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
    • generate Link icon

      public void generate(Point3D origin, Vector3D direction, double length, int npoints)
      Modifies the contents of this Path3D 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 point
      direction - direction vector
      length - path length
      npoints - number of nodes in the path
    • generateRandom Link icon

      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 this Path3D 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 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
    • generateRandom Link icon

      public void generateRandom(Point3D origin, double thetaMin, double thetaMax, double phiMin, double phiMax, double length, int npoints)
      Modifies the contents of this Path3D 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 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
    • translateXYZ Link icon

      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 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
    • rotateX Link icon

      public void rotateX(double angle)
      Description copied from interface: Transformable
      Rotates this object clockwise around the x axis.
      Specified by:
      rotateX in interface Transformable
      Parameters:
      angle - rotation angle in radians
    • rotateY Link icon

      public void rotateY(double angle)
      Description copied from interface: Transformable
      Rotates this object clockwise around the y axis.
      Specified by:
      rotateY in interface Transformable
      Parameters:
      angle - rotation angle in radians
    • rotateZ Link icon

      public void rotateZ(double angle)
      Description copied from interface: Transformable
      Rotates this object clockwise around the z axis.
      Specified by:
      rotateZ in interface Transformable
      Parameters:
      angle - rotation angle in radians
    • show Link icon

      public void show()
      Invokes System.out.println(this).
      Specified by:
      show in interface Showable
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object