cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PUPlane Class Reference

Defines a plane in 3D space. More...

#include <CCPUPlane.h>

Public Types

enum  Side { NO_SIDE, POSITIVE_SIDE, NEGATIVE_SIDE, BOTH_SIDE }
 The "positive side" of the plane is the half space to which the plane normal points. More...
 

Public Member Functions

 PUPlane ()
 Default constructor - sets everything to 0. More...
 
 PUPlane (const PUPlane &rhs)
 PUPlane (const Vec3 &rkNormal, float fConstant)
 Construct a plane through a normal, and a distance to move the plane along the normal. More...
 
 PUPlane (float a, float b, float c, float d)
 Construct a plane using the 4 constants directly. More...
 
 PUPlane (const Vec3 &rkNormal, const Vec3 &rkPoint)
 PUPlane (const Vec3 &rkPoint0, const Vec3 &rkPoint1, const Vec3 &rkPoint2)
float getDistance (const Vec3 &rkPoint) const
 Returns the side where the alignedBox is. More...
 
void redefine (const Vec3 &rkPoint0, const Vec3 &rkPoint1, const Vec3 &rkPoint2)
 Redefine this plane based on 3 points. More...
 
void redefine (const Vec3 &rkNormal, const Vec3 &rkPoint)
 Redefine this plane based on a normal and a point. More...
 
Vec3 projectVector (const Vec3 &v) const
 Project a vector onto the plane. More...
 
float normalize (void)
 Normalises the plane. More...
 
bool operator== (const PUPlane &rhs) const
 Comparison operator. More...
 
bool operator!= (const PUPlane &rhs) const

Public Attributes

Vec3 normal
float d

Detailed Description

Defines a plane in 3D space.

Remarks
A plane is defined in 3D space by the equation Ax + By + Cz + D = 0
This equates to a vector (the normal of the plane, whose x, y and z components equate to the coefficients A, B and C respectively), and a constant (D) which is the distance along the normal you have to go to move the plane back to the origin.

Member Enumeration Documentation

enum Side

The "positive side" of the plane is the half space to which the plane normal points.

The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Enumerator
NO_SIDE 
POSITIVE_SIDE 
NEGATIVE_SIDE 
BOTH_SIDE 
var Side

The "positive side" of the plane is the half space to which the plane normal points.

The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Enumerator
NO_SIDE 
POSITIVE_SIDE 
NEGATIVE_SIDE 
BOTH_SIDE 
local Side

The "positive side" of the plane is the half space to which the plane normal points.

The "negative side" is the other half space. The flag "no side" indicates the plane itself.

Enumerator
NO_SIDE 
POSITIVE_SIDE 
NEGATIVE_SIDE 
BOTH_SIDE 

Constructor & Destructor Documentation

PUPlane ( )

Default constructor - sets everything to 0.

var PUPlane ( )

Default constructor - sets everything to 0.

local PUPlane ( )

Default constructor - sets everything to 0.

PUPlane ( const PUPlane rhs)
var PUPlane ( var  rhs)
local PUPlane ( local  rhs)
PUPlane ( const Vec3 rkNormal,
float  fConstant 
)

Construct a plane through a normal, and a distance to move the plane along the normal.

var PUPlane ( var  rkNormal,
var  fConstant 
)

Construct a plane through a normal, and a distance to move the plane along the normal.

local PUPlane ( local  rkNormal,
local  fConstant 
)

Construct a plane through a normal, and a distance to move the plane along the normal.

PUPlane ( float  a,
float  b,
float  c,
float  d 
)

Construct a plane using the 4 constants directly.

var PUPlane ( var  a,
var  b,
var  c,
var  d 
)

Construct a plane using the 4 constants directly.

local PUPlane ( local  a,
local  b,
local  c,
local  d 
)

Construct a plane using the 4 constants directly.

PUPlane ( const Vec3 rkNormal,
const Vec3 rkPoint 
)
var PUPlane ( var  rkNormal,
var  rkPoint 
)
local PUPlane ( local  rkNormal,
local  rkPoint 
)
PUPlane ( const Vec3 rkPoint0,
const Vec3 rkPoint1,
const Vec3 rkPoint2 
)
var PUPlane ( var  rkPoint0,
var  rkPoint1,
var  rkPoint2 
)
local PUPlane ( local  rkPoint0,
local  rkPoint1,
local  rkPoint2 
)

Member Function Documentation

float getDistance ( const Vec3 rkPoint) const

Returns the side where the alignedBox is.

The flag BOTH_SIDE indicates an intersecting box. One corner ON the plane is sufficient to consider the box and the plane intersecting. Returns which side of the plane that the given box lies on. The box is defined as centre/half-size pairs for effectively.

