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

#include <CCGeometry.h>

Public Member Functions

 CCPoint ()
 CCPoint ()
 CCPoint (float x, float y)
 CCPoint ( local x, local y)
 CCPoint (const CCPoint &other)
 CCPoint (const CCSize &size)
CCPointoperator= (const CCPoint &other)
CCPointoperator= (const CCSize &size)
CCPoint operator+ (const CCPoint &right) const
CCPoint operator- (const CCPoint &right) const
CCPoint operator- () const
CCPoint operator* (float a) const
CCPoint operator/ (float a) const
void setPoint (float x, float y)
bool equals (const CCPoint &target) const
bool fuzzyEquals (const CCPoint &target, float variance) const
float getLength () const
 Calculates distance between point an origin. More...
 
float getLengthSq () const
 Calculates the square length of a CCPoint (not calling sqrt() ) More...
 
float getDistanceSq (const CCPoint &other) const
 Calculates the square distance between two points (not calling sqrt() ) More...
 
local getDistanceSq ( local other)
 Calculates the square distance between two points (not calling sqrt() ) More...
 
float getDistance (const CCPoint &other) const
 Calculates the distance between two points. More...
 
float getAngle () const
float getAngle (const CCPoint &other) const
local getAngle ( local other)
float dot (const CCPoint &other) const
 Calculates dot product of two points. More...
 
local dot ( local other)
 Calculates dot product of two points. More...
 
float cross (const CCPoint &other) const
 Calculates cross product of two points. More...
 
local cross ( local other)
 Calculates cross product of two points. More...
 
CCPoint getPerp () const
 Calculates perpendicular of v, rotated 90 degrees counter-clockwise – cross(v, perp(v)) >= 0. More...
 
CCPoint getRPerp () const
 Calculates perpendicular of v, rotated 90 degrees clockwise – cross(v, rperp(v)) <= 0. More...
 
CCPoint project (const CCPoint &other) const
 Calculates the projection of this over other. More...
 
local project ( local other)
 Calculates the projection of this over other. More...
 
CCPoint rotate (const CCPoint &other) const
 Complex multiplication of two points ("rotates" two points). More...
 
local rotate ( local other)
 Complex multiplication of two points ("rotates" two points). More...
 
CCPoint unrotate (const CCPoint &other) const
 Unrotates two points. More...
 
local unrotate ( local other)
 Unrotates two points. More...
 
CCPoint normalize () const
 Returns point multiplied to a length of 1. More...
 
CCPoint lerp (const CCPoint &other, float alpha) const
 Linear Interpolation between two points a and b. More...
 
local lerp ( local other, local alpha)
 Linear Interpolation between two points a and b. More...
 
CCPoint rotateByAngle (const CCPoint &pivot, float angle) const
 Rotates a point counter clockwise by the angle around a pivot. More...
 

Static Public Member Functions

static CCPoint forAngle (const float a)

Public Attributes

float x
local x
float y
local y

Constructor & Destructor Documentation

CCPoint ( )
local CCPoint ( )
CCPoint ( float  x,
float  y 
)
local CCPoint ( local  x,
local  y 
)
CCPoint ( const CCPoint other)
CCPoint ( const CCSize size)

Member Function Documentation

float cross ( const CCPoint other) const
inline

Calculates cross product of two points.

Returns
float
Since
v2.1.4
local cross ( local  other)
inline

Calculates cross product of two points.

Returns
float
Since
v2.1.4
float dot ( const CCPoint other) const
inline

Calculates dot product of two points.

Returns
float
Since
v2.1.4
local dot ( local  other)
inline

Calculates dot product of two points.

Returns
float
Since
v2.1.4
bool equals ( const CCPoint target) const
local equals ( local  target)
static CCPoint forAngle ( const float  a)
inlinestatic
local forAngle ( local  a)
inlinestatic
bool fuzzyEquals ( const CCPoint target,
float  variance 
) const
Returns
if points have fuzzy equality which means equal with some degree of variance.
Since
v2.1.4
float getAngle ( ) const
inline
Returns
the angle in radians between this vector and the x axis
Since
v2.1.4
local getAngle ( )
inline
Returns
the angle in radians between this vector and the x axis
Since
v2.1.4
float getAngle ( const CCPoint other) const
Returns
the angle in radians between two vector directions
Since
v2.1.4
local getAngle ( local  other)
Returns
the angle in radians between two vector directions
Since
v2.1.4
float getDistance ( const CCPoint other) const
inline

