Class Line


  • public class Line
    extends Primitive
    A line in 3D, described by a two points.
    • Constructor Detail

      • Line

        public Line​(long cPtr,
                    boolean cMemoryOwn)
      • Line

        public Line()
        Constructor.

        Default constructor returns line segment from {0, 0, 0} to {0, 0, 1}.
      • Line

        public Line​(Q params)
        Constructor.
        Parameters:
        params - [in] must be 6 long and contain 2 points lying on the line
      • Line

        public Line​(Vector3D p1,
                    Vector3D p2)
        Constructor.

        Parameters:
        p1 - [in] point 1.
        p2 - [in] point 2.
    • Method Detail

      • getCPtr

        public static long getCPtr​(Line obj)
      • p1

        public Vector3D p1()
        Get point 1.
      • p2

        public Vector3D p2()
        Get point 2.
      • dir

        public Vector3D dir()
        Get a direction vector u = normalize(p2 - p1).
      • distance

        public double distance​(Vector3D point)
        Calculates the shortest distance from a point to the line.

        For the purposes of this calculation, the line is treated as infinitely extending
        geometric entity, without begining nor end.
      • distance

        public double distance​(Line line)
        Calculates the shortest distance to another line.

        For the purposes of this calculation, the lines are treated as infinitely extending
        geometric entity, without begining nor end.
      • closestPoint

        public Vector3D closestPoint​(Vector3D point)
        Finds a point on the line closest to specified point.

        For the purposes of this calculation, the line is treated as infinitely extending
        geometric entity, without begining nor end.
      • refit

        public double refit​(SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t data)
        Fit this line to a set of points

        Uses centroid calculation and SVD analysis to determine the parameters of the line.
        p1 is the point on the line closest to origin {0, 0, 0},
        and p2 is chosen so as (p2 - p1) is an unit vector.
        Error is the sum of point distances to the line squared.

        Parameters:
        data - [in] a set of points

        Returns:
        sum of the squares of point distances to the line
      • createMesh

        public TriMeshPtr createMesh​(int resolution)
        Description copied from class: Primitive
        make a trimesh from this primitive. Use granularity to
        specify minimum number of line segments a half circle is split into
        Overrides:
        createMesh in class Primitive
        Parameters:
        resolution - [in]
      • getParameters

        public Q getParameters()
        Description copied from class: Primitive
        get the parameters that define this primitive
        Overrides:
        getParameters in class Primitive
      • setParameters

        public void setParameters​(Q q)
        Description copied from class: Primitive
        set the parameters that define this primitive
        Overrides:
        setParameters in class Primitive
      • makeGrid

        public static VectorLine makeGrid​(int dim_x,
                                          int dim_y,
                                          double size_x,
                                          double size_y,
                                          Vector3D xdir,
                                          Vector3D ydir)
        Create set of lines making a grid.
      • makeGrid

        public static VectorLine makeGrid​(int dim_x,
                                          int dim_y,
                                          double size_x,
                                          double size_y,
                                          Vector3D xdir)
        Create set of lines making a grid.
      • makeGrid

        public static VectorLine makeGrid​(int dim_x,
                                          int dim_y,
                                          double size_x,
                                          double size_y)
        Create set of lines making a grid.
      • makeGrid

        public static VectorLine makeGrid​(int dim_x,
                                          int dim_y,
                                          double size_x)
        Create set of lines making a grid.
      • makeGrid

        public static VectorLine makeGrid​(int dim_x,
                                          int dim_y)
        Create set of lines making a grid.
      • makeMetric

        public static MetricLinePtr makeMetric​(double angToDistWeight)
        create a metric that can be used to compare the difference between
        two lines. The distance between two lines is computed as follows:

        val = 0.5*angle(l1.dir, l2.dir)*angToDistWeight + 0.5*l1.distance(l2)
        Returns:
        distance metric
      • makeMetric

        public static MetricLinePtr makeMetric()
        create a metric that can be used to compare the difference between
        two lines. The distance between two lines is computed as follows:

        val = 0.5*angle(l1.dir, l2.dir)*angToDistWeight + 0.5*l1.distance(l2)
        Returns:
        distance metric
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object