V-ART
Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
VART::Point4D Class Reference

Points and vectors using homogeneous coordinates. More...

#include <point4d.h>

Inheritance diagram for VART::Point4D:
VART::Point

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 Point4DDOWN ()
 The (0,-1,0,0) vector. More...
 
static const Point4DORIGIN ()
 The (0,0,0,1) point. More...
 
static const Point4DX ()
 The X vector (1,0,0,0). More...
 
static const Point4DY ()
 The Y vector (0,1,0,0). More...
 
static const Point4DZ ()
 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...
 

Detailed Description

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.

Definition at line 22 of file point4d.h.

Constructor & Destructor Documentation

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.

Member Function Documentation

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.

See Also
Point4D::GenericAngleTo(const Point4D& p)
Returns
the angle in radians of the smaller arc between "this" and "p".

Definition at line 126 of file point4d.cpp.

Referenced by VART::Transform::MakeRotation().

double VART::Point4D::AngleTo ( const Point4D p,
const Point4D ref 
) const

Computes the signed angle to p, using ref as a positive axis reference.

Requires all three vectors to be normalized.

Returns
the angle in radians to p (for a rotation around ref).

Definition at line 141 of file point4d.cpp.

VART::Point4D VART::Point4D::CrossProduct ( const Point4D p) const
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().

const VART::Point4D & VART::Point4D::DOWN ( )
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.

Returns
the angle in radians of the smaller arc between "this" and "p".

Definition at line 152 of file point4d.cpp.

References Length().

Referenced by VART::Arrow::Arrow().

double VART::Point4D::GetW ( ) const
inline
double VART::Point4D::GetX ( ) const
inline
double VART::Point4D::GetY ( ) const
inline
double VART::Point4D::GetZ ( ) const
inline
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.

Returns
a (translated) point.

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.

Returns
a vector (from "point" to "this").

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.

const VART::Point4D & VART::Point4D::ORIGIN ( )
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().

void VART::Point4D::SetW ( double  w)
inline
void VART::Point4D::SetX ( double  x)
inline
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 
)
void VART::Point4D::SetY ( double  y)
inline
void VART::Point4D::SetZ ( double  z)
inline
const double* VART::Point4D::VetXYZW ( ) const
inline

Returns vertex coordinates as a pointer to 4 doubles.

This method is usefull to pass to glVertex4dv().

Definition at line 86 of file point4d.h.

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.

const VART::Point4D & VART::Point4D::X ( )
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.

const VART::Point4D & VART::Point4D::Y ( )
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.

const VART::Point4D & VART::Point4D::Z ( )
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.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
const Point4D p 
)
friend

Output operator.

Member Data Documentation

double VART::Point4D::delta = 0.00001
static

Maximum difference for equality.

Used to see if floating point numbers are almost equal.

Definition at line 163 of file point4d.h.

VART::Point4D::tCompareOper VART::Point4D::operatorLess = &VART::Point4D::LexicographicalLess
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.

Definition at line 152 of file point4d.h.

float VART::Point4D::xWeight = 1
static

Weight of the X coordinate for Weighted comparisons.

Definition at line 155 of file point4d.h.

float VART::Point4D::yWeight = 1
static

Weight of the Y coordinate for Weighted comparisons.

Definition at line 157 of file point4d.h.

float VART::Point4D::zWeight = 1
static

Weight of the Z coordinate for Weighted comparisons.

Definition at line 159 of file point4d.h.


The documentation for this class was generated from the following files: