RobWorkProject
24.12.4-
|
A line in 3D, described by a two points. More...
#include <Line.hpp>
Inherits Primitive.
Inherited by Ray.
Public Types | |
typedef rw::core::Ptr< Line > | Ptr |
Smart pointer to Line. | |
typedef double | value_type |
Type of internal values. | |
Public Types inherited from Primitive | |
typedef rw::core::Ptr< Primitive > | Ptr |
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< GeometryData > | Ptr |
smart pointer type to this class | |
typedef rw::core::Ptr< const GeometryData > | CPtr |
const smart pointer type to this class | |
Public Member Functions | |
Line () | |
Constructor. More... | |
Line (const rw::math::Q ¶ms) | |
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< Line > | makeGrid (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... | |
A line in 3D, described by a two points.
Line | ( | ) |
Constructor.
Default constructor returns line segment from {0, 0, 0} to {0, 0, 1}.
Line | ( | const rw::math::Q & | params | ) |
Constructor.
params | [in] must be 6 long and contain 2 points lying on the line |
Line | ( | const rw::math::Vector3D< double > & | p1, |
const rw::math::Vector3D< double > & | p2 | ||
) |
Constructor.
p1 | [in] point 1. |
p2 | [in] point 2. |
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.
|
inlinevirtual |
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.
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.
|
inlinevirtual |
|
inlinevirtual |
|
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)
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.
data | [in] a set of points |
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.
begin | [in] iterator to first element. |
end | [in] iterator to last element. |
|
virtual |
set the parameters that define this primitive
Implements Primitive.