#include <coordinate_2d.hpp>
Definition at line 42 of file 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. | |
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. |
typedef T claw::math::coordinate_2d< T >::value_type |
The type of the values we store.
Reimplemented in claw::math::vector_2d< T >.
Definition at line 46 of file coordinate_2d.hpp.
typedef coordinate_2d<value_type> claw::math::coordinate_2d< T >::self_type |
The type of the current class.
Reimplemented in claw::math::vector_2d< T >.
Definition at line 49 of file coordinate_2d.hpp.
claw::math::coordinate_2d< T >::coordinate_2d | ( | ) | [inline] |
claw::math::coordinate_2d< T >::coordinate_2d | ( | const coordinate_2d< U > & | that | ) | [inline] |
Copy constructor.
Definition at line 48 of file coordinate_2d.tpp.
00049 : x(that.x), y(that.y) 00050 { 00051 00052 } // coordinate_2d::coordinate_2d() [copy constructor]
claw::math::coordinate_2d< T >::coordinate_2d | ( | const value_type & | _x, | |
const value_type & | _y | |||
) | [inline] |
Constructor with initialization.
_x | x value. | |
_y | y Value. |
Definition at line 62 of file coordinate_2d.tpp.
00063 : x(_x), y(_y) 00064 { 00065 00066 } // coordinate_2d::coordinate_2d() [constructor whit values]
claw::math::coordinate_2d< U > claw::math::coordinate_2d< T >::cast_value_type_to | ( | ) | const [inline] |
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.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00093 { 00094 return claw::math::coordinate_2d<U>( (U)x, (U)y ); 00095 } // coordinate_2d::cast_value_type_to()
void claw::math::coordinate_2d< T >::set | ( | const value_type & | _x, | |
const value_type & | _y | |||
) | [inline] |
Sets new values to the coordinate.
_x | New x value. | |
_y | New y Value. |
Definition at line 105 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
claw::math::coordinate_2d< T >::value_type claw::math::coordinate_2d< T >::distance | ( | const self_type & | p | ) | const [inline] |
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.
00119 { 00120 return (value_type)sqrt( (p.x - x)*(p.x - x) + (p.y - y)*(p.y - y) ); 00121 } // coordinate_2d::distance()
bool claw::math::coordinate_2d< T >::operator== | ( | const self_type & | that | ) | const [inline] |
Equality operator.
that | Coordinate to compare to. |
Definition at line 129 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 [inline] |
Difference operator.
that | Coordinate to compare to. |
Definition at line 140 of file coordinate_2d.tpp.
claw::math::coordinate_2d< T > claw::math::coordinate_2d< T >::operator+ | ( | const self_type & | that | ) | const [inline] |
Addition.
that | Coordinate to add. |
Definition at line 152 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 [inline] |
Subtraction.
that | Coordinate to subtract. |
Definition at line 164 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 | ) | [inline] |
Add a coordinate.
that | Coordinate to add. |
Definition at line 176 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00177 { 00178 x += that.x; 00179 y += that.y; 00180 00181 return *this; 00182 } // coordinate_2d::operator+=()
claw::math::coordinate_2d< T > & claw::math::coordinate_2d< T >::operator-= | ( | const self_type & | that | ) | [inline] |
Subtract a coordinate.
that | Coordinate to subtract. |
Definition at line 191 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00192 { 00193 x -= that.x; 00194 y -= that.y; 00195 00196 return *this; 00197 } // coordinate_2d::operator-=()
claw::math::coordinate_2d< T > claw::math::coordinate_2d< T >::operator* | ( | const value_type & | v | ) | const [inline] |
Multiplication.
v | Factor. |
Definition at line 206 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 [inline] |
Division.
v | Divider. |
Definition at line 218 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 | ) | [inline] |
Multiply the coordinates.
v | Factor. |
Definition at line 230 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00231 { 00232 x *= v; 00233 y *= v; 00234 00235 return *this; 00236 } // coordinate_2d::operator*=()
claw::math::coordinate_2d< T > & claw::math::coordinate_2d< T >::operator/= | ( | const value_type & | v | ) | [inline] |
Divide the coordinates.
v | Divider. |
Definition at line 245 of file coordinate_2d.tpp.
References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00246 { 00247 x /= v; 00248 y /= v; 00249 00250 return *this; 00251 } // coordinate_2d::operator/=()
value_type claw::math::coordinate_2d< T >::x |
X-coordinate.
Definition at line 79 of file coordinate_2d.hpp.
Referenced by claw::math::coordinate_2d< T >::cast_value_type_to(), claw::math::coordinate_2d< T >::distance(), claw::math::vector_2d< T >::dot_product(), claw::math::vector_2d< T >::get_orthonormal(), claw::math::rectangle< T >::includes(), claw::math::line_2d< T >::intersection(), claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::math::vector_2d< T >::length(), claw::math::vector_2d< T >::normalize(), claw::graphic::image::base_iterator< Image, Pixel >::operator*(), claw::math::coordinate_2d< T >::operator*(), claw::math::coordinate_2d< T >::operator*=(), claw::math::coordinate_2d< T >::operator+(), claw::graphic::image::base_iterator< Image, Pixel >::operator++(), claw::graphic::image::base_iterator< Image, Pixel >::operator+=(), claw::math::coordinate_2d< T >::operator+=(), claw::graphic::image::base_iterator< Image, Pixel >::operator-(), claw::math::operator-(), claw::math::coordinate_2d< T >::operator-(), claw::graphic::image::base_iterator< Image, Pixel >::operator--(), claw::graphic::image::base_iterator< Image, Pixel >::operator-=(), claw::math::coordinate_2d< T >::operator-=(), claw::graphic::image::base_iterator< Image, Pixel >::operator->(), claw::math::coordinate_2d< T >::operator/(), claw::math::coordinate_2d< T >::operator/=(), claw::graphic::image::base_iterator< Image, Pixel >::operator<(), claw::math::coordinate_2d< T >::operator==(), claw::math::line_2d< T >::parallel(), claw::graphic::image::partial_copy(), claw::graphic::xbm::reader::read_size(), claw::graphic::xbm::writer::save(), claw::math::coordinate_2d< T >::set(), claw::math::box_2d< T >::width(), and claw::math::line_2d< T >::y_value().
value_type claw::math::coordinate_2d< T >::y |
Y-coordinate.
Definition at line 82 of file coordinate_2d.hpp.
Referenced by claw::math::coordinate_2d< T >::cast_value_type_to(), claw::math::coordinate_2d< T >::distance(), claw::math::vector_2d< T >::dot_product(), claw::math::vector_2d< T >::get_orthonormal(), claw::math::box_2d< T >::height(), claw::math::rectangle< T >::includes(), claw::math::line_2d< T >::intersection(), claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::math::vector_2d< T >::length(), claw::math::vector_2d< T >::normalize(), claw::graphic::image::base_iterator< Image, Pixel >::operator*(), claw::math::coordinate_2d< T >::operator*(), claw::math::coordinate_2d< T >::operator*=(), claw::math::coordinate_2d< T >::operator+(), claw::graphic::image::base_iterator< Image, Pixel >::operator++(), claw::graphic::image::base_iterator< Image, Pixel >::operator+=(), claw::math::coordinate_2d< T >::operator+=(), claw::graphic::image::base_iterator< Image, Pixel >::operator-(), claw::math::operator-(), claw::math::coordinate_2d< T >::operator-(), claw::graphic::image::base_iterator< Image, Pixel >::operator--(), claw::graphic::image::base_iterator< Image, Pixel >::operator-=(), claw::math::coordinate_2d< T >::operator-=(), claw::graphic::image::base_iterator< Image, Pixel >::operator->(), claw::math::coordinate_2d< T >::operator/(), claw::math::coordinate_2d< T >::operator/=(), claw::graphic::image::base_iterator< Image, Pixel >::operator<(), claw::math::coordinate_2d< T >::operator==(), claw::math::line_2d< T >::parallel(), claw::graphic::image::partial_copy(), claw::graphic::xbm::reader::read_size(), claw::graphic::xbm::writer::save(), claw::math::coordinate_2d< T >::set(), and claw::math::line_2d< T >::y_value().