wfmath 1.0.3
A math library for the Worldforge system.
|
A dim dimensional point. More...
#include <point.h>
Public Member Functions | |
Point () | |
Construct an uninitialized point. More... | |
Point (const Point &)=default | |
Construct a copy of a point. More... | |
Point (const AtlasInType &a) | |
Construct a point from an object passed by Atlas. More... | |
Point (const Vector< dim > &vector) | |
Construct a point from a vector. More... | |
AtlasOutType | toAtlas () const |
Create an Atlas object from the point. More... | |
void | fromAtlas (const AtlasInType &a) |
Set the point's value to that given by an Atlas object. More... | |
Point & | operator= (const Point &rhs)=default |
bool | isEqualTo (const Point &p, CoordType epsilon=numeric_constants< CoordType >::epsilon()) const |
bool | operator== (const Point &rhs) const |
bool | operator!= (const Point &rhs) const |
bool | isValid () const |
void | setValid (bool valid=true) |
make isValid() return true if you've initialized the point by hand More... | |
Point & | setToOrigin () |
Set point to (0,0,...,0) More... | |
Point & | rotate (const RotMatrix< dim > &m, const Point &p) |
Rotate about point p. More... | |
size_t | numCorners () const |
Point< dim > | getCorner (size_t) const |
Point< dim > | getCenter () const |
Point | shift (const Vector< dim > &v) |
Point | moveCornerTo (const Point &p, size_t) |
Point | moveCenterTo (const Point &p) |
Point & | rotateCorner (const RotMatrix< dim > &, size_t) |
Point & | rotateCenter (const RotMatrix< dim > &) |
Point & | rotatePoint (const RotMatrix< dim > &m, const Point &p) |
Point & | rotate (const Quaternion &q, const Point &p) |
Point & | rotateCorner (const Quaternion &, size_t) |
Point & | rotateCenter (const Quaternion &) |
Point & | rotatePoint (const Quaternion &q, const Point &p) |
AxisBox< dim > | boundingBox () const |
Ball< dim > | boundingSphere () const |
Ball< dim > | boundingSphereSloppy () const |
Point | toParentCoords (const Point &origin, const RotMatrix< dim > &rotation=RotMatrix< dim >().identity()) const |
Point | toParentCoords (const AxisBox< dim > &coords) const |
Point | toParentCoords (const RotBox< dim > &coords) const |
Point | toLocalCoords (const Point &origin, const RotMatrix< dim > &rotation=RotMatrix< dim >().identity()) const |
Point | toLocalCoords (const AxisBox< dim > &coords) const |
Point | toLocalCoords (const RotBox< dim > &coords) const |
Point | toParentCoords (const Point &origin, const Quaternion &rotation) const |
Point | toLocalCoords (const Point &origin, const Quaternion &rotation) const |
CoordType | operator[] (const int i) const |
Access the i'th coordinate of the point. More... | |
CoordType & | operator[] (const int i) |
Access the i'th coordinate of the point. More... | |
Point (CoordType x, CoordType y) | |
2D only: construct a point from its (x, y) coordinates More... | |
Point (CoordType x, CoordType y, CoordType z) | |
3D only: construct a point from its (x, y, z) coordinates More... | |
CoordType | x () const |
access the first component of a point More... | |
CoordType & | x () |
access the first component of a point More... | |
CoordType | y () const |
access the second component of a point More... | |
CoordType & | y () |
access the second component of a point More... | |
CoordType | z () const |
access the third component of a point More... | |
CoordType & | z () |
access the third component of a point More... | |
Point & | polar (CoordType r, CoordType theta) |
2D only: construct a vector from polar coordinates More... | |
void | asPolar (CoordType &r, CoordType &theta) const |
2D only: convert a vector to polar coordinates More... | |
Point & | polar (CoordType r, CoordType theta, CoordType z) |
3D only: construct a vector from polar coordinates More... | |
void | asPolar (CoordType &r, CoordType &theta, CoordType &z) const |
3D only: convert a vector to polar coordinates More... | |
Point & | spherical (CoordType r, CoordType theta, CoordType phi) |
3D only: construct a vector from spherical coordinates More... | |
void | asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const |
3D only: convert a vector to spherical coordinates More... | |
const CoordType * | elements () const |
Point< 2 > & | polar (CoordType r, CoordType theta) |
void | asPolar (CoordType &r, CoordType &theta) const |
Point< 3 > & | polar (CoordType r, CoordType theta, CoordType z) |
void | asPolar (CoordType &r, CoordType &theta, CoordType &z) const |
Point< 3 > & | spherical (CoordType r, CoordType theta, CoordType phi) |
void | asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const |
Point< 3 > & | rotate (const Quaternion &q, const Point< 3 > &p) |
Point< 3 > & | rotatePoint (const Quaternion &q, const Point< 3 > &p) |
Point< 3 > | toLocalCoords (const Point< 3 > &origin, const Quaternion &rotation) const |
Point< 3 > | toParentCoords (const Point< 3 > &origin, const Quaternion &rotation) const |
CoordType | z () const |
CoordType & | z () |
Point (CoordType x, CoordType y) | |
Point (CoordType x, CoordType y, CoordType z) | |
Point< 2 > & | polar (CoordType r, CoordType theta) |
void | asPolar (CoordType &r, CoordType &theta) const |
Point< 3 > & | polar (CoordType r, CoordType theta, CoordType z) |
void | asPolar (CoordType &r, CoordType &theta, CoordType &z) const |
Point< 3 > & | spherical (CoordType r, CoordType theta, CoordType phi) |
void | asSpherical (CoordType &r, CoordType &theta, CoordType &phi) const |
Static Public Member Functions | |
static const Point< dim > & | ZERO () |
Provides a global instance preset to zero. More... | |
Friends | |
class | ZeroPrimitive< Point< dim > > |
std::ostream & | operator (std::ostream &os, const Point &p) |
std::istream & | operator>> (std::istream &is, Point &p) |
Vector< dim > | operator- (const Point &c1, const Point &c2) |
Point | operator+ (const Point &c, const Vector< dim > &v) |
Point | operator- (const Point &c, const Vector< dim > &v) |
Point | operator+ (const Vector< dim > &v, const Point &c) |
Point & | operator+= (Point &p, const Vector< dim > &rhs) |
Point & | operator-= (Point &p, const Vector< dim > &rhs) |
CoordType | SquaredDistance (const Point &p1, const Point &p2) |
Get the square of the distance from p1 to p2. More... | |
Point< dim > | Midpoint (const Point &p1, const Point &p2, CoordType dist) |
Find a point on the line containing p1 and p2, by default the midpoint. More... | |
A dim dimensional point.
This class implements the full shape interface, as described in the fake class Shape.
|
inline |
|
default |
Construct a copy of a point.
|
inlineexplicit |
Construct a point from an object passed by Atlas.
Definition at line 184 of file atlasconv.h.
|
inlineexplicit |
Construct a point from a vector.
Definition at line 40 of file point_funcs.h.
WFMath::Point< dim >::Point | ( | CoordType | x, |
CoordType | y | ||
) |
2D only: construct a point from its (x, y) coordinates
WFMath::Point< dim >::Point | ( | CoordType | x, |
CoordType | y, | ||
CoordType | z | ||
) |
3D only: construct a point from its (x, y, z) coordinates
|
inline |
|
inline |
void WFMath::Point< 2 >::asPolar | ( | CoordType & | r, |
CoordType & | theta | ||
) | const |
void WFMath::Point< dim >::asPolar | ( | CoordType & | r, |
CoordType & | theta | ||
) | const |
2D only: convert a vector to polar coordinates
void WFMath::Point< 3 >::asPolar | ( | CoordType & | r, |
CoordType & | theta, | ||
CoordType & | z | ||
) | const |
void WFMath::Point< dim >::asPolar | ( | CoordType & | r, |
CoordType & | theta, | ||
CoordType & | z | ||
) | const |
3D only: convert a vector to polar coordinates
void WFMath::Point< 3 >::asSpherical | ( | CoordType & | r, |
CoordType & | theta, | ||
CoordType & | phi | ||
) | const |
void WFMath::Point< dim >::asSpherical | ( | CoordType & | r, |
CoordType & | theta, | ||
CoordType & | phi | ||
) | const |
3D only: convert a vector to spherical coordinates
|
inline |
Definition at line 187 of file axisbox_funcs.h.
|
inline |
Definition at line 169 of file ball_funcs.h.
|
inline |
Definition at line 175 of file ball_funcs.h.
|
inline |
|
inline |
Set the point's value to that given by an Atlas object.
Definition at line 190 of file atlasconv.h.
Referenced by WFMath::RotBox< dim >::fromAtlas().
|
inline |
|
inline |
|
inline |
Definition at line 68 of file point_funcs.h.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Point< 2 > & WFMath::Point< 2 >::polar | ( | CoordType | r, |
CoordType | theta | ||
) |
Point & WFMath::Point< dim >::polar | ( | CoordType | r, |
CoordType | theta | ||
) |
2D only: construct a vector from polar coordinates
Point< 3 > & WFMath::Point< 3 >::polar | ( | CoordType | r, |
CoordType | theta, | ||
CoordType | z | ||
) |
Point & WFMath::Point< dim >::polar | ( | CoordType | r, |
CoordType | theta, | ||
CoordType | z | ||
) |
3D only: construct a vector from polar coordinates
Point< 3 > & WFMath::Point< 3 >::rotate | ( | const Quaternion & | q, |
const Point< 3 > & | p | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Point< 3 > & WFMath::Point< 3 >::rotatePoint | ( | const Quaternion & | q, |
const Point< 3 > & | p | ||
) |
|
inline |
|
inline |
Set point to (0,0,...,0)
Definition at line 56 of file point_funcs.h.
|
inline |
make isValid() return true if you've initialized the point by hand
Definition at line 129 of file point.h.
Referenced by WFMath::Ball< dim >::Ball(), WFMath::Barycenter(), WFMath::BoundingBox(), WFMath::BoundingSphere(), WFMath::BoundingSphereSloppy(), and WFMath::AxisBox< dim >::setCorners().
|
inline |
Point< 3 > & WFMath::Point< 3 >::spherical | ( | CoordType | r, |
CoordType | theta, | ||
CoordType | phi | ||
) |
Point & WFMath::Point< dim >::spherical | ( | CoordType | r, |
CoordType | theta, | ||
CoordType | phi | ||
) |
3D only: construct a vector from spherical coordinates
|
inline |
Create an Atlas object from the point.
Definition at line 203 of file atlasconv.h.
Point< dim > WFMath::Point< dim >::toLocalCoords | ( | const AxisBox< dim > & | coords | ) | const |
Definition at line 199 of file axisbox_funcs.h.
|
inline |
Point< 3 > WFMath::Point< 3 >::toLocalCoords | ( | const Point< 3 > & | origin, |
const Quaternion & | rotation | ||
) | const |
Point< dim > WFMath::Point< dim >::toLocalCoords | ( | const RotBox< dim > & | coords | ) | const |
Definition at line 109 of file rotbox_funcs.h.
Point< dim > WFMath::Point< dim >::toParentCoords | ( | const AxisBox< dim > & | coords | ) | const |
Definition at line 193 of file axisbox_funcs.h.
|
inline |
Point< 3 > WFMath::Point< 3 >::toParentCoords | ( | const Point< 3 > & | origin, |
const Quaternion & | rotation | ||
) | const |
Point< dim > WFMath::Point< dim >::toParentCoords | ( | const RotBox< dim > & | coords | ) | const |
Definition at line 103 of file rotbox_funcs.h.
|
inline |
|
inline |
|
inline |
|
inline |
CoordType & WFMath::Point< dim >::z | ( | ) |
access the third component of a point
|
inline |
CoordType WFMath::Point< dim >::z | ( | ) | const |
access the third component of a point
|
inline |
|
static |
Provides a global instance preset to zero.
Definition at line 48 of file point_funcs.h.
References WFMath::ZeroPrimitive< Shape >::getShape().
|
friend |
Find a point on the line containing p1 and p2, by default the midpoint.
The default value of 0.5 for dist gives the midpoint. A value of 0 gives p1, and 1 gives p2. Values of dist outside the [0, 1] range are allowed, and give points on the line which are not on the segment bounded by p1 and p2.
Definition at line 219 of file point_funcs.h.
Definition at line 100 of file point_funcs.h.
|
friend |
Definition at line 86 of file point_funcs.h.
Definition at line 112 of file point_funcs.h.
|
friend |
|
friend |
Get the square of the distance from p1 to p2.
Definition at line 124 of file point_funcs.h.
|
friend |