V-ART
|
Points and vectors using homogeneous coordinates. More...
#include <point4d.h>
Public Member Functions | |
Point4D () | |
Creates the (0,0,0,1) point. More... | |
Point4D (const Point4D &point) | |
Point4D (double x, double y, double z, double w=1.0) | |
Point4D | operator- () const |
bool | operator== (const Point4D &point) const |
bool | operator!= (const Point4D &point) const |
void | operator= (const Point4D &point) |
bool | operator< (const Point4D &p) const |
Checks whether a point is "less then" other. More... | |
bool | LexicographicalLess (const Point4D &p) const |
Verifies whether a point is less than other by looking at coordinates in lexicographical (x, y, z then w) order. More... | |
bool | XThenZLess (const Point4D &p) const |
Verifies whether a point is less then other by looking at coordinates X, then Z only. More... | |
bool | YThenXLess (const Point4D &p) const |
bool | YThenZLess (const Point4D &p) const |
bool | ZThenXLess (const Point4D &p) const |
bool | ZThenYLess (const Point4D &p) const |
bool | WeightedLess (const Point4D &p) const |
bool | WeightedGreater (const Point4D &p) const |
Point4D | operator+ (const Point4D &vector) const |
Addition for point and vector (or vice versa). More... | |
void | operator+= (const Point4D &vector) |
Point4D | operator- (const Point4D &point) const |
Subtraction of two points. More... | |
Point4D | operator* (double escalar) const |
void | operator*= (double escalar) |
Point4D | operator/ (double escalar) const |
double | GetX () const |
double | GetY () const |
double | GetZ () const |
double | GetW () const |
const double * | VetXYZW () const |
Returns vertex coordinates as a pointer to 4 doubles. More... | |
double | DotProduct (const Point4D &p) const |
Computes the dot product between "this" and "p". More... | |
double | AngleTo (const Point4D &p) const |
Computes the angle up to p. More... | |
double | AngleTo (const Point4D &p, const Point4D &ref) const |
Computes the signed angle to p, using ref as a positive axis reference. More... | |
double | GenericAngleTo (const Point4D &p) const |
Point4D | CrossProduct (const Point4D &p) const |
Computes the cross product between "this" and "p". More... | |
void | SetX (double x) |
void | SetY (double y) |
void | SetZ (double z) |
void | SetW (double w) |
void | SetXY (double x, double y) |
void | SetXYZ (double x, double y, double z) |
void | SetXYZW (double x, double y, double z, double w) |
void | Normalize () |
Normalizes the point/vector. More... | |
double | Length () const |
Returns the vector's length. More... | |
bool | AlmostEqual (const Point4D &v) const |
Check if vector is almost equal to some other vector. More... | |
Public Member Functions inherited from VART::Point | |
virtual | ~Point () |
virtual float | GetX () |
virtual float | GetY () |
virtual float | GetZ () |
virtual float | GetW () |
virtual void | GetXY (float &x, float &y) |
virtual void | GetXZ (float &x, float &z) |
virtual void | GetYZ (float &y, float &z) |
virtual void | GetXYZ (float &x, float &y, float &z) |
virtual void | GetXYZW (float &x, float &y, float &z, float &w) |
virtual void | SetX (float x) |
virtual void | SetY (float y) |
virtual void | SetZ (float z) |
virtual void | SetW (float z) |
virtual void | SetXY (float x, float y) |
virtual void | SetXZ (float x, float z) |
virtual void | SetYZ (float y, float z) |
virtual void | SetXYZ (float x, float y, float z) |
virtual void | SetXYZW (float x, float y, float z, float w) |
Static Public Member Functions | |
static const Point4D & | DOWN () |
The (0,-1,0,0) vector. More... | |
static const Point4D & | ORIGIN () |
The (0,0,0,1) point. More... | |
static const Point4D & | X () |
The X vector (1,0,0,0). More... | |
static const Point4D & | Y () |
The Y vector (0,1,0,0). More... | |
static const Point4D & | Z () |
The Z vector (0,0,1,0). More... | |
Static Public Attributes | |
static tCompareOper | operatorLess = &VART::Point4D::LexicographicalLess |
Points to the operator to use within operator<. More... | |
static float | xWeight = 1 |
Weight of the X coordinate for Weighted comparisons. More... | |
static float | yWeight = 1 |
Weight of the Y coordinate for Weighted comparisons. More... | |
static float | zWeight = 1 |
Weight of the Z coordinate for Weighted comparisons. More... | |
static double | delta = 0.00001 |
Maximum difference for equality. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &output, const Point4D &p) |
Output operator. More... | |
Points and vectors using homogeneous coordinates.
The Point4D class provides a unified way of representing point and vectors objects, easing operations between these "two" kinds of entities along with integration with the Transform class. A 4D is homogeneous point represented by a vector (x,y,z,w). W coordinate is 0 for vectors and 1 for normalized points. This class has been created long after the Point3D and Vector3D classes, wich are used by (at this point) all other classes. It is recommended that this class slowly substitutes the other two.
VART::Point4D::Point4D | ( | ) |
Creates the (0,0,0,1) point.
Definition at line 17 of file point4d.cpp.
VART::Point4D::Point4D | ( | const Point4D & | point | ) |
Definition at line 23 of file point4d.cpp.
VART::Point4D::Point4D | ( | double | x, |
double | y, | ||
double | z, | ||
double | w = 1.0 |
||
) |
Definition at line 31 of file point4d.cpp.
bool VART::Point4D::AlmostEqual | ( | const Point4D & | v | ) | const |
Check if vector is almost equal to some other vector.
Definition at line 327 of file point4d.cpp.
double VART::Point4D::AngleTo | ( | const Point4D & | p | ) | const |
Computes the angle up to p.
Requires both vectors to be normalized.
Definition at line 126 of file point4d.cpp.
Referenced by VART::Transform::MakeRotation().
Computes the signed angle to p, using ref as a positive axis reference.
Requires all three vectors to be normalized.
Definition at line 141 of file point4d.cpp.
VART::Point4D VART::Point4D::CrossProduct | ( | const Point4D & | p | ) | const |
Computes the cross product between "this" and "p".
Definition at line 121 of file point4d.cpp.
References GetX(), GetY(), and GetZ().
Referenced by VART::MeshObject::AddFace(), VART::Camera::Camera(), VART::MeshObject::ComputeTriangleNormal(), VART::Camera::LeftVector(), VART::Camera::PitchAroundTarget(), and VART::Dof::Reconfigure().
double VART::Point4D::DotProduct | ( | const Point4D & | p | ) | const |
Computes the dot product between "this" and "p".
Definition at line 116 of file point4d.cpp.
Referenced by VART::Dof::Reconfigure().
|
static |
The (0,-1,0,0) vector.
Definition at line 55 of file point4d.cpp.
double VART::Point4D::GenericAngleTo | ( | const Point4D & | p | ) | const |
This method doesn't require both vectors to be normalized, but has poorer performance than Point4D::AngleTo(const Point4D& p) method.
Definition at line 152 of file point4d.cpp.
References Length().
Referenced by VART::Arrow::Arrow().
|
inline |
Definition at line 81 of file point4d.h.
Referenced by VART::Transform::ApplyTo(), VART::Transform::operator*(), and VART::operator<<().
|
inline |
Definition at line 78 of file point4d.h.
Referenced by VART::MeshObject::AddNormal(), VART::Transform::ApplyTo(), VART::BoundingBox::ApplyTransform(), VART::MeshObject::ApplyTransform(), VART::Arrow::Arrow(), VART::BoundingBox::ConditionalUpdate(), CrossProduct(), VART::Transform::MakeRotation(), VART::Transform::MakeTranslation(), VART::Transform::operator*(), VART::operator<<(), VART::MeshObject::SetVertex(), and VART::BoundingBox::testPoint().
|
inline |
Definition at line 79 of file point4d.h.
Referenced by VART::MeshObject::AddNormal(), VART::Transform::ApplyTo(), VART::BoundingBox::ApplyTransform(), VART::MeshObject::ApplyTransform(), VART::Arrow::Arrow(), VART::BoundingBox::ConditionalUpdate(), CrossProduct(), VART::Modifier::GetMax(), VART::Modifier::GetMin(), VART::Transform::MakeRotation(), VART::Transform::MakeTranslation(), VART::Transform::operator*(), VART::operator<<(), VART::MeshObject::SetVertex(), and VART::BoundingBox::testPoint().
|
inline |
Definition at line 80 of file point4d.h.
Referenced by VART::MeshObject::AddNormal(), VART::Transform::ApplyTo(), VART::BoundingBox::ApplyTransform(), VART::MeshObject::ApplyTransform(), VART::Arrow::Arrow(), VART::BoundingBox::ConditionalUpdate(), CrossProduct(), VART::Transform::MakeRotation(), VART::Transform::MakeTranslation(), VART::Transform::operator*(), VART::operator<<(), VART::MeshObject::SetVertex(), and VART::BoundingBox::testPoint().
double VART::Point4D::Length | ( | ) | const |
Returns the vector's length.
Definition at line 111 of file point4d.cpp.
Referenced by VART::Arrow::Arrow(), and GenericAngleTo().
bool VART::Point4D::LexicographicalLess | ( | const Point4D & | p | ) | const |
Verifies whether a point is less than other by looking at coordinates in lexicographical (x, y, z then w) order.
Definition at line 254 of file point4d.cpp.
void VART::Point4D::Normalize | ( | ) |
Normalizes the point/vector.
Points are normalized by dividing coordinates by W. Vectors are normalized by having their length changed to 1. Warning: The homogeneous point (0,0,0,0) is neither a point nor a vector and will cause a division by zero!
Definition at line 88 of file point4d.cpp.
Referenced by VART::MeshObject::AddFace(), VART::Camera::Camera(), VART::MeshObject::ComputeTriangleNormal(), VART::Dof::Dof(), VART::Camera::FrontVector(), VART::Camera::LeftVector(), VART::XmlScene::loadDofs(), VART::Transform::MakeRotation(), VART::Camera::MoveForward(), VART::Camera::MoveSideways(), VART::Camera::MoveUp(), VART::Camera::PitchAroundTarget(), VART::Camera::Roll(), and VART::Dof::Set().
bool VART::Point4D::operator!= | ( | const Point4D & | point | ) | const |
Definition at line 230 of file point4d.cpp.
VART::Point4D VART::Point4D::operator* | ( | double | escalar | ) | const |
Definition at line 201 of file point4d.cpp.
void VART::Point4D::operator*= | ( | double | escalar | ) |
Definition at line 209 of file point4d.cpp.
VART::Point4D VART::Point4D::operator+ | ( | const Point4D & | vector | ) | const |
Addition for point and vector (or vice versa).
Both point and vector should be normalized.
Definition at line 181 of file point4d.cpp.
void VART::Point4D::operator+= | ( | const Point4D & | vector | ) |
Definition at line 193 of file point4d.cpp.
VART::Point4D VART::Point4D::operator- | ( | ) | const |
Definition at line 166 of file point4d.cpp.
VART::Point4D VART::Point4D::operator- | ( | const Point4D & | point | ) | const |
Subtraction of two points.
Both points should be normalized.
Definition at line 173 of file point4d.cpp.
VART::Point4D VART::Point4D::operator/ | ( | double | escalar | ) | const |
Definition at line 246 of file point4d.cpp.
bool VART::Point4D::operator< | ( | const Point4D & | p | ) | const |
Checks whether a point is "less then" other.
The idea of ordering in 4D point comes from operatorLess public attribute.
Definition at line 225 of file point4d.cpp.
void VART::Point4D::operator= | ( | const Point4D & | point | ) |
Definition at line 238 of file point4d.cpp.
bool VART::Point4D::operator== | ( | const Point4D & | point | ) | const |
Definition at line 217 of file point4d.cpp.
|
static |
The (0,0,0,1) point.
Definition at line 61 of file point4d.cpp.
Referenced by VART::Bezier::Bezier(), and VART::Light::BRIGHT_AMBIENT().
|
inline |
Definition at line 115 of file point4d.h.
Referenced by VART::Dof::ComputeLIM(), VART::Transform::GetTranslation(), VART::Transform::GetVectorX(), VART::Transform::GetVectorY(), VART::Transform::GetVectorZ(), and VART::Dof::MoveTo().
|
inline |
Definition at line 112 of file point4d.h.
Referenced by VART::Transform::GetTranslation(), VART::Transform::GetVectorX(), VART::Transform::GetVectorY(), and VART::Transform::GetVectorZ().
void VART::Point4D::SetXY | ( | double | x, |
double | y | ||
) |
Definition at line 67 of file point4d.cpp.
void VART::Point4D::SetXYZ | ( | double | x, |
double | y, | ||
double | z | ||
) |
Definition at line 73 of file point4d.cpp.
Referenced by VART::MeshObject::SmallerVertex().
void VART::Point4D::SetXYZW | ( | double | x, |
double | y, | ||
double | z, | ||
double | w | ||
) |
Definition at line 80 of file point4d.cpp.
Referenced by VART::Transform::ApplyTo(), VART::MeshObject::ApplyTransform(), VART::MeshObject::ComputeBoundingBox(), VART::MeshObject::ComputeSubBBoxes(), VART::MeshObject::GetYProjection(), VART::XmlScene::loadDofs(), VART::Transform::MakeRotation(), and VART::MeshObject::SetVertices().
|
inline |
Definition at line 113 of file point4d.h.
Referenced by VART::Arrow::Arrow(), VART::Transform::GetTranslation(), VART::Transform::GetVectorX(), VART::Transform::GetVectorY(), and VART::Transform::GetVectorZ().
|
inline |
Definition at line 114 of file point4d.h.
Referenced by VART::Transform::GetTranslation(), VART::Transform::GetVectorX(), VART::Transform::GetVectorY(), and VART::Transform::GetVectorZ().
|
inline |
bool VART::Point4D::WeightedGreater | ( | const Point4D & | p | ) | const |
Definition at line 317 of file point4d.cpp.
bool VART::Point4D::WeightedLess | ( | const Point4D & | p | ) | const |
Definition at line 312 of file point4d.cpp.
|
static |
The X vector (1,0,0,0).
Definition at line 37 of file point4d.cpp.
Referenced by VART::Scene::MakeCameraViewAll().
bool VART::Point4D::XThenZLess | ( | const Point4D & | p | ) | const |
Verifies whether a point is less then other by looking at coordinates X, then Z only.
Definition at line 272 of file point4d.cpp.
|
static |
The Y vector (0,1,0,0).
Definition at line 43 of file point4d.cpp.
Referenced by VART::Scene::MakeCameraViewAll().
bool VART::Point4D::YThenXLess | ( | const Point4D & | p | ) | const |
Definition at line 280 of file point4d.cpp.
bool VART::Point4D::YThenZLess | ( | const Point4D & | p | ) | const |
Definition at line 288 of file point4d.cpp.
|
static |
The Z vector (0,0,1,0).
Definition at line 49 of file point4d.cpp.
bool VART::Point4D::ZThenXLess | ( | const Point4D & | p | ) | const |
Definition at line 296 of file point4d.cpp.
bool VART::Point4D::ZThenYLess | ( | const Point4D & | p | ) | const |
Definition at line 304 of file point4d.cpp.
|
friend |
Output operator.
|
static |
|
static |
Points to the operator to use within operator<.
The application programmer should change this pointer to the desired comparison function. Default value is LexicographicalLess. To change its value, use something like: Point4D::operatorLess = &Point4D::LexicographicalLess . Currently, possible values are: LexicographicalLess and XThenZLess.
|
static |
|
static |
|
static |