# Cartesian Points

Description: Simple object representations for cartesian points.

Keywords: ecl points

Tutorial Level: BEGINNER

## Cartesian Point

This is a simple templatised abstraction of a cartesian/euclidean point. The template arguments are used to define the dimension and the storage type (float or double for the point.

```   1 #include <ecl/geometry/cartesian_point.hpp>
2
3 using ecl::CartesianPoint;   // the template class
4 using ecl::CartesianPoint3d; // a typedef
5
6 CartesianPoint<3,double> p1; // template instantiation
7 CarteisanPoint3d p2;         // same thing
8
```

## Setters

```   1 // Point by point - 2d/3d specialisations only
2 CartesianPoint3d p1(0.1,0.2,0.3);
3 // From eigen vector
4 eigen::Vector3d v; v << 0.1, 0.2, 0.3;
5 CartesianPoint3d p2(v);
6 // Comma Initialisation
7 CartesianPoint3d p3;
8 p3 << 1.0, 2.0, 3.0;
9 // From api - 2d/3d specialisations only
10 CartesianPoint3d p4;
11 p4.x(1.0); p4.y(2.0); p4.z(3.0);
```

## Accessors

```   1 CartesianPoint3d p;
2 p << 1.0, 2.0, 3.0;
3 // From api - 2d/3d specialisations only
4 double x(p.x()), y(p.y()), z(p.z());
5 // From vector
6 eigen::Vector3d v = p.positionVector();
7 // From operator []
8 double x(p[0]), y(p[1]), z(p[2]);
```

## Error Handling

The class will throw exceptions in debug mode if ranges are exceeded at any time (comma initisalisations, operator []).

Wiki: ecl_geometry/Tutorials/Cartesian Points (last edited 2012-01-24 11:13:38 by DanielStonier)