Skip to content

Origin and vector types

edrumwri edited this page Oct 4, 2015 · 7 revisions

Ravelin represents both points and vectors in 2D and 3D without distinction (we will elaborate upon this below). However, Ravelin also treats points/vectors with and without frame information differently. The Origin2x and Origin3x types indicate the origin of a frame/pose and are not defined with respect to a frame. On the other hand, the Vector2x and Vector3x types indicate a point or vector defined with respect to a frame or pose and thus carry frame information. In other words, beware: Origin2x and Origin3x do not do any frame checking.

Include files

#include <Ravelin/Origin2d.h>
#include <Ravelin/Origin2f.h>
#include <Ravelin/Origin3d.h>
#include <Ravelin/Origin3f.h>
#include <Ravelin/Vector2d.h>
#include <Ravelin/Vector2f.h>
#include <Ravelin/Vector3d.h>
#include <Ravelin/Vector3f.h>

Distinguishing between points and vectors

As noted above, Ravelin does not distinguish internally between vectors (for which transformations preserve length) and points (for which transformations do not preserve length). The example below shows the difference.

// define a pose with a 90 degree rotation around the x-axis followed 
// by a 1-unit along the global y-axis 
shared_ptr<Pose3d> P(new Pose3d);
P->x = Origin3d(0,1,0);
P->q = AAngle3d(1,0,0,M_PI_2);

// define a vector and a point ***using the same data structure***
Vector3d vec(1,0,0,P);
Vector3d pt(1,0,0,P);

// transform the vector and point to the global frame
Vector3d vec0 = Pose3d::transform_vector(GLOBAL, vec);  // transformed to [ 0 1 0 ]
Vector3d pt0 = Pose3d::transform_point(GLOBAL, pt);     // transformed to [ 1 1 0 ]