![]() |
Gorgon Game Engine
|
This class represents a 2D point. More...
Public Types | |
| typedef T_ | BaseType |
| Base type of the point elements. More... | |
Public Member Functions | |
| basic_Point () | |
| Default constructor, does not zero initialize point. More... | |
| template<class O_ > | |
| basic_Point (const basic_Point< O_ > &point) | |
| Conversion from a different point type. More... | |
| basic_Point (const std::string &str) | |
| Conversion from string. More... | |
| basic_Point (const T_ &X, const T_ &Y) | |
| Filling constructor. More... | |
| Float | Angle () const |
| Calculates the angle of the line formed from the origin to this point. More... | |
| Float | Angle (const basic_Point &origin) const |
| Calculates the angle of the line formed from the given point to this point. More... | |
| bool | Compare (const basic_Point &point) const |
| Compares two points. More... | |
| T_ | CrossProduct (const basic_Point< T_ > &value) const |
| Calculates cross product of two points. More... | |
| Float | Distance () const |
| Calculates Euclidean distance from this point to origin. More... | |
| Float | Distance (const basic_Point &target) const |
| Calculates Euclidean distance from this point to the given target. More... | |
| T_ | DotProduct (const basic_Point< T_ > &value) const |
| Calculates dot product of two points. More... | |
| Float | EuclideanSquare () const |
| Calculates EuclideanSquare distance from this point to the given target. More... | |
| Float | EuclideanSquare (const basic_Point &target) const |
| Calculates EuclideanSquare distance from this point to the given target. More... | |
| Float | ManhattanDistance () const |
| Calculates Manhattan distance from this point to origin. More... | |
| Float | ManhattanDistance (const basic_Point &target) const |
| Calculates Manhattan distance from this point to the given target. More... | |
| void | Move (const T_ &x, const T_ &y) |
| Moves this point to the given coordinates. More... | |
| basic_Point | Normalize () const |
| Normalizes the point as a unit vector. More... | |
| operator std::string () const | |
| Converts this object to string. More... | |
| bool | operator!= (const basic_Point &point) const |
| Compares two points. More... | |
| T_ | operator* (const basic_Point< T_ > &value) const |
| Multiplies two points. This is essentially a dot product. More... | |
| template<class O_ > | |
| basic_Point | operator* (O_ value) const |
| Multiply this point with a scalar value. More... | |
| template<class O_ > | |
| basic_Point & | operator*= (O_ value) |
| Scales this point. More... | |
| basic_Point | operator+ (const basic_Point &point) const |
| Adds another point to this one and returns the result. More... | |
| basic_Point & | operator+= (const basic_Point &point) |
| Adds another point from this point. More... | |
| basic_Point | operator- () const |
| Negates this point. More... | |
| basic_Point | operator- (const basic_Point &point) const |
| Subtracts another point from this one. More... | |
| basic_Point & | operator-= (const basic_Point &point) |
| Subtracts another point from this point. More... | |
| template<class O_ > | |
| basic_Point | operator/ (O_ value) const |
| Divides this point to a scalar value. More... | |
| template<class O_ > | |
| basic_Point & | operator/= (O_ value) |
| Scales this point. More... | |
| template<class O_ > | |
| basic_Point & | operator= (const basic_Point< O_ > &point) |
| Assignment from a different point type. More... | |
| bool | operator== (const basic_Point &point) const |
| Compares two points. More... | |
| basic_Point | Perpendicular () const |
| Calculates perpendicular vector to this point. More... | |
| Float | Slope () const |
| Calculates the slope of the line formed from the origin to this point. More... | |
| Float | Slope (const basic_Point &point) const |
| Calculates the slope of the line formed from the given point to this point. More... | |
Static Public Member Functions | |
| template<class O_ > | |
| static basic_Point | FromVector (Float magnitute, Float angle, const basic_Point< O_ > &origin={0, 0}) |
| Creates a new point from the given vector data. More... | |
| static basic_Point | Parse (const std::string &str, bool require_parenthesis=false) |
| Properly parses given string into a point. More... | |
Public Attributes | |
| union { | |
| struct { | |
| T_ X | |
| X coordinate. More... | |
| T_ Y | |
| Y coordinate. More... | |
| } | |
| T_ Vector [2] | |
| Allows this point to be accessed as a vector. More... | |
| }; | |
This class represents a 2D point.
Points are serialized to string as (X, Y) form. However, unserialization, by default, accepts X, Y as well.
| typedef T_ BaseType |
Base type of the point elements.
| basic_Point | ( | ) |
Default constructor, does not zero initialize point.
| basic_Point | ( | const T_ & | X, |
| const T_ & | Y | ||
| ) |
Filling constructor.
| basic_Point | ( | const basic_Point< O_ > & | point | ) |
Conversion from a different point type.
|
explicit |
Conversion from string.
| Float Angle | ( | ) | const |
Calculates the angle of the line formed from the origin to this point.
| Float Angle | ( | const basic_Point< T_ > & | origin | ) | const |
Calculates the angle of the line formed from the given point to this point.
| origin | is the starting point of the line |
| bool Compare | ( | const basic_Point< T_ > & | point | ) | const |
Compares two points.
| T_ CrossProduct | ( | const basic_Point< T_ > & | value | ) | const |
Calculates cross product of two points.
| Float Distance | ( | ) | const |
Calculates Euclidean distance from this point to origin.
| Float Distance | ( | const basic_Point< T_ > & | target | ) | const |
Calculates Euclidean distance from this point to the given target.
| T_ DotProduct | ( | const basic_Point< T_ > & | value | ) | const |
Calculates dot product of two points.
| Float EuclideanSquare | ( | ) | const |
Calculates EuclideanSquare distance from this point to the given target.
| Float EuclideanSquare | ( | const basic_Point< T_ > & | target | ) | const |
Calculates EuclideanSquare distance from this point to the given target.
|
static |
Creates a new point from the given vector data.
| magnitute | is the magnitute of the vector |
| angle | is the direction of the vector in radians |
| origin | is the source origin to calculate new point |
| Float ManhattanDistance | ( | ) | const |
Calculates Manhattan distance from this point to origin.
| Float ManhattanDistance | ( | const basic_Point< T_ > & | target | ) | const |
Calculates Manhattan distance from this point to the given target.
| void Move | ( | const T_ & | x, |
| const T_ & | y | ||
| ) |
Moves this point to the given coordinates.
| basic_Point Normalize | ( | ) | const |
Normalizes the point as a unit vector.
|
explicit |
Converts this object to string.
| bool operator!= | ( | const basic_Point< T_ > & | point | ) | const |
Compares two points.
| T_ operator* | ( | const basic_Point< T_ > & | value | ) | const |
Multiplies two points. This is essentially a dot product.
| basic_Point operator* | ( | O_ | value | ) | const |
Multiply this point with a scalar value.
This is effectively scales the point
| basic_Point& operator*= | ( | O_ | value | ) |
Scales this point.
| basic_Point operator+ | ( | const basic_Point< T_ > & | point | ) | const |
Adds another point to this one and returns the result.
| basic_Point& operator+= | ( | const basic_Point< T_ > & | point | ) |
Adds another point from this point.
Result is assigned to this point
| basic_Point operator- | ( | ) | const |
Negates this point.
| basic_Point operator- | ( | const basic_Point< T_ > & | point | ) | const |
Subtracts another point from this one.
| basic_Point& operator-= | ( | const basic_Point< T_ > & | point | ) |
Subtracts another point from this point.
Result is assigned to this point
| basic_Point operator/ | ( | O_ | value | ) | const |
Divides this point to a scalar value.
This is effectively scales the point
| basic_Point& operator/= | ( | O_ | value | ) |
Scales this point.
| basic_Point& operator= | ( | const basic_Point< O_ > & | point | ) |
Assignment from a different point type.
| bool operator== | ( | const basic_Point< T_ > & | point | ) | const |
Compares two points.
|
static |
Properly parses given string into a point.
Throws errors if the point is not well formed. Works only on types that can be parsed using strtod. Following error codes are reported by this parse function:
| basic_Point Perpendicular | ( | ) | const |
Calculates perpendicular vector to this point.
| Float Slope | ( | ) | const |
Calculates the slope of the line formed from the origin to this point.
| Float Slope | ( | const basic_Point< T_ > & | point | ) | const |
Calculates the slope of the line formed from the given point to this point.
| point | is the starting point of the line |
| union { ... } |
| T_ Vector[2] |
Allows this point to be accessed as a vector.
| T_ X |
X coordinate.
| T_ Y |
Y coordinate.