CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csPlane2 Class Reference
[Geometry utilities]

A plane in 2D space. More...

#include <plane2.h>

List of all members.

Public Methods

 csPlane2 ()
 Initialize to the xy plane.

 csPlane2 (const csVector2 &plane_norm, float c=0)
 Initialize the plane.

 csPlane2 (float a, float b, float c=0)
 Initialize the plane.

void Set (const csVector2 &v1, const csVector2 &v2)
 Initialize the plane given two vectors.

void Set (const csSegment2 &s)
 Initialize the plane given a segment.

 csPlane2 (const csVector2 &v1, const csVector2 &v2)
 Initialize the plane given two vectors.

 csPlane2 (const csSegment2 &s)
 Initialize the plane given a segment.

csVector2Normal ()
 Return the normal vector of this plane.

csVector2 GetNormal () const
 Return the normal vector of this plane (const version).

float A () const
 Return the A component of this plane.

float B () const
 Return the B component of this plane.

float C () const
 Return the C component of this plane.

float & A ()
 Return the A component of this plane.

float & B ()
 Return the B component of this plane.

float & C ()
 Return the C component of this plane.

void Set (float a, float b, float c)
 Set the value of the four plane components.

float Classify (const csVector2 &pt) const
 Classify the given vector with regards to this plane.

float Distance (const csVector2 &pt) const
 Compute the distance from the given vector to this plane.

float SquaredDistance (const csVector2 &pt) const
 Compute the squared distance between the given vector and this plane.

void Invert ()
 Reverses the direction of the plane while maintianing the plane itself.

void Normalize ()
 Normalizes the plane equation so that 'norm' is a unit vector.


Static Public Methods

float Classify (float A, float B, float C, const csVector2 &pt)
 Classify a vector with regards to three plane components.


Public Attributes

csVector2 norm
 The normal vector (or the (A,B) components).

float CC
 The C component of the plane.


Detailed Description

A plane in 2D space.

The plane is given by the equation AAx + BBy + CCz + DD = 0, Where (AA,BB,CC) is given by the vector 'norm'.

Definition at line 49 of file plane2.h.


Constructor & Destructor Documentation

csPlane2::csPlane2   [inline]
 

Initialize to the xy plane.

Definition at line 59 of file plane2.h.

References CC.

csPlane2::csPlane2 const csVector2   plane_norm,
float    c = 0
[inline]
 

Initialize the plane.

Definition at line 62 of file plane2.h.

References CC.

csPlane2::csPlane2 float    a,
float    b,
float    c = 0
[inline]
 

Initialize the plane.

Definition at line 65 of file plane2.h.

References CC.

csPlane2::csPlane2 const csVector2   v1,
const csVector2   v2
[inline]
 

Initialize the plane given two vectors.

Definition at line 82 of file plane2.h.

References Set().

csPlane2::csPlane2 const csSegment2   s [inline]
 

Initialize the plane given a segment.

Definition at line 88 of file plane2.h.

References Set().


Member Function Documentation

float& csPlane2::A   [inline]
 

Return the A component of this plane.

Definition at line 107 of file plane2.h.

References csVector2::x.

float csPlane2::A   const [inline]
 

Return the A component of this plane.

Definition at line 100 of file plane2.h.

References csVector2::x.

Referenced by Classify().

float& csPlane2::B   [inline]
 

Return the B component of this plane.

Definition at line 109 of file plane2.h.

References csVector2::y.

float csPlane2::B   const [inline]
 

Return the B component of this plane.

Definition at line 102 of file plane2.h.

References csVector2::y.

Referenced by Classify().

float& csPlane2::C   [inline]
 

Return the C component of this plane.

Definition at line 111 of file plane2.h.

References CC.

float csPlane2::C   const [inline]
 

Return the C component of this plane.

Definition at line 104 of file plane2.h.

References CC.

Referenced by Classify().

float csPlane2::Classify float    A,
float    B,
float    C,
const csVector2   pt
[inline, static]
 

Classify a vector with regards to three plane components.

Definition at line 121 of file plane2.h.

References A(), B(), C(), csVector2::x, and csVector2::y.

float csPlane2::Classify const csVector2   pt const [inline]
 

Classify the given vector with regards to this plane.

Definition at line 118 of file plane2.h.

References CC.

Referenced by Distance(), SquaredDistance(), and csMath2::Visible().

float csPlane2::Distance const csVector2   pt const [inline]
 

Compute the distance from the given vector to this plane.

This function assumes that 'norm' is a unit vector. If not, the function returns distance times the magnitude of 'norm'.

Definition at line 130 of file plane2.h.

References Classify().

csVector2 csPlane2::GetNormal   const [inline]
 

Return the normal vector of this plane (const version).

Definition at line 97 of file plane2.h.

void csPlane2::Invert   [inline]
 

Reverses the direction of the plane while maintianing the plane itself.

Definition at line 145 of file plane2.h.

References CC.

csVector2& csPlane2::Normal   [inline]
 

Return the normal vector of this plane.

Definition at line 94 of file plane2.h.

void csPlane2::Normalize   [inline]
 

Normalizes the plane equation so that 'norm' is a unit vector.

Definition at line 148 of file plane2.h.

References CC, and csVector2::Norm().

void csPlane2::Set float    a,
float    b,
float    c
[inline]
 

Set the value of the four plane components.

Definition at line 114 of file plane2.h.

References CC, csVector2::x, and csVector2::y.

void csPlane2::Set const csSegment2   s [inline]
 

Initialize the plane given a segment.

Definition at line 76 of file plane2.h.

References csSegment2::End(), Set(), and csSegment2::Start().

void csPlane2::Set const csVector2   v1,
const csVector2   v2
[inline]
 

Initialize the plane given two vectors.

Definition at line 68 of file plane2.h.

References CC, csVector2::x, and csVector2::y.

Referenced by csPlane2(), and Set().

float csPlane2::SquaredDistance const csVector2   pt const [inline]
 

Compute the squared distance between the given vector and this plane.

This function works even if the plane is not normalized. Note that the returned distance will be negative if the point is left of the plane and positive otherwise.

Definition at line 139 of file plane2.h.

References Classify(), and csVector2::SquaredNorm().


Member Data Documentation

float csPlane2::CC
 

The C component of the plane.

Definition at line 56 of file plane2.h.

Referenced by C(), Classify(), csPlane2(), Invert(), Normalize(), csIntersect2::PlaneNoTest(), csMath2::PlanesEqual(), and Set().

csVector2 csPlane2::norm
 

The normal vector (or the (A,B) components).

Definition at line 53 of file plane2.h.

Referenced by csIntersect2::PlaneNoTest(), and csMath2::PlanesEqual().


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.18