Claw
1.7.3
|
Coordinates in a two dimensional space. More...
#include <coordinate_2d.hpp>
Public Types | |
typedef T | value_type |
The type of the values we store. | |
typedef coordinate_2d< value_type > | self_type |
The type of the current class. |
Public Member Functions | |
coordinate_2d () | |
Constructor. | |
template<typename U > | |
coordinate_2d (const coordinate_2d< U > &that) | |
Copy constructor. | |
coordinate_2d (const value_type &_x, const value_type &_y) | |
Constructor with initialization. | |
template<typename U > | |
coordinate_2d< U > | cast_value_type_to () const |
Get a copy of the rectangle by converting its members to a given type. | |
void | set (const value_type &_x, const value_type &_y) |
Sets new values to the coordinate. | |
value_type | distance (const self_type &p) const |
Get the distance separing two coordinates. | |
void | rotate (const self_type ¢er, double angle) |
Rotate this point around an other point. | |
double | slope_angle (const self_type &to) const |
Get the angle of the slope starting from this and ending with an other coordinate. | |
bool | operator== (const self_type &vect) const |
Equality operator. | |
bool | operator!= (const self_type &vect) const |
Difference operator. | |
self_type | operator+ (const self_type &vect) const |
Addition. | |
self_type | operator- (const self_type &vect) const |
Subtraction. | |
self_type & | operator+= (const self_type &vect) |
Add a coordinate. | |
self_type & | operator-= (const self_type &vect) |
Subtract a coordinate. | |
self_type | operator* (const value_type &v) const |
Multiplication. | |
self_type | operator/ (const value_type &v) const |
Division. | |
self_type & | operator*= (const value_type &v) |
Multiply the coordinates. | |
self_type & | operator/= (const value_type &v) |
Divide the coordinates. |
Public Attributes | |
value_type | x |
X-coordinate. | |
value_type | y |
Y-coordinate. |
Coordinates in a two dimensional space.
Definition at line 42 of file coordinate_2d.hpp.
claw::math::coordinate_2d< T >::coordinate_2d | ( | const value_type & | _x, |
const value_type & | _y | ||
) |
Constructor with initialization.
_x | x value. |
_y | y Value. |
Definition at line 62 of file coordinate_2d.tpp.
claw::math::coordinate_2d< U > claw::math::coordinate_2d< T >::cast_value_type_to | ( | ) | const |
Get a copy of the rectangle by converting its members to a given type.
Consider the following code:
coordinate_2d<float> a;
...
coordinate_2d<int> b(a);
The copy constructor will be called, and your compiler should print some warnings in your console. These warnings have a meaning, so we don't wan't to make them disapear by adding explicit type conversion inside the coordinate_2d class nor adding a cast operator that will be used silently by the compiler.
If you really want to convert the type, this method will explicitly cast the member variables.
Definition at line 92 of file coordinate_2d.tpp.
claw::math::coordinate_2d< T >::value_type claw::math::coordinate_2d< T >::distance | ( | const self_type & | p | ) | const |
Get the distance separing two coordinates.
p | The second coordinate |
Definition at line 118 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
bool claw::math::coordinate_2d< T >::operator!= | ( | const self_type & | that | ) | const |
Difference operator.
that | Coordinate to compare to. |
Definition at line 172 of file coordinate_2d.tpp.
claw::math::coordinate_2d< T > claw::math::coordinate_2d< T >::operator* | ( | const value_type & | v | ) | const |
claw::math::coordinate_2d< T > & claw::math::coordinate_2d< T >::operator*= | ( | const value_type & | v | ) |
claw::math::coordinate_2d< T > claw::math::coordinate_2d< T >::operator+ | ( | const self_type & | that | ) | const |
Addition.
that | Coordinate to add. |
Definition at line 184 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
claw::math::coordinate_2d< T > & claw::math::coordinate_2d< T >::operator+= | ( | const self_type & | that | ) |
Add a coordinate.
that | Coordinate to add. |
Definition at line 208 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
claw::math::coordinate_2d< T > claw::math::coordinate_2d< T >::operator- | ( | const self_type & | that | ) | const |
Subtraction.
that | Coordinate to subtract. |
Definition at line 196 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
claw::math::coordinate_2d< T > & claw::math::coordinate_2d< T >::operator-= | ( | const self_type & | that | ) |
Subtract a coordinate.
that | Coordinate to subtract. |
Definition at line 223 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
claw::math::coordinate_2d< T > claw::math::coordinate_2d< T >::operator/ | ( | const value_type & | v | ) | const |
claw::math::coordinate_2d< T > & claw::math::coordinate_2d< T >::operator/= | ( | const value_type & | v | ) |
bool claw::math::coordinate_2d< T >::operator== | ( | const self_type & | that | ) | const |
Equality operator.
that | Coordinate to compare to. |
Definition at line 161 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
void claw::math::coordinate_2d< T >::rotate | ( | const self_type & | center, |
double | angle | ||
) |
Rotate this point around an other point.
center | The other point. |
angle | The angle of the rotation. |
Definition at line 131 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
void claw::math::coordinate_2d< T >::set | ( | const value_type & | _x, |
const value_type & | _y | ||
) |
Sets new values to the coordinate.
_x | New x value. |
_y | New y Value. |
Definition at line 105 of file coordinate_2d.tpp.
double claw::math::coordinate_2d< T >::slope_angle | ( | const self_type & | to | ) | const |
Get the angle of the slope starting from this and ending with an other coordinate.
to | The other point. |
Definition at line 150 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.