Package org.robwork.sdurw_geometry
Class Line
- java.lang.Object
-
- org.robwork.sdurw_geometry.GeometryData
-
- org.robwork.sdurw_geometry.Primitive
-
- org.robwork.sdurw_geometry.Line
-
public class Line extends Primitive
A line in 3D, described by a two points.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.robwork.sdurw_geometry.GeometryData
GeometryData.GeometryType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.TriMeshPtr
createMesh(int resolution)
make a trimesh from this primitive.void
delete()
Vector3D
dir()
Get a direction vector u = normalize(p2 - p1).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.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.static long
getCPtr(Line obj)
Q
getParameters()
get the parameters that define this primitiveGeometryData.GeometryType
getType()
the type of this primitivestatic VectorLine
makeGrid(int dim_x, int dim_y)
Create set of lines making a grid.static VectorLine
makeGrid(int dim_x, int dim_y, double size_x)
Create set of lines making a grid.static VectorLine
makeGrid(int dim_x, int dim_y, double size_x, double size_y)
Create set of lines making a grid.static VectorLine
makeGrid(int dim_x, int dim_y, double size_x, double size_y, Vector3D xdir)
Create set of lines making a grid.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.static MetricLinePtr
makeMetric()
create a metric that can be used to compare the difference between
two lines.static MetricLinePtr
makeMetric(double angToDistWeight)
create a metric that can be used to compare the difference between
two lines.Vector3D
p1()
Get point 1.Vector3D
p2()
Get point 2.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.
double
refit(SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t__const_iterator begin, SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t__const_iterator end)
void
setParameters(Q q)
set the parameters that define this primitivejava.lang.String
toString()
-
Methods inherited from class org.robwork.sdurw_geometry.Primitive
getCPtr, getTriMesh, getTriMesh, isConvex, isInside
-
Methods inherited from class org.robwork.sdurw_geometry.GeometryData
getCPtr, toString
-
-
-
-
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
-
-
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
-
refit
public double refit(SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t__const_iterator begin, SWIGTYPE_p_std__vectorT_rw__math__Vector3DT_double_t_t__const_iterator end)
-
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 classPrimitive
- Parameters:
resolution
- [in]
-
getParameters
public Q getParameters()
Description copied from class:Primitive
get the parameters that define this primitive- Overrides:
getParameters
in classPrimitive
-
setParameters
public void setParameters(Q q)
Description copied from class:Primitive
set the parameters that define this primitive- Overrides:
setParameters
in classPrimitive
-
getType
public GeometryData.GeometryType getType()
Description copied from class:GeometryData
the type of this primitive- Overrides:
getType
in classGeometryData
-
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 classjava.lang.Object
-
-