#import <CoreGraphics/CGGeometry.h>#import <math.h>

Go to the source code of this file.
Defines | |
| #define | ccp(__X__, __Y__) CGPointMake(__X__,__Y__) |
Functions | |
| static CGPoint | ccpNeg (const CGPoint v) |
| static CGPoint | ccpAdd (const CGPoint v1, const CGPoint v2) |
| static CGPoint | ccpSub (const CGPoint v1, const CGPoint v2) |
| static CGPoint | ccpMult (const CGPoint v, const CGFloat s) |
| static CGPoint | ccpMidpoint (const CGPoint v1, const CGPoint v2) |
| static CGFloat | ccpDot (const CGPoint v1, const CGPoint v2) |
| static CGFloat | ccpCross (const CGPoint v1, const CGPoint v2) |
| static CGPoint | ccpPerp (const CGPoint v) |
| static CGPoint | ccpRPerp (const CGPoint v) |
| static CGPoint | ccpProject (const CGPoint v1, const CGPoint v2) |
| static CGPoint | ccpRotate (const CGPoint v1, const CGPoint v2) |
| static CGPoint | ccpUnrotate (const CGPoint v1, const CGPoint v2) |
| static CGFloat | ccpLengthSQ (const CGPoint v) |
| CGFloat | ccpLength (const CGPoint v) |
| CGFloat | ccpDistance (const CGPoint v1, const CGPoint v2) |
| CGPoint | ccpNormalize (const CGPoint v) |
| CGPoint | ccpForAngle (const CGFloat a) |
| CGFloat | ccpToAngle (const CGPoint v) |
CGPoint extensions based on Chipmunk's cpVect file. These extensions work both with CGPoint and cpVect.
The "ccp" prefix means: "CoCos2d Point"
Examples:
Definition in file CGPointExtension.h.
| #define ccp | ( | __X__, | |||
| __Y__ | ) | CGPointMake(__X__,__Y__) |
Helper macro that creates a CGPoint
Definition at line 57 of file CGPointExtension.h.
| static CGPoint ccpAdd | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Calculates sum of two points.
Definition at line 75 of file CGPointExtension.h.
| static CGFloat ccpCross | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Calculates cross product of two points.
Definition at line 125 of file CGPointExtension.h.
| CGFloat ccpDistance | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) |
Calculates the distance between two points
| static CGFloat ccpDot | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Calculates dot product of two points.
Definition at line 115 of file CGPointExtension.h.
| CGPoint ccpForAngle | ( | const CGFloat | a | ) |
Converts radians to a normalized vector.
| CGFloat ccpLength | ( | const CGPoint | v | ) |
Calculates distance between point an origin
| static CGFloat ccpLengthSQ | ( | const CGPoint | v | ) | [inline, static] |
Calculates the square length of a CGPoint (not calling sqrt() )
Definition at line 185 of file CGPointExtension.h.
| static CGPoint ccpMidpoint | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Calculates midpoint between two points.
Definition at line 105 of file CGPointExtension.h.
| static CGPoint ccpMult | ( | const CGPoint | v, | |
| const CGFloat | s | |||
| ) | [inline, static] |
Returns point multiplied by given factor.
Definition at line 95 of file CGPointExtension.h.
| static CGPoint ccpNeg | ( | const CGPoint | v | ) | [inline, static] |
Returns opposite of point.
Definition at line 65 of file CGPointExtension.h.
| CGPoint ccpNormalize | ( | const CGPoint | v | ) |
Returns point multiplied to a length of 1.
| static CGPoint ccpPerp | ( | const CGPoint | v | ) | [inline, static] |
Calculates perpendicular of v, rotated 90 degrees counter-clockwise -- cross(v, perp(v)) >= 0
Definition at line 135 of file CGPointExtension.h.
| static CGPoint ccpProject | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Calculates the projection of v1 over v2.
Definition at line 155 of file CGPointExtension.h.
| static CGPoint ccpRotate | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
| static CGPoint ccpRPerp | ( | const CGPoint | v | ) | [inline, static] |
Calculates perpendicular of v, rotated 90 degrees clockwise -- cross(v, rperp(v)) <= 0
Definition at line 145 of file CGPointExtension.h.
| static CGPoint ccpSub | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Calculates difference of two points.
Definition at line 85 of file CGPointExtension.h.
| CGFloat ccpToAngle | ( | const CGPoint | v | ) |
Converts a vector to radians.
| static CGPoint ccpUnrotate | ( | const CGPoint | v1, | |
| const CGPoint | v2 | |||
| ) | [inline, static] |
Unrotates two points.
Definition at line 175 of file CGPointExtension.h.
1.6.1