Calculates the distance between two points.

Returns
float
Since
v2.1.4
local getDistance ( local  other)
inline

Calculates the distance between two points.

Returns
float
Since
v2.1.4
float getDistanceSq ( const CCPoint other) const
inline

Calculates the square distance between two points (not calling sqrt() )

Returns
float
Since
v2.1.4
local getDistanceSq ( local  other)
inline

Calculates the square distance between two points (not calling sqrt() )

Returns
float
Since
v2.1.4
float getLength ( ) const
inline

Calculates distance between point an origin.

Returns
float
Since
v2.1.4
float getLengthSq ( ) const
inline

Calculates the square length of a CCPoint (not calling sqrt() )

Returns
float
Since
v2.1.4
CCPoint getPerp ( ) const
inline

Calculates perpendicular of v, rotated 90 degrees counter-clockwise – cross(v, perp(v)) >= 0.

Returns
CCPoint
Since
v2.1.4
local getPerp ( )
inline

Calculates perpendicular of v, rotated 90 degrees counter-clockwise – cross(v, perp(v)) >= 0.

Returns
CCPoint
Since
v2.1.4
CCPoint getRPerp ( ) const
inline

Calculates perpendicular of v, rotated 90 degrees clockwise – cross(v, rperp(v)) <= 0.

Returns
CCPoint
Since
v2.1.4
local getRPerp ( )
inline

Calculates perpendicular of v, rotated 90 degrees clockwise – cross(v, rperp(v)) <= 0.

Returns
CCPoint
Since
v2.1.4
CCPoint lerp ( const CCPoint other,
float  alpha 
) const
inline

Linear Interpolation between two points a and b.

Returns
alpha == 0 ? a alpha == 1 ? b otherwise a value between a..b
Since
v2.1.4
local lerp ( local  other,
local  alpha 
)
inline

Linear Interpolation between two points a and b.

Returns
alpha == 0 ? a alpha == 1 ? b otherwise a value between a..b
Since
v2.1.4
CCPoint normalize ( ) const
inline

Returns point multiplied to a length of 1.

If the point is 0, it returns (1, 0)

Returns
CCPoint
Since
v2.1.4
local normalize ( )
inline

Returns point multiplied to a length of 1.

If the point is 0, it returns (1, 0)

Returns
CCPoint
Since
v2.1.4
CCPoint operator* ( float  a) const
CCPoint operator+ ( const CCPoint right) const
CCPoint operator- ( const CCPoint right) const
CCPoint operator- ( ) const
CCPoint operator/ ( float  a) const
CCPoint& operator= ( const CCPoint other)
CCPoint& operator= ( const CCSize size)
CCPoint project ( const CCPoint other) const
inline

Calculates the projection of this over other.

Returns
CCPoint
Since
v2.1.4
local project ( local  other)
inline

Calculates the projection of this over other.

Returns
CCPoint
Since
v2.1.4
CCPoint rotate ( const CCPoint other) const
inline

Complex multiplication of two points ("rotates" two points).

Returns
CCPoint vector with an angle of this.getAngle() + other.getAngle(), and a length of this.getLength() * other.getLength().
Since
v2.1.4
local rotate ( local  other)
inline

Complex multiplication of two points ("rotates" two points).

Returns
CCPoint vector with an angle of this.getAngle() + other.getAngle(), and a length of this.getLength() * other.getLength().
Since
v2.1.4
CCPoint rotateByAngle ( const CCPoint pivot,
float  angle 
) const

Rotates a point counter clockwise by the angle around a pivot.

Parameters
pivotis the pivot, naturally
angleis the angle of rotation ccw in radians
Returns
the rotated point
Since
v2.1.4
local rotateByAngle ( local  pivot,
local  angle 
)

Rotates a point counter clockwise by the angle around a pivot.

Parameters
pivotis the pivot, naturally
angleis the angle of rotation ccw in radians
Returns
the rotated point
Since
v2.1.4
void setPoint ( float  x,
float  y 
)
CCPoint unrotate ( const CCPoint other) const
inline

Unrotates two points.

Returns
CCPoint vector with an angle of this.getAngle() - other.getAngle(), and a length of this.getLength() * other.getLength().
Since
v2.1.4
local unrotate ( local  other)
inline

Unrotates two points.

Returns
CCPoint vector with an angle of this.getAngle() - other.getAngle(), and a length of this.getLength() * other.getLength().
Since
v2.1.4

Member Data Documentation

float x
local x
float y
local y

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