C3D Toolkit
Kernel - 117958, Vision - 2.7.6.12
|
The cartesian two-dimensional point. More...
#include <mb_cart_point.h>
Public Member Functions | |
MbCartPoint () | |
Default constructor. More... | |
MbCartPoint (const MbCartPoint &p) | |
Copy-constructor. | |
MbCartPoint (const MbVector &p) | |
Constructor by a vector. | |
MbCartPoint (double initX, double initY) | |
Constructor by coordinates. | |
MbCartPoint (const MbCartPoint &p, const MbMatrix &matr) | |
Constructor by a point in a local coordinate system. More... | |
MbCartPoint (const MbFloatPoint &) | |
Constructor by float point. | |
void | SetZero () |
Set coordinates to zero. | |
template<class Point > | |
MbCartPoint & | Init (const Point &p) |
Initialize by another point. | |
MbCartPoint & | Init (double initX, double initY) |
Initialize by coordinates. | |
double | DistanceToPoint (const MbCartPoint &to) const |
Find the distance between points. | |
MbCartPoint & | Transform (const MbMatrix &matr) |
Transform according to the matrix. | |
MbCartPoint & | Move (const MbVector &to) |
Translate along a vector. | |
MbCartPoint & | Move (double dx, double dy) |
Translate by given increments. | |
double | DistanceToPoint2 (const MbCartPoint &to) const |
Find the squared distance between points. | |
double | DistanceToLineSeg (const MbCartPoint &p1, const MbCartPoint &p2, double eps=Math::LengthEps) const |
The distance from a point to a segment. More... | |
double | Length () const |
The vector length ( 0, p(x,y) ). | |
void | Scale (double sx, double sy) |
Scale the coordinates. More... | |
void | GetProperties (MbProperties &properties) |
Get properties of the object. | |
void | SetProperties (const MbProperties &properties) |
Set properties of the object. | |
bool | IsSame (const MbCartPoint &other, double accuracy) const |
Are the objects equal? More... | |
bool | IsUndefined () const |
Is the point undefined? | |
Translations, rotations, reflections. | |
void | MoveAlongLine (const MbCartPoint &p2, double delta) |
Translate along the direction which is defined by a second point. More... | |
void | MoveAlongLine (double angle, double delta) |
Translate along the direction which is defined by an angle. More... | |
void | MoveAlongLine (const MbDirection &angle, double delta) |
Translate along the direction which is defined by a vector. More... | |
void | MoveAlongLine (const MbVector &vect, double delta) |
Translate along the direction which is defined by a vector. More... | |
void | MoveUntilDist (const MbCartPoint &p1, double dist) |
Translate the point towards a given point to the distance "dist". More... | |
void | GoNearToPoint (const MbCartPoint &to, double ratio) |
Translate along the direction. More... | |
void | Rotate (const MbCartPoint &pnt, double angle) |
Rotate by an angle. More... | |
void | Rotate (const MbCartPoint &pnt, const MbDirection &angle) |
Rotate by an angle. More... | |
void | Rotate (double angle) |
Rotate by an angle. More... | |
void | Rotate (const MbDirection &angle) |
Rotate by an angle. More... | |
MbCartPoint | Mirror (const MbCartPoint &from) const |
Reflect a point specularly from a given point. More... | |
MbCartPoint | Mirror (const MbCartPoint &p1, const MbCartPoint &p2) const |
Reflect a point specularly from a line. More... | |
void | Mirror (const MbCartPoint &p1, const MbDirection &dir) |
Reflect a point specularly from a line. More... | |
Logical and arithmetical operations. | |
double & | operator[] (size_t i) |
Access to a coordinate by an index. | |
double | operator[] (size_t i) const |
The value of a coordinate by an index. | |
bool | operator== (const MbCartPoint &with) const |
Check for equality with tolerance. | |
bool | operator!= (const MbCartPoint &with) const |
Check for inequality. | |
bool | Equal (const MbCartPoint &with) const |
Check for an accurate equality. | |
bool | operator< (const MbCartPoint &) const |
Check for "less". | |
bool | operator> (const MbCartPoint &) const |
Check for "greater". | |
MbVector | operator+ (const MbCartPoint &pnt) const |
Sum two points. | |
MbVector | operator- (const MbCartPoint &pnt) const |
Subtract a point from the point. | |
MbCartPoint | operator+ (const MbDirection &d) const |
Add a point to a vector. | |
MbCartPoint | operator- (const MbDirection &d) const |
Subtract a vector from a point. | |
MbCartPoint | operator- () const |
The unary minus. | |
MbCartPoint | operator* (double factor) const |
Multiply a point by a number. | |
MbCartPoint | operator/ (double factor) const |
Divide a point by a number. | |
MbCartPoint | operator* (const MbMatrix &) const |
Calculate the point as this copy transformed by the matrix. | |
void | operator+= (const MbCartPoint &pnt) |
Sum two points. | |
void | operator-= (const MbCartPoint &pnt) |
Subtract a point from the point. | |
void | operator*= (double factor) |
Multiply a point by a number. | |
void | operator/= (double factor) |
Divide a point by a number. | |
void | operator+= (MbVector &v) |
Add a point to a vector. | |
void | operator-= (MbVector &v) |
Subtract a vector from a point. | |
MbCartPoint | operator+ (const MbVector &vector) const |
Add a point to a vector. | |
MbCartPoint | operator- (const MbVector &vector) const |
Subtract a vector from a point. | |
MbCartPoint & | operator= (const MbCartPoint &) |
Assign the value of another point to the point. | |
void | operator= (const MbVector &) |
Assign values of vector components to the point. | |
void | operator= (const MbDirection &) |
Assign values of vector components to the point. | |
void | operator= (const MbFloatPoint &) |
Assign the float-point value to the point. | |
The functions of addition and multiplication of points with points and vectors. | |
void | Set (const MbCartPoint &v1, const MbVector &v2, double t2) |
Equate coordinates to sum of point coordinates and vector coordinates. More... | |
void | Set (const MbCartPoint &v1, const MbVector &v2, double t2, const MbVector &v3, double t3) |
Equate coordinates to sum of point coordinates and two vectors coordinates. More... | |
void | Set (const MbCartPoint &v1, double t1, const MbCartPoint &v2, double t2) |
Equate coordinates to sum of two points coordinates. More... | |
void | Set (const MbCartPoint &v1, double t1, const MbCartPoint &v2, double t2, const MbCartPoint &v3, double t3) |
Equate coordinates to sum of three points coordinates. More... | |
void | Set (const MbCartPoint &v1, double t1, const MbCartPoint &v2, double t2, const MbCartPoint &v3, double t3, const MbCartPoint &v4, double t4) |
Equate coordinates to sum of four points coordinates. More... | |
void | Set (const MbCartPoint &v1, const MbDirection &v2, double t2, const MbDirection &v3, double t3) |
Equate coordinates to sum of point coordinates and two vectors coordinates. More... | |
void | Add (const MbVector &v1, double t1) |
Increase coordinates by values of vector components. More... | |
void | Add (const MbVector &v1, double t1, const MbVector &v2, double t2) |
Increase coordinates by values of two vectors components. More... | |
void | Add (const MbVector &v1, double t1, const MbVector &v2, double t2, const MbVector &v3, double t3) |
Increase coordinates by values of v1, v2 and v3 vectors components multiplied by t1, t2 and t3 respectively. More... | |
void | Add (const MbVector &v1, double t1, const MbVector &v2, double t2, const MbVector &v3, double t3, const MbVector &v4, double t4) |
Increase coordinates by values of three vectors components. More... | |
void | Add (const MbDirection &v1, double t1, const MbDirection &v2, double t2) |
Increase coordinates by values of two vectors components. More... | |
void | Add (const MbCartPoint &v1, double t1) |
Increase coordinates by values of point coordinates. More... | |
void | Add (const MbCartPoint &v1, double t1, const MbCartPoint &v2, double t2, const MbCartPoint &v3, double t3) |
Increase coordinates by values of three points coordinates. More... | |
void | Add (const MbCartPoint &v1, double t1, const MbCartPoint &v2, double t2, const MbCartPoint &v3, double t3, const MbCartPoint &v4, double t4) |
Increase coordinates by values of four points coordinates. More... | |
Static Public Member Functions | |
static size_t | GetDimension () |
The number of point coordinates. | |
Public Attributes | |
double | x |
A first coordinate of point. | |
double | y |
A second coordinate of point. | |
Static Public Attributes | |
static const MbCartPoint | origin |
The origin or { 0, 0 }. | |
The cartesian two-dimensional point.
The two-dimensional point is defined by two coordinates. Different logical, arithmetical and geometrical operations of points with points and vectors are defined. The point is named in honor of French scientist Rene Descartes (lat. Renatus Cartesius).
|
inline |
Default constructor.
Creates a point with zero coordinates.
|
inline |
Constructor by a point in a local coordinate system.
A transition matrix is given for transforming of a point to the global coordinate system from a local coordinate system.
[in] | p | - A point in the local coordinate system. |
[in] | matr | - A transition matrix from the local coordinate system to the global coordinate system. |
void MbCartPoint::MoveAlongLine | ( | const MbCartPoint & | p2, |
double | delta | ||
) |
Translate along the direction which is defined by a second point.
[in] | p2 | - An initial point, which defines the direction of the translation. |
[in] | delta | - Magnitude of the translation. |
|
inline |
Translate along the direction which is defined by an angle.
[in] | angle | - An angle which defines the direction of the translation. |
[in] | delta | - Magnitude of the translation. |
|
inline |
Translate along the direction which is defined by a vector.
[in] | angle | - A vector which defines the direction of the translation. |
[in] | delta | - Magnitude of the translation. |
Translate along the direction which is defined by a vector.
[in] | angle | - A vector which defines the direction of the translation. |
[in] | delta | - Magnitude of the translation. |
void MbCartPoint::MoveUntilDist | ( | const MbCartPoint & | p1, |
double | dist | ||
) |
Translate the point towards a given point to the distance "dist".
[in] | p1 | - An initial point, which defines the direction of the translation. |
[in] | dist | - Magnitude of the translation. |
|
inline |
Translate along the direction.
Translation along the direction of the "to" point to the distance which is defined by the ratio of "ratio" and distance between points.
[in] | to | - A point. |
[in] | ratio | - A distance part. |
|
inline |
Rotate by an angle.
An angle defines a rotation vector and a point defines a center.
[in] | pnt | - A point. |
[in] | angle | - A rotation angle. |
void MbCartPoint::Rotate | ( | const MbCartPoint & | pnt, |
const MbDirection & | angle | ||
) |
Rotate by an angle.
An angle is defined by a rotation vector.
[in] | pnt | - A point is a rotation center. |
[in] | angle | - A rotation vector. |
|
inline |
Rotate by an angle.
An angle defines a rotation vector.
[in] | angle | - A rotation angle. |
void MbCartPoint::Rotate | ( | const MbDirection & | angle | ) |
Rotate by an angle.
An angle is defined by a rotation vector.
[in] | angle | - A rotation vector. |
|
inline |
Reflect a point specularly from a given point.
[in] | from | - A point from which it is necessary to reflect the initial point. |
MbCartPoint MbCartPoint::Mirror | ( | const MbCartPoint & | p1, |
const MbCartPoint & | p2 | ||
) | const |
Reflect a point specularly from a line.
[in] | p1,p2 | - Points which define a line. |
|
inline |
Reflect a point specularly from a line.
The reflection from a line in the direction which is defined by the base point.
[in] | p1 | - A point which defines the direction of the reflection. |
[in] | dir | - A vector defines a line from which the reflection is made. |
double MbCartPoint::DistanceToLineSeg | ( | const MbCartPoint & | p1, |
const MbCartPoint & | p2, | ||
double | eps = Math::LengthEps |
||
) | const |
The distance from a point to a segment.
A segment is defined by two input points,
[in] | p1,p2 | - Start and end points of a segment. |
|
inline |
Scale the coordinates.
[in] | sx,sy | - Scaling coefficients for components x & y respectively. |
|
inline |
Equate coordinates to sum of point coordinates and vector coordinates.
Equate coordinates to sum of v1 point coordinates and v2 vector coordinates multiplied by t2.
[in] | v1 | - The initial point. |
[in] | v2 | - The initial vector. |
[in] | t2 | - Coordinates of the initial vector v2 are multiplied by this number. |
|
inline |
Equate coordinates to sum of point coordinates and two vectors coordinates.
Equate coordinates to sum of v1 point coordinates and v2 and v3 vectors coordinates multiplied by the numbers t2 and t3 respectively.
[in] | v1 | - The initial point. |
[in] | v2,v3 | - The initial vectors. |
[in] | t2,t3 | - Coordinates of v2 and v3 vectors are multiplied by these numbers respectively. |
|
inline |
Equate coordinates to sum of two points coordinates.
Equate coordinates to sum of v1 and v2 points coordinates multiplied by the numbers t1 and t2 respectively.
[in] | v1,v2 | - Initial points. |
[in] | t1,t2 | - Coordinates of v1 and v2 points are multiplied by these numbers respectively. |
|
inline |
Equate coordinates to sum of three points coordinates.
Equate coordinates to sum of v1, v2 and v3 points coordinates multiplied by the numbers t1, t2 and t3 respectively.
[in] | v1,v2,v3 | - Initial points. |
[in] | t1,t2,t3 | - Coordinates of v1, v2 and v3 points are multiplied by these numbers respectively. |
|
inline |
Equate coordinates to sum of four points coordinates.
Equate coordinates to sum of v1, v2, v3 and v4 points coordinates multiplied by the numbers t1, t2, t3 and t4 respectively.
[in] | v1,v2,v3,v4 | - Initial points. |
[in] | t1,t2,t3,t4 | - Coordinates of v1, v2, v3 and v4 points are multiplied by these numbers respectively. |
|
inline |
Equate coordinates to sum of point coordinates and two vectors coordinates.
Equate coordinates to sum of v1 point coordinates and v2 and v3 vectors coordinates multiplied by the numbers t2 and t3 respectively.
[in] | v1 | - The initial point. |
[in] | v2,v3 | - The initial vectors. |
[in] | t2,t3 | - Coordinates of v2 and v3 vectors are multiplied by these numbers respectively. |
Increase coordinates by values of vector components.
Increase coordinates by values of v1 vector components multiplied by t1.
[in] | v1 | - The initial vector. |
[in] | t1 | - Coordinates of the initial vector v1 are multiplied by this number. |
Increase coordinates by values of two vectors components.
Increase coordinates by values of v1 and v2 vectors components multiplied by the numbers t1 and t2 respectively.
[in] | v1,v2 | - The initial vectors. |
[in] | t1,t2 | - Coordinates of v1 and v2 vectors are multiplied by these numbers respectively. |
|
inline |
Increase coordinates by values of v1, v2 and v3 vectors components multiplied by t1, t2 and t3 respectively.
[in] | v1,v2,v3 | - The initial vectors. |
[in] | t1,t2,t3 | - Coordinates of v1, v2 and v3 vectors are multiplied by these numbers respectively. |
|
inline |
Increase coordinates by values of three vectors components.
Increase coordinates by values of v1, v2 and v3 vectors components multiplied by the numbers t1, t2 and t3 respectively.
[in] | v1,v2,v3 | - The initial vectors. |
[in] | t1,t2,t3 | - Coordinates of v1, v2 and v3 vectors are multiplied by these numbers respectively. |
|
inline |
Increase coordinates by values of two vectors components.
Increase coordinates by values of v1 and v2 vectors components multiplied by the numbers t1 and t2 respectively.
[in] | v1,v2 | - The initial vectors. |
[in] | t1,t2 | - Coordinates of v1 and v2 vectors are multiplied by these numbers respectively. |
|
inline |
Increase coordinates by values of point coordinates.
Increase coordinates by values of v1 point coordinates multiplied by t1.
[in] | v1 | - The initial point. |
[in] | t1 | - Coordinates of the initial point v1 are multiplied by this number. |
|
inline |
Increase coordinates by values of three points coordinates.
Increase coordinates by values of v1, v2 and v3 points coordinates multiplied by the numbers t1, t2 and t3 respectively.
[in] | v1,v2,v3 | - Initial points. |
[in] | t1,t2,t3 | - Coordinates of v1, v2 and v3 points are multiplied by these numbers respectively. |
|
inline |
Increase coordinates by values of four points coordinates.
Increase coordinates by values of v1, v2, v3 and v4 points coordinates multiplied by the numbers t1, t2, t3 and t4 respectively.
[in] | v1,v2,v3,v4 | - Initial points. |
[in] | t1,t2,t3,t4 | - Coordinates of v1, v2, v3 and v4 points are multiplied by these numbers respectively. |
|
inline |
Are the objects equal?
The objects are equal if their data are equal with a given accuracy.
[in] | other | - The object to compare. |
[in] | accuracy | - The accuracy to compare. |