Mathematical functions:
- Ccp (x, y); // create a vector ccpFromSize (s) with coordinates x and y; // create a vector with the width of size s as x and height as y
Addition, subtraction, multiplication, division, and operation of CCPoint
- CcpAdd (v1, v2); // equivalent ccp (v1.x + v2.x, v1.y + v2.y); ccpSub (v1, v2); // equivalent ccp (v1.x-v2.x, v1.y-v2.y );
- CcpNeg (v) // equivalent ccp (-v. x,-v. y); ccpMult (v, s); // equivalent ccp (v. x * s, v. y * s); s is a floating point number.
Midpoint:
- CcpMidpoint (v1, v2); // equivalent ccp (v1.x + v2.x)/2, (v1.y + v2.y)/2 );
Dot multiplication, cross multiplication, and projection:
- CcpDot (v1, v2); // equivalent v1.x * v2.x + v1.y * v2.y; ccpCross (v1, v2); // equivalent v1.x * v2.y-v1.y * v2.x;
- CcpProject (v1, v2) // returns the projection vector of vector v1 on vector v2.
Evaluate the length, distance, and their square values:
- CcpLength (v) // return vector v length, that is, the square of the length from vertex v to the origin point ccpLengthSQ (v) // return vector v, that is, the square of the distance from vertex v to the origin point
- CcpDistance (v1, v2) // returns the square of the distance from v1 to v2 to ccpDistanceSQ (v1, v2) // returns the square of the distance from v1 to v2.
- CcpNormalize (v) // returns the standardized vector of v, that is, the length is 1
Rotate, 90 degrees clockwise, 90 degrees clockwise:
- CcpRotate (v1, v2); // vector v1 rotates the angle of vector v2 and multiplied by the length of vector v2. When v2 is a standard vector with a length of 1, it is normal rotation. It can be used together with ccpForAngle ccpPerp (v); // equivalent to ccp (-v. y, v. x); (because the opengl coordinate system is the origin in the lower left corner, the vector v is rotated 90 degrees counterclockwise)
- CcpRPerp (v); // equivalent to ccp (v. y,-v. x); Rotate 90 degrees clockwise
The supported conversion vectors include vectors and radians. There are also some angle-related vectors:
- CcpForAngle (a); // returns a standard vector ccpToAngle (v) with an angle of radians a; // returns the radians of a vector v.
- CcpAngle (a, B); // returns the radian value of the difference between the and B vectors indicating the angle ccpRotateByAngle (v, cosine, angle) // returns the vector v with degrees as the rotation axis point, rotate angle radians counterclockwise
Detection of intersection of line segments:
- CcpLineIntersect (p1, p2, p3, p4, & s, & t ); // returns whether the straight line where p1 is the start point p2 is the end line 1 and p3 is the start point p4 is the end line 2. If yes, parameters s and t return the ratio of the intersection online segment 1 and Line Segment 2. // The ratio of s and t can be obtained through p1 + s * (p2-p1) or p3 + t * (p4-p3.
- CcpSegmentIntersect (A, B c, D) // returns the intersection of A line A-B and A line C-D ccpIntersectPoint (A, B, C, D) // returns the intersection of A line A-B and A line C-D
Other useful:
- CC_RADIANS_TO_DEGREES (a); // radian conversion angle CC_DEGREES_TO_RADIANS (a); // converts degrees to radians CCRANDOM_0_1 (); // generates random floating point numbers between 0 and 1.
- CCRANDOM_MINUS1_1 (); // generates a random floating point number between-1 and 1.