RobWorkProject  23.9.11-
Public Types | Public Member Functions | Related Functions | List of all members
Line2D Class Reference

Describes a line segment in 2D. More...

#include <Line2D.hpp>

Public Types

enum  IntersectResult { PARALLEL , COINCIDENT , INTERSECTS }
 definition of intersection result values for the intersection test between two lines. More...
 

Public Member Functions

 Line2D ()
 Constructor.
 
 Line2D (const rw::math::Vector2D<> &p1, const rw::math::Vector2D<> &p2)
 Creates a line between that intersect the two points p1 and p2. More...
 
 Line2D (double x1, double y1, double x2, double y2)
 Creates a line between that intersect the two points (x1,y1) and (x2,y2). More...
 
virtual ~Line2D ()
 Destructor.
 
IntersectResult getIntersect (const Line2D &line, rw::math::Vector2D<> &res) const
 calculates the intersection between two lines. A intersection point is only saved in res if the two lines are not parallel or coincident. The intersection test does not take the segments into acount. More...
 
double calcAngle (const Line2D &line) const
 calculates the angle between this line and line More...
 
double calcAngle () const
 calculates the angle between the projection of this line onto yz-plane and the x-axis More...
 
double calcDist (const rw::math::Vector2D<> &v) const
 calculates the shortest distance between point v and the infinite line. More...
 
double getLength () const
 gets the length of thi line segment. More...
 
rw::math::Vector2Dp1 ()
 first point on the line
 
const rw::math::Vector2Dp1 () const
 first point on the line More...
 
rw::math::Vector2Dp2 ()
 second point on the line
 
const rw::math::Vector2Dp2 () const
 second point on the line More...
 
rw::math::Vector2D calcUnitNormal () const
 calculates the unit normal of the line
 

Related Functions

(Note that these are not member functions.)

template<>
void write (const rw::math::Line2D &sobject, rw::common::OutputArchive &oarchive, const std::string &id)
 
template<>
void read (rw::math::Line2D &sobject, rw::common::InputArchive &iarchive, const std::string &id)
 

Detailed Description

Describes a line segment in 2D.

Member Enumeration Documentation

◆ IntersectResult

definition of intersection result values for the intersection test between two lines.

Enumerator
PARALLEL 

Two lines are parallel.

COINCIDENT 

Two lines are parallel and coinciding.

INTERSECTS 

Two lines intersects at one point.

Constructor & Destructor Documentation

◆ Line2D() [1/2]

Line2D ( const rw::math::Vector2D<> &  p1,
const rw::math::Vector2D<> &  p2 
)

Creates a line between that intersect the two points p1 and p2.

Parameters
p1[in] point
p2[in] point

◆ Line2D() [2/2]

Line2D ( double  x1,
double  y1,
double  x2,
double  y2 
)

Creates a line between that intersect the two points (x1,y1) and (x2,y2).

Parameters
x1[in] x coordinate of point 1
y1[in] y coordinate of point 1
x2[in] x coordinate of point 2
y2[in] y coordinate of point 2

Member Function Documentation

◆ calcAngle() [1/2]

double calcAngle ( ) const

calculates the angle between the projection of this line onto yz-plane and the x-axis

Returns
the angle

◆ calcAngle() [2/2]

double calcAngle ( const Line2D line) const

calculates the angle between this line and line

Parameters
line[in] a line
Returns
the angle from this line to line

◆ calcDist()

double calcDist ( const rw::math::Vector2D<> &  v) const

calculates the shortest distance between point v and the infinite line.

Parameters
v[in] Point to which to calculate distance

◆ getIntersect()

IntersectResult getIntersect ( const Line2D line,
rw::math::Vector2D<> &  res 
) const

calculates the intersection between two lines. A intersection point is only saved in res if the two lines are not parallel or coincident. The intersection test does not take the segments into acount.

Parameters
line[in] the line two test against
res[out] the point of intersection
Returns
the intersection type

◆ getLength()

double getLength ( ) const
inline

gets the length of thi line segment.

Returns
line segment length

◆ p1()

const rw::math::Vector2D& p1 ( ) const
inline

first point on the line

◆ p2()

const rw::math::Vector2D& p2 ( ) const
inline

second point on the line

Friends And Related Function Documentation

◆ read()

void read ( rw::math::Line2D sobject,
rw::common::InputArchive iarchive,
const std::string &  id 
)
related

Enable read-serialization of class T by overloading this method. Data is read from iarchive and filled into sobject.

Parameters
sobject[out] the object in which the data should be streamed into
iarchive[in] the InputArchive from which to read data.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

◆ write()

void write ( const rw::math::Line2D sobject,
rw::common::OutputArchive oarchive,
const std::string &  id 
)
related

Enable write-serialization of class T by overloading this method. Data is written to oarchive from the sobject.

Parameters
sobject[in] the object from which the data should be streamed.
oarchive[out] the OutputArchive in which data should be written.
id[in] The id of the serialized sobject.
Note
the id can be empty in which case the overloaded method should provide a default identifier. E.g. the Vector3D class defined "Vector3D" as its default id.

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