# cugl::Plane Class Reference

`#include <cugl.h>`

List of all members.

## Public Member Functions

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

GLfloat a
GLfloat b
GLfloat c
GLfloat d

## Friends

class Matrix
Point meet (Line &k, Plane &p)
bool operator== (const Plane &x, const Plane &y)
bool operator!= (const Plane &x, const Plane &y)
std::ostream & operator<< (std::ostream &os, 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+Cx+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 432 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 ( Point & p, Point & q, Point & r )

Construct a plane containing the three given points.

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

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

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

Construct the plane orthogonal to `v` and passing through `p`.

## Member Function Documentation

 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).

 Vector cugl::Plane::normal ( ) const` [inline]`

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

Definition at line 2531 of file cugl.h.

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

 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:
 index must 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.

## Friends And Related Function Documentation

 Point meet ( Line & k, 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 `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 2538 of file cugl.h.

 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 2543 of file cugl.h.

 std::ostream& operator<< ( std::ostream & os, 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.

 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 2494 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 2499 of file cugl.h.

## Member Data Documentation

 GLfloat cugl::Plane::a` [private]`

Coefficient of x in the plane equation.

Definition at line 542 of file cugl.h.

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

 GLfloat cugl::Plane::b` [private]`

Coefficient of y in the plane equation.

Definition at line 545 of file cugl.h.

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

 GLfloat cugl::Plane::c` [private]`

Coefficient of z in the plane equation.

Definition at line 548 of file cugl.h.

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

 GLfloat cugl::Plane::d` [private]`

Coefficient of w in the plane equation.

Definition at line 551 of file cugl.h.

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

The documentation for this class was generated from the following file:
Generated on Wed Sep 12 14:31:42 2007 for CUGL by  1.5.2