cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
CCPoint Class Reference

NA. More...

#include <CCGeometry.h>

Public Member Functions

 CCPoint ()
 
 CCPoint (float x, float y)
 
 CCPoint (const CCPoint &other)
 NA. More...
 
 CCPoint (const CCSize &size)
 NA. More...
 
CCPointoperator= (const CCPoint &other)
 NA. More...
 
CCPointoperator= (const CCSize &size)
 NA. More...
 
CCPoint operator+ (const CCPoint &right) const
 NA. More...
 
CCPoint operator- (const CCPoint &right) const
 NA. More...
 
CCPoint operator- () const
 NA. More...
 
CCPoint operator* (float a) const
 NA. More...
 
CCPoint operator/ (float a) const
 NA. More...
 
void setPoint (float x, float y)
 NA. More...
 
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...
 
float getDistance (const CCPoint &other) const
 Calculates the distance between two points. More...
 
float getAngle () const
 
float getAngle (const CCPoint &other) const
 
float dot (const CCPoint &other) const
 Calculates dot product of two points. More...
 
float cross (const CCPoint &other) const
 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...
 
CCPoint rotate (const CCPoint &other) const
 Complex multiplication of two points ("rotates" two points). More...
 
CCPoint unrotate (const CCPoint &other) const
 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...
 
CCPoint rotateByAngle (const CCPoint &pivot, float angle) const
 Rotates a point counter clockwise by the angle around a pivot. More...
 
CCPoint operator* (const CCPoint &right) const
 
CCPoint operator/ (const CCPoint &right) const
 

Static Public Member Functions

static CCPoint forAngle (const float a)
 

Public Attributes

float x
 
float y
 

Detailed Description

NA.

Constructor & Destructor Documentation

◆ CCPoint() [1/4]

CCPoint ( )

◆ CCPoint() [2/4]

CCPoint ( float  x,
float  y 
)

◆ CCPoint() [3/4]

CCPoint ( const CCPoint other)

NA.

◆ CCPoint() [4/4]

CCPoint ( const CCSize size)

NA.

Member Function Documentation

◆ cross()

float cross ( const CCPoint other) const
inline

Calculates cross product of two points.

Returns
float
Since
v2.1.4

◆ dot()

float dot ( const CCPoint other) const
inline

Calculates dot product of two points.

Returns
float
Since
v2.1.4

◆ equals()

bool equals ( const CCPoint target) const

◆ forAngle()

static CCPoint forAngle ( const float  a)
inlinestatic

◆ fuzzyEquals()

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 NA

◆ getAngle() [1/2]

float getAngle ( ) const
inline
Returns
the angle in radians between this vector and the x axis
Since
v2.1.4

◆ getAngle() [2/2]

float getAngle ( const CCPoint other) const
Returns
the angle in radians between two vector directions
Since
v2.1.4

◆ getDistance()

float getDistance ( const CCPoint other) const
inline

Calculates the distance between two points.

Returns
float
Since
v2.1.4

◆ getDistanceSq()

float getDistanceSq ( const CCPoint other) const
inline

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

Returns
float
Since
v2.1.4

◆ getLength()

float getLength ( ) const
inline

Calculates distance between point an origin.

Returns
float
Since
v2.1.4 NA

◆ getLengthSq()

float getLengthSq ( ) const
inline

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

Returns
float
Since
v2.1.4 NA

◆ getPerp()

CCPoint getPerp ( ) const
inline

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

Returns
CCPoint
Since
v2.1.4

◆ getRPerp()

CCPoint getRPerp ( ) const
inline

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

Returns
CCPoint
Since
v2.1.4

◆ lerp()

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

◆ normalize()

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

◆ operator*() [1/2]

CCPoint operator* ( const CCPoint right) const
inline
Remarks
Added by HJFod. See HJ_ADD for more info.

◆ operator*() [2/2]

CCPoint operator* ( float  a) const

NA.

◆ operator+()

CCPoint operator+ ( const CCPoint right) const

NA.

◆ operator-() [1/2]

CCPoint operator- ( ) const

NA.

◆ operator-() [2/2]

CCPoint operator- ( const CCPoint right) const

NA.

◆ operator/() [1/2]

CCPoint operator/ ( const CCPoint right) const
inline
Remarks
Added by HJFod. See HJ_ADD for more info.

◆ operator/() [2/2]

CCPoint operator/ ( float  a) const

NA.

◆ operator=() [1/2]

CCPoint & operator= ( const CCPoint other)

NA.

◆ operator=() [2/2]

CCPoint & operator= ( const CCSize size)

NA.

◆ project()

CCPoint project ( const CCPoint other) const
inline

Calculates the projection of this over other.

Returns
CCPoint
Since
v2.1.4

◆ rotate()

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

◆ rotateByAngle()

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

◆ setPoint()

void setPoint ( float  x,
float  y 
)

NA.

◆ unrotate()

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

Member Data Documentation

◆ x

float x

◆ y

float y

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