CUGL
2.0
|
#include <cugl.h>
Public Member Functions | |
Point (GLfloat x=0, GLfloat y=0, GLfloat z=0, GLfloat w=1) | |
Point (GLfloat coordinates[]) | |
Point (const Quaternion &q) | |
GLfloat & | operator[] (int i) |
const GLfloat & | operator[] (int i) const |
void | normalize () |
Point | unit () const |
void | draw () const |
void | light (GLenum lightNum) const |
void | translate () const |
Point | operator/ (GLfloat s) const |
Point | operator+= (const Vector &v) |
Point | operator-= (const Vector &v) |
Private Attributes | |
GLfloat | x |
GLfloat | y |
GLfloat | z |
GLfloat | w |
Friends | |
class | Line |
class | Vector |
class | Matrix |
class | Plane |
Point | operator+ (const Vector &v, const Point &p) |
Point | operator+ (const Point &p, const Vector &v) |
Point | operator* (const Point &p, GLfloat s) |
Point | operator* (GLfloat s, const Point &p) |
Vector | operator- (const Point &p, const Point &q) |
Point | meet (const Line &k, const Plane &p) |
bool | operator== (const Point &p, const Point &q) |
bool | operator!= (const Point &p, const Point &q) |
std::ostream & | operator<< (std::ostream &os, const Point &p) |
GLfloat | dist (const Point &p, const Plane &s) |
GLfloat | dist (const Plane &s, const Point &p) |
double | dist (const Point &p, const Point &q) |
An instance is a point represented by four homogeneous coordinates. A point is represented by (x,y,z,w) in which each component is a GLfloat
. If w=0, the point is `at infinity'. Points at infinity may be used like other points, but a few operations do not work for them. CUGL functions do not issue an error message when this happens: they simply return a default result.
A Point is in normal form if w=1. A Point may be normalized if w!=0.
cugl::Point::Point | ( | GLfloat | x = 0 , |
GLfloat | y = 0 , |
||
GLfloat | z = 0 , |
||
GLfloat | w = 1 |
||
) |
Construct a point with coordinates (x, y, z, w). Default parameter values: (0,0,0,1).
Referenced by operator/().
|
inline |
cugl::Point::Point | ( | const Quaternion & | q | ) |
Convert a Quaternion to a Point.
q | is a quaternion. |
|
inline |
|
inline |
void cugl::Point::normalize | ( | ) |
Displace a Point with a Vector. The components of the Vector are added to the corresponding components of the Point. If the Point is not in normal form, the Vector is implicitly scaled.
Definition at line 2598 of file cugl.h.
References w, x, cugl::Vector::x, y, cugl::Vector::y, z, and cugl::Vector::z.
Displace a Point with a Vector The components of the Vector are subtracted from the corresponding components of the Point. If the Point is not in normal form, the Vector is implicitly scaled.
Definition at line 2606 of file cugl.h.
References w, x, cugl::Vector::x, y, cugl::Vector::y, z, and cugl::Vector::z.
|
inline |
GLfloat& cugl::Point::operator[] | ( | int | i | ) |
Access coordinates of a point.
i | is the index of the coordinate: p[0] = x, p[1] = y, p[2] = z, p[3] = w. |
i
is not one of {0,1,2, 3}. const GLfloat& cugl::Point::operator[] | ( | int | i | ) | const |
Access coordinates of a point. This form is used with const
instances (p
[i] cannot appear on the left of =
).
i | is the index of the coordinate: p[0] = x, p[1] = y, p[2] = z, p[3] = w. |
i
is not one of {0,1,2, 3}.
|
inline |
Point cugl::Point::unit | ( | ) | const |
Return the distance between a Point and a Plane. The result has the correct magnitude only if the Point and the Plane are both in normal form. In particular, the result is incorrect if the Point is at infinity. However, the sign of the result is correct in all cases, and so it is not necessary to provide normalized arguments if only the sign is important.
Return the distance between a Point and a Plane. The result has the correct magnitude only if the Point and the Plane are both in normal form. In particular, the result is incorrect if the Point is at infinity. However, the sign of the result is correct in all cases, and so it is not necessary to provide normalized arguments if only the sign is important.
Return the vector corresponding to the displacement between the two points. This is the vector (p.x/p
.w - q.x/q
.w, p.y/p
.w - q.y/q
.w, p.z/p
.w - q.z/q
.w). If p
or q
is a point at infinity, return the zero vector.
|
friend |
Write "(x,y,z,w)" to output stream. Inserts the coordinates of the point into the output stream os
in the format "(x,y,z,w)". The current settings of the stream formatting parameters are used. If a width is specified with setw()
, it is applied to each coordinate, not to the point as a whole.
|
private |
W coordinate of point.
Definition at line 371 of file cugl.h.
Referenced by cugl::Matrix::apply(), cugl::dist(), draw(), light(), cugl::operator*(), cugl::operator+(), operator+=(), cugl::operator-(), operator-=(), operator/(), cugl::operator==(), Point(), translate(), and cugl::Vector::Vector().
|
private |
X coordinate of point.
Definition at line 362 of file cugl.h.
Referenced by cugl::Matrix::apply(), cugl::dist(), draw(), light(), cugl::operator*(), cugl::operator+(), operator+=(), cugl::operator-(), operator-=(), operator/(), cugl::operator==(), Point(), translate(), and cugl::Vector::Vector().
|
private |
Y coordinate of point.
Definition at line 365 of file cugl.h.
Referenced by cugl::Matrix::apply(), cugl::dist(), draw(), light(), cugl::operator*(), cugl::operator+(), operator+=(), cugl::operator-(), operator-=(), operator/(), cugl::operator==(), Point(), translate(), and cugl::Vector::Vector().
|
private |
Z coordinate of point.
Definition at line 368 of file cugl.h.
Referenced by cugl::Matrix::apply(), cugl::dist(), draw(), light(), cugl::operator*(), cugl::operator+(), operator+=(), cugl::operator-(), operator-=(), operator/(), cugl::operator==(), Point(), translate(), and cugl::Vector::Vector().