CUGL  2.0
Public Member Functions | Private Attributes | Friends | List of all members
cugl::Plane Class Reference

#include <cugl.h>

Public Member Functions

 Plane (GLfloat a=0, GLfloat b=1, GLfloat c=0, GLfloat d=0)
 
 Plane (const Point &p, const Point &q, const Point &r)
 
 Plane (const Line &s, const Point &p)
 
 Plane (const Vector &v, const Point &p)
 
void normalize ()
 
Plane unit () const
 
Vector normal () const
 
void clipPlane (GLenum index) const
 
GLfloat getA ()
 
GLfloat getB ()
 
GLfloat getC ()
 
GLfloat getD ()
 

Private Attributes

GLfloat a
 
GLfloat b
 
GLfloat c
 
GLfloat d
 

Friends

class Matrix
 
Point meet (const Line &k, const Plane &p)
 
bool operator== (const Plane &x, const Plane &y)
 
bool operator!= (const Plane &x, const Plane &y)
 
std::ostream & operator<< (std::ostream &os, const Plane &p)
 
GLfloat dist (const Point &p, const Plane &s)
 
GLfloat dist (const Plane &s, const Point &p)
 

Detailed Description

An instance is a plane defined by its equation Ax+By+Cz+D=0.

Planes are used for clipping, shadows, and reflections (see class Matrix).

Homogeneous points (x,y,z,w) lie on the plane if Ax+By+Cz+Dw=0. The notation for a plane is <A,B,C,D>. The plane <0,0,0,D> is undefined. An attempt to construct such a plane sets the error flag to BAD_PLANE and the plane is set to <0,1,0,0> (in the conventional OpenGL frame, this often corresponds to the ground, y=0).

A Plane is in normal form if the Vector (A,B,C) is a unit vector. A Plane can be normalized by scaling A,B,C,D.

Definition at line 458 of file cugl.h.

Constructor & Destructor Documentation

cugl::Plane::Plane ( GLfloat  a = 0,
GLfloat  b = 1,
GLfloat  c = 0,
GLfloat  d = 0 
)

Construct a plane given the coefficients of its equation Ax+By+Cx+D=0. If no arguments are provided, construct the plane y = 0.

cugl::Plane::Plane ( const Point p,
const Point q,
const Point r 
)

Construct a plane containing the three given points.

cugl::Plane::Plane ( const Line s,
const Point p 
)

Construct a plane containing the line s and the point p.

cugl::Plane::Plane ( const Vector v,
const Point p 
)

Construct the plane orthogonal to v and passing through p.

Member Function Documentation

void cugl::Plane::clipPlane ( GLenum  index) const

Use this plane as a clipping plane. This function calls glClipPlane to suppress rendering of objects on one side of the plane.

Parameters
indexmust be one of GL_CLIP_PLANE0, GL_CLIP_PLANE1, ... A An implementation of OpenGL is supposed to provide at least six clipping planes, numbered 0,1,...,5.
GLfloat cugl::Plane::getA ( )
inline

Return the A component of the plane defined by Ax+By+Cz+d=0.

Definition at line 566 of file cugl.h.

References a.

GLfloat cugl::Plane::getB ( )
inline

Return the B component of the plane defined by Ax+By+Cz+d=0.

Definition at line 569 of file cugl.h.

References b.

GLfloat cugl::Plane::getC ( )
inline

Return the C component of the plane defined by Ax+By+Cz+d=0.

Definition at line 572 of file cugl.h.

References c.

GLfloat cugl::Plane::getD ( )
inline

Return the D component of the plane defined by Ax+By+Cz+d=0.

Definition at line 575 of file cugl.h.

References d.

Vector cugl::Plane::normal ( ) const
inline

Return a vector of unit length that is normal to the plane.

Definition at line 2710 of file cugl.h.

References a, b, c, and cugl::Vector::unit().

void cugl::Plane::normalize ( )

Normalize this plane. The Plane (A,B,C,D) is in normal form when (A,B,C) is a unit vector. Error ZERO_DIVISOR reported if |(A,B,C|=0 (which should not be the case for a well-formed plane).

Note
The value of the Plane is changed by this function.
Plane cugl::Plane::unit ( ) const

Return a normalized Plane equivalent to this plane. The Plane (A,B,C,D) is in normal form when (A,B,C) is a unit vector. Error ZERO_DIVISOR reported if |(A,B,C|=0 (which should not be the case for a well-formed plane).

Friends And Related Function Documentation

GLfloat dist ( const Point p,
const Plane s 
)
friend

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.

Definition at line 2673 of file cugl.h.

GLfloat dist ( const Plane s,
const Point p 
)
friend

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.

Definition at line 2678 of file cugl.h.

Point meet ( const Line k,
const Plane p 
)
friend

Find the point where this line meets the plane p.

bool operator!= ( const Plane x,
const Plane y 
)
friend

Compare two planes. This function returns false only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2722 of file cugl.h.

std::ostream& operator<< ( std::ostream &  os,
const Plane p 
)
friend

Write a description of the plane to the output stream as <a,b,c,d>. Inserts the components of the plane into the output stream os in the format <a,b,c,d>. The current settings of the stream formatting parameters are used. If a width is specified with setw(), it is applied to each component rather than to the plane as a whole.

bool operator== ( const Plane x,
const Plane y 
)
friend

Compare two planes. This function returns true only if corresponding components are exactly equal. Values that are theoretically equal but computed in different ways are likely to be unequal according to this function.

Definition at line 2717 of file cugl.h.

Member Data Documentation

GLfloat cugl::Plane::a
private

Coefficient of x in the plane equation.

Definition at line 580 of file cugl.h.

Referenced by cugl::dist(), getA(), normal(), and cugl::operator==().

GLfloat cugl::Plane::b
private

Coefficient of y in the plane equation.

Definition at line 583 of file cugl.h.

Referenced by cugl::dist(), getB(), normal(), and cugl::operator==().

GLfloat cugl::Plane::c
private

Coefficient of z in the plane equation.

Definition at line 586 of file cugl.h.

Referenced by cugl::dist(), getC(), normal(), and cugl::operator==().

GLfloat cugl::Plane::d
private

Coefficient of w in the plane equation.

Definition at line 589 of file cugl.h.

Referenced by cugl::dist(), getD(), and cugl::operator==().


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