#include <line_2d.hpp>
Definition at line 45 of file line_2d.hpp.
Public Types | |
typedef T | value_type |
The type of the values we store. | |
typedef line_2d< value_type > | self_type |
The type of the current class. | |
typedef coordinate_2d< value_type > | point_type |
The type of the reference point. | |
typedef vector_2d< value_type > | direction_type |
The type of the direction vector. | |
Public Member Functions | |
line_2d () | |
Constructor. | |
template<class U> | |
line_2d (const line_2d< U > &that) | |
Constructor. | |
line_2d (const point_type &_origin, const direction_type &_direction) | |
Constructor with initializations. | |
line_2d (const value_type &ox, const value_type &oy, const value_type &dx, const value_type &dy) | |
Constructor with initializations. | |
bool | parallel (const self_type &that) const |
Tell if two lines are parallels. | |
bool | orthogonal (const self_type &that) const |
Tell if two lines are orthogonal. | |
point_type | intersection (const self_type &that) const |
Get the point at the intersection of two lines. | |
value_type | y_value (const value_type &x) const |
Get the y value of the point of the line at position x. | |
Public Attributes | |
point_type | origin |
A reference point on the line. | |
direction_type | direction |
Direction. |
typedef T claw::math::line_2d< T >::value_type |
typedef line_2d<value_type> claw::math::line_2d< T >::self_type |
typedef coordinate_2d<value_type> claw::math::line_2d< T >::point_type |
typedef vector_2d<value_type> claw::math::line_2d< T >::direction_type |
claw::math::line_2d< T >::line_2d | ( | ) | [inline] |
claw::math::line_2d< T >::line_2d | ( | const line_2d< U > & | that | ) | [inline] |
Constructor.
that | Line to copy from. |
Definition at line 48 of file line_2d.tpp.
00049 : origin(that.origin), direction(that.direction) 00050 { 00051 00052 } // line_2d::line_2d() [copy constructor]
claw::math::line_2d< T >::line_2d | ( | const point_type & | _origin, | |
const direction_type & | _direction | |||
) | [inline] |
Constructor with initializations.
_origin | A point on the line. | |
_direction | The direction of the line. |
Definition at line 62 of file line_2d.tpp.
00063 : origin(_origin), direction(_direction) 00064 { 00065 00066 } // line_2d::line_2d() [constructor with values]
claw::math::line_2d< T >::line_2d | ( | const value_type & | ox, | |
const value_type & | oy, | |||
const value_type & | dx, | |||
const value_type & | dy | |||
) | [inline] |
Constructor with initializations.
ox | X-coordinate of the origin. | |
oy | Y-coordinate of the origin. | |
dx | X direction of the line. | |
dy | Y direction of the line. |
Definition at line 77 of file line_2d.tpp.
00079 : origin(ox, oy), direction(dx, dy) 00080 { 00081 00082 } // line_2d::line_2d() [constructor with detailed origin & direction]
bool claw::math::line_2d< T >::parallel | ( | const self_type & | that | ) | const [inline] |
Tell if two lines are parallels.
that | The other line. |
Definition at line 90 of file line_2d.tpp.
References claw::math::line_2d< T >::direction, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
Referenced by claw::math::line_2d< T >::intersection().
00091 { 00092 return !( (direction.x * that.direction.y) 00093 - (that.direction.x * direction.y) ); 00094 } // line_2d::parallel()
bool claw::math::line_2d< T >::orthogonal | ( | const self_type & | that | ) | const [inline] |
Tell if two lines are orthogonal.
that | The other line. |
Definition at line 102 of file line_2d.tpp.
References claw::math::line_2d< T >::direction, and claw::math::vector_2d< T >::dot_product().
00103 { 00104 return !( direction.dot_product( that.direction ) ); 00105 } // line_2d::orthogonal()
claw::math::line_2d< T >::point_type claw::math::line_2d< T >::intersection | ( | const self_type & | that | ) | const [inline] |
Get the point at the intersection of two lines.
that | The other line. |
Definition at line 115 of file line_2d.tpp.
References claw::math::line_2d< T >::direction, claw::math::line_2d< T >::origin, claw::math::line_2d< T >::parallel(), claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00116 { 00117 point_type result; 00118 00119 if ( ! parallel( that ) ) 00120 { 00121 point_type delta( that.origin - origin ); 00122 value_type n, m; 00123 00124 n = direction.x * delta.y - direction.y * delta.x; 00125 m = that.direction.x * direction.y - direction.x * that.direction.y; 00126 00127 result.x = that.origin.x + (n * that.direction.x) / m; 00128 result.y = that.origin.y + (n * that.direction.y) / m; 00129 } 00130 00131 return result; 00132 } // line_2d::intersection()
claw::math::line_2d< T >::value_type claw::math::line_2d< T >::y_value | ( | const value_type & | x | ) | const [inline] |
Get the y value of the point of the line at position x.
x | The X-coordinate for which we want the Y-coordinate. |
Definition at line 141 of file line_2d.tpp.
References claw::math::line_2d< T >::direction, claw::math::line_2d< T >::origin, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00142 { 00143 return (direction.y * (x - origin.x) + direction.x * origin.y) / direction.x; 00144 } // line_2d::y_value()
point_type claw::math::line_2d< T >::origin |
A reference point on the line.
Definition at line 75 of file line_2d.hpp.
Referenced by claw::math::line_2d< T >::intersection(), and claw::math::line_2d< T >::y_value().
direction_type claw::math::line_2d< T >::direction |
Direction.
Definition at line 78 of file line_2d.hpp.
Referenced by claw::math::line_2d< T >::intersection(), claw::math::line_2d< T >::orthogonal(), claw::math::line_2d< T >::parallel(), and claw::math::line_2d< T >::y_value().