|
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. | |
| Segment2 (const Segment &) | |
| Creates a planar segment given a three dimensional segment. | |
| ~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. | |
| 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. | |
| void | Translate (const Vector2 &) |
| Translates a segment. | |
| void | Rotate (const Matrix2 &) |
| Translates a segment. | |
| void | Scale (const double &) |
| Uniformly scales a segment. | |
| Segment2 | Translated (const Vector2 &) const |
| Translates a segment. | |
| Segment2 | Extended (const double &) const |
| Extend the length of a segment by a given distance. | |
| double | Length () const |
| Return axis length. | |
| void | Draw (QGraphicsScene &, const QPen &=QPen()) const |
| Draw a segment. | |
| void | DrawArrow (QGraphicsScene &, const double &, const QPen &=QPen(), const QBrush &=QBrush(QColor(255, 255, 255))) const |
| Draw a segment as an arrow. | |
| double | R (const Vector2 &) const |
| Compute the squared distance to the segment. | |
| double | R (const Vector2 &, double &) const |
| Compute the squared distance to the axis edge characterized by its end points. | |
| Vector2 | Normal (const Vector2 &) const |
| Compute the normal vector between a point and its projection onto the segment. | |
| bool | Intersect (const Segment2 &) const |
| Test if two segments intersect. | |
| bool | Intersection (const Segment2 &, Vector2 &) const |
| Compute the intersection between two segments. | |
| Segment2 | Shrinked (const double &) const |
| Create a new segment by shrinking the current segment. | |
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. | |
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 &s, const Segment2 &segment) |
| Overloaded. | |
| bool | operator== (const Segment2 &a, const Segment2 &b) |
| Compare two segments. | |
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(QColor(255, 255, 255)) ) const |
Draw a segment as an arrow.
| scene | Graphics scene. |
| pen | The pen. |
| brush | The brush. |
| s | Size of the arrow head. |
| Segment2 Segment2::Extended | ( | const double & | r | ) | const |
Extend the length of a segment by a given distance.
A negative value shrinks the segment.
| r | Distance. |
| 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. |
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. |
| Segment2 Segment2::Shrinked | ( | const double & | s | ) | const |
Create a new segment by shrinking the current segment.
| s | Shrinkage distance. |
| void Segment2::Translate | ( | const Vector2 & | t | ) |
Translates a segment.
| t | Translation vector. |
Translates a segment.
| t | Translation vector. |
|
inline |
Compute a point on the segment.
| t | Interpolation parameter. |
|
friend |
Overloaded.
| s | Stream. |
| segment | The segment. |