Package sc.fiji.snt

Class NearPoint

java.lang.Object
sc.fiji.snt.NearPoint
All Implemented Interfaces:
Comparable<NearPoint>

public class NearPoint extends Object implements Comparable<NearPoint>
This class encapsulates the relationship between an arbitrary point (nearPoint.x,nearPoint.y,nearPoint.z) close to a particular point on a particular path. The important method here is distanceToPathNearPoint() which retrieves the distance to the nearest point on the line segments on either side of the path point, rather than just the point. Also, it will return null if the point appears to be "off the end" of the Path.
Author:
Mark Longair, Tiago Ferreira
  • Field Details

    • indexInPath

      public final int indexInPath
      The index of this point within its associated path
    • near

      protected PointInImage near
    • closestIntersection

      protected sc.fiji.snt.NearPoint.IntersectionOnLine closestIntersection
  • Constructor Details

    • NearPoint

      public NearPoint(PointInImage nearPoint, Path path, int indexInPath)
    • NearPoint

      protected NearPoint(PointInImage nearPoint, Path path, int indexInPath, boolean unScaledPositions)
  • Method Details

    • getNode

      public PointInImage getNode()
    • getNodeUnscaled

      public PointInCanvas getNodeUnscaled()
    • getPath

      public Path getPath()
    • getClosestIntersectionPoint

      public PointInImage getClosestIntersectionPoint()
      Returns the point on the path's line segments closest to the queried position which, may fall strictly between two nodes. Useful when path nodes are sparser than the pick radius used to find this NearPoint in the first place (e.g. manually-placed tracing waypoints), where the closest existing node can be much farther from the query point than the path itself is. See getInsertionIndex() to materialize this position as a real node via Path.insertNode(int, PointInImage) before using it structurally (e.g. as a fork/branch point)
      Returns:
      the interpolated closest point, tagged with PointInImage.getPath() set to this NearPoint's path; or null if no valid intersection exists
    • getInsertionIndex

      public int getInsertionIndex()
      Returns the index at which a new node would need to be inserted to materialize getClosestIntersectionPoint() as a real node on the path, or -1 if that point already coincides with an existing node (i.e. getNode() can be used directly, no insertion needed). Only meaningful after distanceToPathNearPoint() has run (directly, or indirectly via getClosestIntersectionPoint())
      Returns:
      the insertion index, or -1 if no insertion is needed
    • compareTo

      public int compareTo(NearPoint other)
      Specified by:
      compareTo in interface Comparable<NearPoint>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • distanceToPathNearPoint

      public double distanceToPathNearPoint()
      Returns the distance to the path, If a corresponding point on the path was found . Returns -1 if no such point can be found
      Returns:
      the distance to the path, If a corresponding point on the path was found . Returns -1 if no such point can be found
    • distanceToLineSegment

      public static sc.fiji.snt.NearPoint.IntersectionOnLine distanceToLineSegment(double x, double y, double z, double startX, double startY, double startZ, double endX, double endY, double endZ)
    • distanceToPathPoint

      public double distanceToPathPoint()
    • distanceToPathPointSquared

      public double distanceToPathPointSquared()
    • normalSideOfPlane

      public static int normalSideOfPlane(double cx, double cy, double cz, double nx, double ny, double nz, double x, double y, double z)
    • distanceFromPointToLine

      public static sc.fiji.snt.NearPoint.IntersectionOnLine distanceFromPointToLine(double ax, double ay, double az, double vx, double vy, double vz, double x, double y, double z)
    • distanceFromSinglePointPath

      protected static sc.fiji.snt.NearPoint.IntersectionOnLine distanceFromSinglePointPath(double pathX, double pathY, double pathZ, double nearPointX, double nearPointY, double nearPointZ)