8 #error This class is not to be included by the user directly. Use VECTOR2.h or Vector2f.h instead.
18 VECTOR2(boost::shared_ptr<const POSE2>
pose = boost::shared_ptr<const POSE2>()) { this->
pose =
pose; }
19 VECTOR2(boost::shared_ptr<POSE2>
pose) { this->pose = boost::const_pointer_cast<
const POSE2>(
pose); }
20 VECTOR2(REAL x, REAL y, boost::shared_ptr<const POSE2> pose = boost::shared_ptr<const POSE2>());
21 VECTOR2(REAL x, REAL y, boost::shared_ptr<POSE2> pose);
22 VECTOR2(
const REAL* array, boost::shared_ptr<const POSE2> pose = boost::shared_ptr<const POSE2>());
23 VECTOR2(
const REAL* array, boost::shared_ptr<POSE2> pose);
24 VECTOR2(
const ORIGIN2& o, boost::shared_ptr<POSE2> pose) { this->pose = boost::const_pointer_cast<
const POSE2>(
pose); operator=(o); }
25 VECTOR2(
const ORIGIN2& o, boost::shared_ptr<const POSE2> pose) { this->pose =
pose; operator=(o); }
26 REAL dot(
const VECTOR2& v)
const {
return v[0]*_data[0] + v[1]*_data[1]; }
27 static REAL dot(
const VECTOR2& v1,
const VECTOR2& v2) {
return v1[0]*v2[0] + v1[1]*v2[1]; }
28 REAL norm_inf()
const {
return std::max(std::fabs(_data[0]), std::fabs(_data[1])); }
29 REAL norm()
const {
return std::sqrt(norm_sq()); }
30 REAL norm_sq()
const {
return dot(*
this, *
this); }
31 void normalize() { assert(norm() > std::numeric_limits<REAL>::epsilon()); operator/=(norm()); }
33 unsigned size()
const {
return 2; }
34 static REAL norm(
const VECTOR2& v) {
return std::sqrt(norm_sq(v)); }
35 static REAL norm_sq(
const VECTOR2& v) {
return v.dot(v); }
36 VECTOR2& set_zero() { _data[0] = _data[1] = 0.0;
return *
this; }
37 VECTOR2& set_one() { _data[0] = _data[1] = 1.0;
return *
this; }
38 VECTOR2& set_zero(boost::shared_ptr<const POSE2> pose) { _data[0] = _data[1] = 0.0; this->pose =
pose;
return *
this; }
39 VECTOR2& set_one(boost::shared_ptr<const POSE2> pose) { _data[0] = _data[1] = 1.0; this->pose =
pose;
return *
this; }
40 static VECTOR2 zero(boost::shared_ptr<const POSE2> pose = boost::shared_ptr<const POSE2>()) {
return VECTOR2(0.0, 0.0, pose); }
41 VECTOR2& operator=(
const VECTOR2& v) { _data[0] = v[0]; _data[1] = v[1]; pose = v.
pose;
return *
this; }
51 VECTOR2& operator*=(REAL scalar) { _data[0] *= scalar; _data[1] *= scalar;
return *
this; }
52 VECTOR2& operator/=(REAL scalar) { _data[0] /= scalar; _data[1] /= scalar;
return *
this; }
53 VECTOR2 operator*(REAL scalar)
const {
VECTOR2 v = *
this; v *= scalar;
return v; }
54 VECTOR2 operator/(REAL scalar)
const {
VECTOR2 v = *
this; v /= scalar;
return v; }
55 VECTOR2 operator-()
const {
return VECTOR2(-_data[0], -_data[1]); }
56 REAL* data() {
return _data; }
57 const REAL* data()
const {
return _data; }
58 unsigned rows()
const {
return 2; }
59 unsigned columns()
const {
return 1; }
60 unsigned inc()
const {
return 1; }
61 unsigned leading_dim()
const {
return 2; }
62 REAL& operator[](
const unsigned i);
63 const REAL& operator[](
const unsigned i)
const;
64 VECTOR2& resize(
unsigned m,
unsigned n,
bool preserve =
false);
77 REAL* data(
unsigned i);
78 const REAL* data(
unsigned i)
const;
79 const REAL& x()
const {
return _data[0]; }
80 const REAL& y()
const {
return _data[1]; }
81 REAL& x() {
return _data[0]; }
82 REAL& y() {
return _data[1]; }
91 boost::shared_ptr<const POSE2>
pose;
97 inline VECTOR2 operator*(REAL scalar,
const VECTOR2& v) {
return v * scalar; }
100 inline std::ostream& operator<<(std::ostream& out,
const VECTOR2& v)
102 out <<
'[' << v[0] <<
',' <<
' ' << v[1] <<
']' <<
' ';
A construct for iterating over a rectangular block of a matrix.
Definition: RowIterator.h:210
A 2D rigid body pose.
Definition: Pose2.h:12
A two-dimensional floating point vector used for computational geometry calculations and with associa...
Definition: Vector2.h:15
VECTOR2 perp() const
Computes the "perp" operator.
Definition: Vector2.h:85
VECTOR2 & operator-=(const VECTOR2 &v)
Subtracts a vector from this.
Definition: Vector2.cpp:223
boost::shared_ptr< const POSE2 > pose
The pose that this vector is defined in.
Definition: Vector2.h:91
VECTOR2 & operator+=(const VECTOR2 &v)
Adds a vector to this.
Definition: Vector2.cpp:208
A construct for iterating over a rectangular block of a matrix.
Definition: ColumnIterator.h:12
A construct for iterating over a rectangular block of a matrix.
Definition: ColumnIterator.h:215
A two-dimensional floating point vector used for computational geometry calculations and without asso...
Definition: Origin2.h:14
A construct for iterating over a rectangular block of a matrix.
Definition: RowIterator.h:12
REAL dot_perp(const VECTOR2 &v) const
Computes the dot "perp" product.
Definition: Vector2.h:88