14 #ifndef ECL_GEOMETRY_CARTESIAN_POINT_HPP_ 15 #define ECL_GEOMETRY_CARTESIAN_POINT_HPP_ 45 template <
typename T,
unsigned int N>
51 CartesianPoint(
const T &value = T()) : elements(
ecl::linear_algebra::Matrix<T,N,1>::Constant(value)) {}
57 CartesianPoint(
const ecl::linear_algebra::Matrix<T,N,1> &point_vector) : elements(point_vector) {}
75 ecl::linear_algebra::CommaInitializer< ecl::linear_algebra::Matrix<T,N,1> >
operator<<(
const T &value) {
76 return elements.operator<<(value);
88 return elements[index];
100 return elements[index];
121 const ecl::linear_algebra::Matrix<T,N,1>&
positionVector()
const {
return elements; }
123 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
149 CartesianPoint(
const T &value = T()) : elements(
ecl::linear_algebra::Matrix<T,3,1>::Constant(value)) {}
164 elements << x_i, y_i, z_i;
185 ecl::linear_algebra::CommaInitializer< ecl::linear_algebra::Matrix<T,3,1> >
operator<<(
const T &value) {
186 return elements.operator<<(value);
205 const ecl::linear_algebra::Matrix<T,3,1>&
positionVector()
const {
return elements; }
214 unsigned int size() {
return 3; }
221 const T&
x()
const {
return elements[0]; }
227 const T&
y()
const {
return elements[1]; }
233 const T&
z()
const {
return elements[2]; }
239 T
x() {
return elements[0]; }
245 T
y() {
return elements[1]; }
251 T
z() {
return elements[2]; }
253 void x(
const T& value) { elements[0] = value; }
254 void y(
const T& value) { elements[1] = value; }
255 void z(
const T& value) { elements[2] = value; }
257 template <
typename OutputStream,
typename Type>
258 friend OutputStream& operator<<(OutputStream &ostream , const CartesianPoint<Type,3> &point);
278 template <
typename OutputStream,
typename Type>
279 OutputStream& operator<<(OutputStream &ostream , const CartesianPoint<Type,3> &point) {
280 ostream <<
"[ " << point.x() <<
" " << point.y() <<
" " << point.z() <<
" ]";
304 CartesianPoint(
const T &value = T()) : elements(
ecl::linear_algebra::Matrix<T,2,1>::Constant(value)) {}
319 elements << x_i, y_i;
340 ecl::linear_algebra::CommaInitializer< ecl::linear_algebra::Matrix<T,2,1> >
operator<<(
const T &value) {
341 return elements.operator<<(value);
346 return elements[index];
351 return elements[index];
375 const ecl::linear_algebra::Matrix<T,2,1>&
positionVector()
const {
return elements; }
384 unsigned int size() {
return 2; }
391 const T&
x()
const {
return elements[0]; }
397 const T&
y()
const {
return elements[1]; }
403 T
x() {
return elements[0]; }
409 T
y() {
return elements[1]; }
413 if( other.
x() != x() || other.
y() != y() )
return false;
419 if( other.
x() != x() || other.
y() != y() )
return true;
425 double c = cos(angle);
426 double s = sin(angle);
427 double tx = x()*c - y()*s;
428 double ty = x()*s + y()*c;
436 return atan2( y(), x() );
446 ecl::linear_algebra::Matrix<T,2,1> temp_element = elements - other.
positionVector();
447 return static_cast<T
>( sqrt( temp_element[0]*temp_element[0]+temp_element[1]*temp_element[1]) );
454 if ( mag == static_cast<T>(0) )
460 elements[0] *= (1.0/mag);
461 elements[1] *= (1.0/mag);
487 void x(
const T& value) { elements[0] = value; }
488 void y(
const T& value) { elements[1] = value; }
490 template <
typename OutputStream,
typename Type>
491 friend OutputStream& operator<<(OutputStream &ostream , const CartesianPoint<Type,2> &point);
493 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
513 template <
typename OutputStream,
typename Type>
514 OutputStream& operator<<(OutputStream &ostream , const CartesianPoint<Type,2> &point) {
515 ostream <<
"[ " << point.x() <<
" " << point.y() <<
" ]";
CartesianPoint(const ecl::linear_algebra::Matrix< T, 2, 1 > &vec)
Initialises with the specified input vector.
ecl::linear_algebra::Matrix< T, 3, 1 > elements
virtual ~CartesianPoint()
void y(const T &value)
Sets the y-cordinate.
CartesianPoint(const CartesianPoint< T, 2 > &point)
Default copy constructor.
T x()
Returns a copy of the x co-ordinate.
Embedded control libraries.
unsigned int size()
Size/dimension of the cartesian point.
ecl::linear_algebra::Matrix< T, 3, 1 > & positionVector()
Representation of the position vector in eigen vector format.
T distance(const CartesianPoint< T, 2 > &other)
const T & y() const
Returns a constant reference to the y co-ordinate.
CartesianPoint< float, 3 > CartesianPoint3f
Eigen style convenience handle for x, y, z triples in float format.
T z()
Returns a copy of the z co-ordinate.
ecl::linear_algebra::Matrix< T, 2, 1 > & positionVector()
Representation of the position vector in eigen vector format.
void y(const T &value)
Sets the y-coordinate.
CartesianPoint< double, 2 > CartesianPoint2d
Eigen style convenience handle for x, y, z triples in double format.
void rotate(const double &angle)
CartesianPoint(const T &value=T())
Default constructor - sets all elements to the same value.
Specialisation for a cartesian point of dimension 2.
CartesianPoint(const T &value=T())
Default constructor - sets all elements to the same value.
CartesianPoint< double, 3 > CartesianPoint3d
Eigen style convenience handle for x, y, z triples in double format.
OutputStream & operator<<(OutputStream &ostream, const Void void_object)
virtual ~CartesianPoint()
const T & x() const
Returns a constant reference to the x co-ordinate.
ecl::linear_algebra::Matrix< T, 2, 1 > elements
const ecl::linear_algebra::Matrix< T, 3, 1 > & positionVector() const
Representation of the position vector in const eigen vector format.
void x(const T &value)
Sets the x-cor.dinate.
CartesianPoint(const ecl::linear_algebra::Matrix< T, N, 1 > &point_vector)
Initialises with the specified eigen style vector.
T y()
Returns a copy of the y co-ordinate.
void x(const T &value)
Sets the x-coordinate.
#define ecl_assert_throw(expression, exception)
CartesianPoint(const T &x_i, const T &y_i, const T &z_i)
Initialises the point with the specified values.
ecl::linear_algebra::Matrix< T, N, 1 > & positionVector()
Representation of the position vector in eigen vector format.
T y()
Returns a copy of the y co-ordinate.
const T & x() const
Returns a constant reference to the x co-ordinate.
const ecl::linear_algebra::Matrix< T, N, 1 > & positionVector() const
Representation of the position vector in const eigen vector format.
CartesianPoint(const T &value=T())
Default constructor - sets all elements to the same value.
CartesianPoint< int, 3 > CartesianPoint3i
Eigen style convenience handle for x, y, z triples in integer format.
CartesianPoint(const ecl::linear_algebra::Matrix< T, 3, 1 > &vec)
Initialises with the specified eigen style vector.
ecl::linear_algebra::Matrix< T, N, 1 > elements
const ecl::linear_algebra::Matrix< T, 2, 1 > & positionVector() const
Representation of the position vector in const eigen vector format.
const T & y() const
Returns a constant reference to the y co-ordinate.
T x()
Returns a copy of the x co-ordinate.
#define ecl_assert_throw_decl(exception)
void z(const T &value)
Sets the z-coordinate.
CartesianPoint(const T &x_i, const T &y_i)
const T & z() const
Returns a constant reference to the z co-ordinate.
Generic container storing a cartesian point of dimension N.
unsigned int size()
Size/dimension of the cartesian point.
CartesianPoint< float, 2 > CartesianPoint2f
Eigen style convenience handle for x, y, z triples in float format.
CartesianPoint< int, 2 > CartesianPoint2i
Eigen style convenience handle for x, y, z triples in integer format.