Core 1.0
|
Segments in the plane. More...
#include <segment.h>
Public Member Functions | |
Segment2 () | |
Empty. | |
Segment2 (const Vector2 &, const Vector2 &) | |
Creates a planar segment given end vertices. More... | |
Segment2 (const Segment &) | |
Creates a planar segment given a three dimensional segment. More... | |
~Segment2 () | |
Empty. | |
Vector2 | Vertex (int) const |
Return one of the end vertex of the axis. | |
Vector2 & | Vertex (int) |
Return one of the end vertex of the axis. | |
Vector2 | VertexAt (const double &) const |
Compute a point on the segment. More... | |
Vector2 | Center () const |
Compute the center of the segment. | |
Vector2 | GetAxis () const |
Returns the normalized axis vector. | |
Box2 | GetBox () const |
Compute the bounding box of the segment. | |
Vector2 | Orthogonal () const |
Compute an orthogonal vector to the segment. More... | |
void | Translate (const Vector2 &) |
Translates a segment. More... | |
void | Rotate (const Matrix2 &) |
Translates a segment. More... | |
void | Scale (const double &) |
Uniformly scales a segment. More... | |
double | Length () const |
Return axis length. | |
void | Draw (QGraphicsScene &, const QPen &=QPen()) const |
Draw a segment. More... | |
void | DrawArrow (QGraphicsScene &, const double &, const QPen &=QPen(), const QBrush &=QBrush()) const |
Draw a segment as an arrow. More... | |
double | R (const Vector2 &) const |
Compute the squared distance to the segment. More... | |
double | R (const Vector2 &, double &) const |
Compute the squared distance to the axis edge characterized by its end points. More... | |
Vector2 | Normal (const Vector2 &) const |
Compute the normal vector between a point and its projection onto the segment. More... | |
bool | Intersect (const Segment2 &) const |
Test if two segments intersect. More... | |
bool | IntersectOpen (const Segment2 &) const |
This functions tests if two segments intersect. More... | |
bool | Intersection (const Segment2 &, Vector2 &) const |
Compute the intersection between two segments. More... | |
Static Public Member Functions | |
static Vector2 | Intersect (const Vector2 &, const Vector2 &, const double, const double, const double=0.0) |
Compute the intersection between the line f(x)=y and a line such that f(a)=va and f(b)=vb, on the segment ab. More... | |
Static Public Attributes | |
static constexpr const double | epsilon = 1e-8 |
Epsilon value for intersection test. | |
Protected Attributes | |
Vector2 | b = Vector2::X |
End vertices of the segment. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Segment2 &) |
Overloaded. More... | |
bool | operator== (const Segment2 &, const Segment2 &) |
Compare two segments. More... | |
Segments in the plane.
A segment stores its end vertices.
Creates a planar segment given end vertices.
a,b | End vertices of the segment. |
|
inlineexplicit |
Creates a planar segment given a three dimensional segment.
s | Segment. |
void Segment2::Draw | ( | QGraphicsScene & | scene, |
const QPen & | pen = QPen() |
||
) | const |
Draw a segment.
scene | Graphics scene. |
pen | The pen. |
void Segment2::DrawArrow | ( | QGraphicsScene & | scene, |
const double & | s, | ||
const QPen & | pen = QPen() , |
||
const QBrush & | brush = QBrush() |
||
) | const |
Draw a segment as an arrow.
scene | Graphics scene. |
pen | The pen. |
brush | The brush. |
s | Size of the arrow head. |
bool Segment2::Intersect | ( | const Segment2 & | segment | ) | const |
Test if two segments intersect.
This function computes the intersection and test the intersection parameters. Two segments that share an end point are detected as intersecting.
segment | Other segment. |
|
static |
Compute the intersection between the line f(x)=y and a line such that f(a)=va and f(b)=vb, on the segment ab.
a,b | Points. |
va,vb | Values. |
y | Threshold. |
Compute the intersection between two segments.
e | Other segment. |
p | Intersection point. |
bool Segment2::IntersectOpen | ( | const Segment2 & | segment | ) | const |
This functions tests if two segments intersect.
The algorithm avoids the computation of the intersection. Instead, it checks whether the two points of one segment lie on the same half space defined by the line of the other segment.
Contrary to bool Intersect(const Segment2&), two segments that share one point are not detected as intersecting.
segment | Other segment. |
Compute the normal vector between a point and its projection onto the segment.
p | Point. |
Vector2 Segment2::Orthogonal | ( | ) | const |
Compute an orthogonal vector to the segment.
The returned vector is not normalized.
double Segment2::R | ( | const Vector2 & | p | ) | const |
Compute the squared distance to the segment.
p | Point. |
double Segment2::R | ( | const Vector2 & | p, |
double & | s | ||
) | const |
Compute the squared distance to the axis edge characterized by its end points.
p | Point. |
s | Linear coefficient corresponding to the projection of argument point p onto the edge. |
void Segment2::Rotate | ( | const Matrix2 & | r | ) |
Translates a segment.
r | Rotation matrix. |
void Segment2::Scale | ( | const double & | s | ) |
Uniformly scales a segment.
s | Scaling factor. |
void Segment2::Translate | ( | const Vector2 & | t | ) |
Translates a segment.
t | Translation vector. |
|
inline |
Compute a point on the segment.
t | Interpolation parameter. |
|
friend |
Overloaded.
s | Stream. |
segment | The segment. |