Parameters
centreThe centre of the box.
halfSizeThe half-size of the box.
Returns
POSITIVE_SIDE if the box complete lies on the "positive side" of the plane, NEGATIVE_SIDE if the box complete lies on the "negative side" of the plane, and BOTH_SIDE if the box intersects the plane.This is a pseudodistance. The sign of the return value is positive if the point is on the positive side of the plane, negative if the point is on the negative side, and zero if the point is on the plane.
The absolute value of the return value is the true distance only when the plane normal is a unit length vector.
var getDistance ( var  rkPoint)

Returns the side where the alignedBox is.

The flag BOTH_SIDE indicates an intersecting box. One corner ON the plane is sufficient to consider the box and the plane intersecting. Returns which side of the plane that the given box lies on. The box is defined as centre/half-size pairs for effectively.

Parameters
centreThe centre of the box.
halfSizeThe half-size of the box.
Returns
POSITIVE_SIDE if the box complete lies on the "positive side" of the plane, NEGATIVE_SIDE if the box complete lies on the "negative side" of the plane, and BOTH_SIDE if the box intersects the plane.This is a pseudodistance. The sign of the return value is positive if the point is on the positive side of the plane, negative if the point is on the negative side, and zero if the point is on the plane.
The absolute value of the return value is the true distance only when the plane normal is a unit length vector.
local getDistance ( local  rkPoint)

Returns the side where the alignedBox is.

The flag BOTH_SIDE indicates an intersecting box. One corner ON the plane is sufficient to consider the box and the plane intersecting. Returns which side of the plane that the given box lies on. The box is defined as centre/half-size pairs for effectively.

Parameters
centreThe centre of the box.
halfSizeThe half-size of the box.
Returns
POSITIVE_SIDE if the box complete lies on the "positive side" of the plane, NEGATIVE_SIDE if the box complete lies on the "negative side" of the plane, and BOTH_SIDE if the box intersects the plane.This is a pseudodistance. The sign of the return value is positive if the point is on the positive side of the plane, negative if the point is on the negative side, and zero if the point is on the plane.
The absolute value of the return value is the true distance only when the plane normal is a unit length vector.
float normalize ( void  )

Normalises the plane.

Remarks
This method normalises the plane's normal and the length scale of d is as well.
Note
This function will not crash for zero-sized vectors, but there will be no changes made to their components.
Returns
The previous length of the plane's normal.
var normalize (   )

Normalises the plane.

Remarks
This method normalises the plane's normal and the length scale of d is as well.
Note
This function will not crash for zero-sized vectors, but there will be no changes made to their components.
Returns
The previous length of the plane's normal.
local normalize (   )

Normalises the plane.

Remarks
This method normalises the plane's normal and the length scale of d is as well.
Note
This function will not crash for zero-sized vectors, but there will be no changes made to their components.
Returns
The previous length of the plane's normal.
bool operator!= ( const PUPlane rhs) const
inline
bool operator!= ( var  rhs)
inline
bool operator!= ( local  rhs)
inline
bool operator== ( const PUPlane rhs) const
inline

Comparison operator.

bool operator== ( var  rhs)
inline

Comparison operator.

bool operator== ( local  rhs)
inline

Comparison operator.

Vec3 projectVector ( const Vec3 v) const

Project a vector onto the plane.

Remarks
This gives you the element of the input vector that is perpendicular to the normal of the plane. You can get the element which is parallel to the normal of the plane by subtracting the result of this method from the original vector, since parallel + perpendicular = original.
Parameters
vThe input vector
var projectVector ( var  v)

Project a vector onto the plane.

Remarks
This gives you the element of the input vector that is perpendicular to the normal of the plane. You can get the element which is parallel to the normal of the plane by subtracting the result of this method from the original vector, since parallel + perpendicular = original.
Parameters
vThe input vector
local projectVector ( local  v)

Project a vector onto the plane.

Remarks
This gives you the element of the input vector that is perpendicular to the normal of the plane. You can get the element which is parallel to the normal of the plane by subtracting the result of this method from the original vector, since parallel + perpendicular = original.
Parameters
vThe input vector
void redefine ( const Vec3 rkPoint0,
const Vec3 rkPoint1,
const Vec3 rkPoint2 
)

Redefine this plane based on 3 points.

var redefine ( var  rkPoint0,
var  rkPoint1,
var  rkPoint2 
)

Redefine this plane based on 3 points.

local redefine ( local  rkPoint0,
local  rkPoint1,
local  rkPoint2 
)

Redefine this plane based on 3 points.

void redefine ( const Vec3 rkNormal,
const Vec3 rkPoint 
)

Redefine this plane based on a normal and a point.

var redefine ( var  rkNormal,
var  rkPoint 
)

Redefine this plane based on a normal and a point.

local redefine ( local  rkNormal,
local  rkPoint 
)

Redefine this plane based on a normal and a point.

Member Data Documentation

float d
var d
local d
Vec3 normal

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