#include <CCGeometry.h>
Public Member Functions | |
Point () | |
Point (float x, float y) | |
Point (const Point &other) | |
Point (const Size &size) | |
Point & | operator= (const Point &other) |
Point & | operator= (const Size &size) |
Point | operator+ (const Point &right) const |
Point & | operator+= (const Point &right) |
Point | operator- (const Point &right) const |
Point & | operator-= (const Point &right) |
Point | operator- () const |
bool | operator== (const Point &right) |
bool | operator!= (const Point &right) |
bool | operator== (const Point &right) const |
bool | operator!= (const Point &right) const |
Point | operator* (float a) const |
Point | operator/ (float a) const |
void | setPoint (float x, float y) |
bool | equals (const Point &target) const |
bool | fuzzyEquals (const Point &target, float variance) const |
float | getLength () const |
Calculates distance between point an origin. More... | |
float | getLengthSq () const |
Calculates the square length of a Point (not calling sqrt() ) More... | |
float | getDistanceSq (const Point &other) const |
Calculates the square distance between two points (not calling sqrt() ) More... | |
float | getDistance (const Point &other) const |
Calculates the distance between two points. More... | |
float | getAngle () const |
float | getAngle (const Point &other) const |
float | dot (const Point &other) const |
Calculates dot product of two points. More... | |
float | cross (const Point &other) const |
Calculates cross product of two points. More... | |
Point | getPerp () const |
Calculates perpendicular of v, rotated 90 degrees counter-clockwise – cross(v, perp(v)) >= 0. More... | |
Point | getMidpoint (const Point &other) const |
Calculates midpoint between two points. More... | |
Point | getClampPoint (const Point &min_inclusive, const Point &max_inclusive) const |
Clamp a point between from and to. More... | |
Point | compOp (std::function< float(float)> function) const |
Run a math operation function on each point component absf, fllorf, ceilf, roundf any function that has the signature: float func(float); For example: let's try to take the floor of x,y p.compOp(floorf);. More... | |
Point | getRPerp () const |
Calculates perpendicular of v, rotated 90 degrees clockwise – cross(v, rperp(v)) <= 0. More... | |
Point | project (const Point &other) const |
Calculates the projection of this over other. More... | |
Point | rotate (const Point &other) const |
Complex multiplication of two points ("rotates" two points). More... | |
Point | unrotate (const Point &other) const |
Unrotates two points. More... | |
Point | normalize () const |
Returns point multiplied to a length of 1. More... | |
Point | lerp (const Point &other, float alpha) const |
Linear Interpolation between two points a and b. More... | |
Point | rotateByAngle (const Point &pivot, float angle) const |
Rotates a point counter clockwise by the angle around a pivot. More... | |
Static Public Member Functions | |
static Point | forAngle (const float a) |
static bool | isLineIntersect (const Point &A, const Point &B, const Point &C, const Point &D, float *S=nullptr, float *T=nullptr) |
A general line-line intersection test. More... | |
static bool | isLineOverlap (const Point &A, const Point &B, const Point &C, const Point &D) |
returns true if Line A-B overlap with segment C-D More... | |
static bool | isLineParallel (const Point &A, const Point &B, const Point &C, const Point &D) |
returns true if Line A-B parallel with segment C-D More... | |
static bool | isSegmentOverlap (const Point &A, const Point &B, const Point &C, const Point &D, Point *S=nullptr, Point *E=nullptr) |
returns true if Segment A-B overlap with segment C-D More... | |
static bool | isSegmentIntersect (const Point &A, const Point &B, const Point &C, const Point &D) |
returns true if Segment A-B intersects with segment C-D More... | |
static Point | getIntersectPoint (const Point &A, const Point &B, const Point &C, const Point &D) |
returns the intersection point of line A-B, C-D More... | |
Public Attributes | |
float | x |
float | y |
Static Public Attributes | |
static const Point | ZERO |
equals to Point(0,0) More... | |
static const Point | ANCHOR_MIDDLE |
equals to Point(0.5, 0.5) More... | |
static const Point | ANCHOR_BOTTOM_LEFT |
equals to Point(0, 0) More... | |
static const Point | ANCHOR_TOP_LEFT |
equals to Point(0, 1) More... | |
static const Point | ANCHOR_BOTTOM_RIGHT |
equals to Point(1, 0) More... | |
static const Point | ANCHOR_TOP_RIGHT |
equals to Point(1, 1) More... | |
static const Point | ANCHOR_MIDDLE_RIGHT |
equals to Point(1, 0.5) More... | |
static const Point | ANCHOR_MIDDLE_LEFT |
equals to Point(0, 0.5) More... | |
static const Point | ANCHOR_MIDDLE_TOP |
equals to Point(0.5, 1) More... | |
static const Point | ANCHOR_MIDDLE_BOTTOM |
equals to Point(0.5, 0) More... | |
Point | ( | ) |
Point | ( | float | x, |
float | y | ||
) |
|
inline |
Run a math operation function on each point component absf, fllorf, ceilf, roundf any function that has the signature: float func(float); For example: let's try to take the floor of x,y p.compOp(floorf);.
|
inline |
Calculates cross product of two points.
|
inline |
Calculates dot product of two points.
bool equals | ( | const Point & | target) | const |
|
inlinestatic |
bool fuzzyEquals | ( | const Point & | target, |
float | variance | ||
) | const |
|
inline |
float getAngle | ( | const Point & | other) | const |
Clamp a point between from and to.
|
inline |
Calculates the distance between two points.
|
inline |
Calculates the square distance between two points (not calling sqrt() )
|
static |
returns the intersection point of line A-B, C-D
|
inline |
Calculates distance between point an origin.
|
inline |
|
inline |
Calculates perpendicular of v, rotated 90 degrees counter-clockwise – cross(v, perp(v)) >= 0.
|
inline |
Calculates perpendicular of v, rotated 90 degrees clockwise – cross(v, rperp(v)) <= 0.
|
static |
A general line-line intersection test.
A | the startpoint for the first line L1 = (A - B) |
B | the endpoint for the first line L1 = (A - B) |
C | the startpoint for the second line L2 = (C - D) |
D | the endpoint for the second line L2 = (C - D) |
S | the range for a hitpoint in L1 (p = A + S*(B - A)) |
T | the range for a hitpoint in L2 (p = C + T*(D - C)) |
Note that to truly test intersection for segments we have to make sure that S & T lie within [0..1] and for rays, make sure S & T > 0 the hit point is C + T * (D - C); the hit point also is A + S * (B - A);
|
static |
returns true if Line A-B overlap with segment C-D
|
static |
returns true if Line A-B parallel with segment C-D
|
static |
returns true if Segment A-B intersects with segment C-D
|
static |
returns true if Segment A-B overlap with segment C-D
Linear Interpolation between two points a and b.
|
inline |
Returns point multiplied to a length of 1.
If the point is 0, it returns (1, 0)
bool operator!= | ( | const Point & | right) |
bool operator!= | ( | const Point & | right) | const |
Point operator* | ( | float | a) | const |
Point operator- | ( | ) | const |
Point operator/ | ( | float | a) | const |
bool operator== | ( | const Point & | right) |
bool operator== | ( | const Point & | right) | const |
Complex multiplication of two points ("rotates" two points).
Rotates a point counter clockwise by the angle around a pivot.
pivot | is the pivot, naturally |
angle | is the angle of rotation ccw in radians |
void setPoint | ( | float | x, |
float | y | ||
) |
Unrotates two points.
|
static |
equals to Point(0, 0)
|
static |
equals to Point(1, 0)
|
static |
equals to Point(0, 1)
|
static |
equals to Point(1, 1)
float x |
float y |
|
static |
equals to Point(0,0)