Core 1.0
|
A segment defined by its end vertices. More...
#include <segment.h>
Public Member Functions | |
Segment () | |
Empty. | |
Segment (const Vector &, const Vector &) | |
Creates a segment given its end vertices. More... | |
~Segment () | |
Empty. | |
void | Rotate (const Matrix &) |
Rotates a segment. More... | |
void | Translate (const Vector &) |
Translates a segment. More... | |
void | Scale (const double &) |
Uniformly scales a segment. More... | |
Segment | Translated (const Vector &) const |
Translates a segment. More... | |
Segment | Scaled (const Vector &) const |
Scales a segment. More... | |
Segment | Scaled (const double &) const |
Uniformly scales a segment. More... | |
Segment | Rotated (const Matrix &) const |
Rotates a segment. More... | |
Segment | InverseTransformed (const Frame &) const |
Inverse transformation. More... | |
Quadric | Equation (const Ray &) const |
Computes the polynomial equation of the Euclidean distance between a ray and the line corresponding to the segment. More... | |
Vector | Vertex (int) const |
Return one of the end vertex of the axis. | |
Vector & | Vertex (int) |
Return one of the end vertex of the axis. | |
Vector | VertexAt (const double &) const |
Compute a point on the segment. More... | |
Vector | Center () const |
Compute the center of the segment. | |
bool | Intersect (const Box &) const |
Check if a segment intersects a box. More... | |
Vector | GetAxis () const |
Returns the normalized axis vector. | |
Box | GetBox () const |
Compute the bounding box of the segment. | |
double | Length () const |
Return axis length. | |
double | R (const Vector &) const |
Compute the squared distance to the segment. More... | |
double | R (const Vector &, double &) const |
Compute the squared distance to the segment. More... | |
double | R (const Segment &) const |
Compute the squared distance between two segments. More... | |
Vector | Normal (const Vector &) const |
Compute the normal vector between a point and its projection onto the segment. More... | |
bool | Equal (const Segment &, const double &) const |
Test if two segments are almost equal. More... | |
Static Public Member Functions | |
static Quadric | EdgeEquation (const Ray &, const Vector &, const Vector &, const Vector &) |
Compute the polynomial equation of the distance function along the ray. More... | |
static Vector | Intersect (const Vector &, const Vector &, const double, const double, 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... | |
Protected Attributes | |
Vector | b = Vector::Z |
End vertices of the segment. | |
Friends | |
std::ostream & | operator<< (std::ostream &, const Segment &) |
Overloaded. More... | |
A segment defined by its end vertices.
Axis inherits Segment and extends the structure by storing the normalized axis vector and its length. Lines are implemented by the class Line.
How do I compute the intersection of two segments?
In general, segments do not intersect, use the distance function.
Alternatively, it is possible to compute the intersection between two segments in the plane, using Segment2::Intersect(const Segment2&).
Creates a segment given its end vertices.
a,b | End vertices of the segment. |
|
static |
Compute the polynomial equation of the distance function along the ray.
ray | The ray. |
a | First vertex of the segment. |
axis | Axis. |
bool Segment::Equal | ( | const Segment & | s, |
const double & | epsilon | ||
) | const |
Test if two segments are almost equal.
This function computes the distance between the end vertices of the two argument segments. If the norm infinity of this difference is greater than the epsilon threshold value, then the segments are different.
s | Other segment. |
epsilon | Precision. This is a convenience function which is the same as: double e; // Epsilon value
Vector Vertex(int) const Return one of the end vertex of the axis. Definition: segment.h:76 static bool Equal(const Vector &, const Vector &, const double &=0.0001) Test if two vectors are almost equal. Definition: evector.cpp:85 |
Computes the polynomial equation of the Euclidean distance between a ray and the line corresponding to the segment.
ray | The ray. |
bool Segment::Intersect | ( | const Box & | box | ) | const |
Check if a segment intersects a box.
box | The box. |
|
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. |
Inverse transformation.
f | The frame. |
Compute the normal vector between a point and its projection onto the segment.
p | Point. |
double Segment::R | ( | const Segment & | segment | ) | const |
Compute the squared distance between two segments.
segment | The segment. |
double Segment::R | ( | const Vector & | p | ) | const |
Compute the squared distance to the segment.
p | Point. |
double Segment::R | ( | const Vector & | p, |
double & | s | ||
) | const |
Compute the squared distance to the segment.
p | Point. |
s | Linear coefficient corresponding to the projection of argument point p onto the segment. |
void Segment::Rotate | ( | const Matrix & | r | ) |
Rotates a segment.
Only the vertices and the axis are modified, the length is preserved.
r | Rotation matrix. |
void Segment::Scale | ( | const double & | s | ) |
Uniformly scales a segment.
s | Scaling factor. |
Segment Segment::Scaled | ( | const double & | s | ) | const |
Uniformly scales a segment.
s | Scaling factor. |
void Segment::Translate | ( | const Vector & | 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. |