RobWorkProject  23.9.11-
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
Line Class Reference

A line in 3D, described by a two points. More...

#include <Line.hpp>

Inherits Primitive.

Inherited by Ray.

Public Types

typedef rw::core::Ptr< LinePtr
 Smart pointer to Line.
 
typedef double value_type
 Type of internal values.
 
- Public Types inherited from Primitive
typedef rw::core::Ptr< PrimitivePtr
 Smart pointer to this type of class.
 
- Public Types inherited from GeometryData
enum  GeometryType {
  PointCloud , LineMesh , PlainTriMesh , IdxTriMesh ,
  SpherePrim , BoxPrim , OBBPrim , AABBPrim ,
  LinePrim , PointPrim , PyramidPrim , ConePrim ,
  TrianglePrim , CylinderPrim , TubePrim , PlanePrim ,
  RayPrim , Implicit , Quadratic , UserType
}
 geometry data types
 
typedef rw::core::Ptr< GeometryDataPtr
 smart pointer type to this class
 
typedef rw::core::Ptr< const GeometryDataCPtr
 const smart pointer type to this class
 

Public Member Functions

 Line ()
 Constructor. More...
 
 Line (const rw::math::Q &params)
 Constructor. More...
 
 Line (const rw::math::Vector3D< double > &p1, const rw::math::Vector3D< double > &p2)
 Constructor. More...
 
virtual ~Line ()
 destructor
 
rw::math::Vector3D< double > & p1 ()
 Get point 1.
 
const rw::math::Vector3D< double > & p1 () const
 Get point 1.
 
rw::math::Vector3D< double > & p2 ()
 Get point 2.
 
const rw::math::Vector3D< double > & p2 () const
 Get point 2.
 
rw::math::Vector3D< double > dir () const
 Get a direction vector u = normalize(p2 - p1).
 
double distance (const rw::math::Vector3D< double > &point) const
 Calculates the shortest distance from a point to the line. More...
 
double distance (const Line &line) const
 Calculates the shortest distance to another line. More...
 
rw::math::Vector3D< double > closestPoint (const rw::math::Vector3D< double > &point) const
 Finds a point on the line closest to specified point. More...
 
double refit (const std::vector< rw::math::Vector3D< double >> &data)
 Fit this line to a set of points. More...
 
double refit (const std::vector< rw::math::Vector3D< double >>::const_iterator begin, const std::vector< rw::math::Vector3D< double >>::const_iterator end)
 
TriMesh::Ptr createMesh (int resolution) const
 make a trimesh from this primitive. Use granularity to specify minimum number of line segments a half circle is split into More...
 
virtual rw::math::Q getParameters () const
 get the parameters that define this primitive More...
 
virtual void setParameters (const rw::math::Q &q)
 set the parameters that define this primitive More...
 
GeometryType getType () const
 the type of this primitive More...
 
- Public Member Functions inherited from Primitive
virtual ~Primitive ()
 destructor
 
TriMesh::Ptr getTriMesh (bool forceCopy=true)
 gets a trimesh representation of this geometry data. More...
 
virtual bool isConvex ()
 test if this geometry data is convex More...
 
bool isInside (const rw::math::Vector3D< double > &point)
 test if a point is on the border or inside this primitive
 
- Public Member Functions inherited from GeometryData
virtual ~GeometryData ()
 Destructor.
 

Static Public Member Functions

static std::vector< LinemakeGrid (int dim_x, int dim_y, double size_x=1.0, double size_y=1.0, const rw::math::Vector3D< double > &xdir=rw::math::Vector3D< double >::x(), const rw::math::Vector3D< double > &ydir=rw::math::Vector3D< double >::y())
 Create set of lines making a grid.
 
static rw::math::Metric< Line >::Ptr makeMetric (double angToDistWeight=1.0)
 create a metric that can be used to compare the difference between two lines. The distance between two lines is computed as follows: More...
 
- Static Public Member Functions inherited from GeometryData
static std::string toString (GeometryType type)
 format GeometryType to string More...
 

Friends

std::ostream & operator<< (std::ostream &out, const Line &line)
 Streaming operator.
 

Additional Inherited Members

- Protected Member Functions inherited from Primitive
virtual bool doIsInside (const rw::math::Vector3D< double > &point)
 Check if point lies inside geometry. More...
 
 Primitive (int levels=20)
 Constructor. More...
 

Detailed Description

A line in 3D, described by a two points.

Constructor & Destructor Documentation

◆ Line() [1/3]

Line ( )

Constructor.

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

◆ Line() [2/3]

Line ( const rw::math::Q params)

Constructor.

Parameters
params[in] must be 6 long and contain 2 points lying on the line

◆ Line() [3/3]

Line ( const rw::math::Vector3D< double > &  p1,
const rw::math::Vector3D< double > &  p2 
)

Constructor.

Parameters
p1[in] point 1.
p2[in] point 2.

Member Function Documentation

◆ closestPoint()

rw::math::Vector3D<double> closestPoint ( const rw::math::Vector3D< double > &  point) const

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.

◆ createMesh()

TriMesh::Ptr createMesh ( int  resolution) const
inlinevirtual

make a trimesh from this primitive. Use granularity to specify minimum number of line segments a half circle is split into

Parameters
resolution[in]

Implements Primitive.

Reimplemented in Ray.

◆ distance() [1/2]

double distance ( const Line line) const

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.

◆ distance() [2/2]

double distance ( const rw::math::Vector3D< double > &  point) const

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.

◆ getParameters()

virtual rw::math::Q getParameters ( ) const
inlinevirtual

get the parameters that define this primitive

Implements Primitive.

Reimplemented in Ray.

◆ getType()

GeometryType getType ( ) const
inlinevirtual

the type of this primitive

Implements GeometryData.

Reimplemented in Ray.

◆ makeMetric()

static rw::math::Metric<Line>::Ptr makeMetric ( double  angToDistWeight = 1.0)
static

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

◆ refit() [1/2]

double refit ( const std::vector< rw::math::Vector3D< double >> &  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() [2/2]

double refit ( const std::vector< rw::math::Vector3D< double >>::const_iterator  begin,
const std::vector< rw::math::Vector3D< double >>::const_iterator  end 
)

This version of refit makes it possible to fit only a subset of the points in a vector.

Parameters
begin[in] iterator to first element.
end[in] iterator to last element.
Returns
sum of the squares of point distances to the line.
See also
refit(const std::vector<rw::math::Vector3D<double> >&)

◆ setParameters()

virtual void setParameters ( const rw::math::Q q)
virtual

set the parameters that define this primitive

Implements Primitive.


The documentation for this class was generated from the following file: