8 #error This class is not to be included by the user directly. Use Origin2d.h or Origin2f.h instead.
21 REAL norm_inf()
const {
return std::max(std::fabs(_data[0]), std::fabs(_data[1])); }
22 REAL norm()
const {
return std::sqrt(norm_sq()); }
23 REAL norm_sq()
const {
return sqr(_data[0]) + sqr(_data[1]); }
24 static REAL norm(
const ORIGIN2& v) {
return std::sqrt(norm_sq(v)); }
25 static REAL norm_sq(
const ORIGIN2& v) {
return v.norm_sq(); }
26 ORIGIN2& set_zero() { _data[0] = _data[1] = 0.0;
return *
this; }
27 ORIGIN2& set_zero(
unsigned m) { assert(m==2);
return set_zero(); }
28 ORIGIN2& set_zero(
unsigned m,
unsigned n) { assert(m==2 && n==1);
return set_zero(); }
36 ORIGIN2& operator+=(
const ORIGIN2& v) { _data[0] += v[0]; _data[1] += v[1];
return *
this; }
37 ORIGIN2& operator-=(
const ORIGIN2& v) { _data[0] -= v[0]; _data[1] -= v[1];
return *
this; }
38 ORIGIN2& operator*=(REAL scalar) { _data[0] *= scalar; _data[1] *= scalar;
return *
this; }
39 ORIGIN2& operator/=(REAL scalar) { _data[0] /= scalar; _data[1] /= scalar;
return *
this; }
40 ORIGIN2 operator*(REAL scalar)
const {
ORIGIN2 v = *
this; v *= scalar;
return v; }
41 ORIGIN2 operator/(REAL scalar)
const {
ORIGIN2 v = *
this; v /= scalar;
return v; }
42 ORIGIN2 operator-()
const {
return ORIGIN2(-_data[0], -_data[1]); }
43 REAL* data() {
return _data; }
44 const REAL* data()
const {
return _data; }
45 REAL& operator[](
const unsigned i);
46 const REAL& operator[](
const unsigned i)
const;
47 REAL* data(
unsigned i);
48 const REAL* data(
unsigned i)
const;
49 const REAL& x()
const {
return _data[0]; }
50 const REAL& y()
const {
return _data[1]; }
51 REAL& x() {
return _data[0]; }
52 REAL& y() {
return _data[1]; }
53 unsigned size()
const {
return 3; }
54 unsigned rows()
const {
return 3; }
55 unsigned columns()
const {
return 1; }
56 unsigned leading_dim()
const {
return 3; }
57 unsigned inc()
const {
return 1; }
59 ORIGIN2&
resize(
unsigned m,
unsigned n,
bool preserve =
false);
63 static REAL sqr(REAL x) {
return x*x; }
66 inline ORIGIN2 operator*(REAL scalar,
const ORIGIN2& v) {
return v * scalar; }
69 inline std::ostream& operator<<(std::ostream& out,
const ORIGIN2& v)
71 out <<
'[' << v[0] <<
',' <<
' ' << v[1] <<
']' <<
' ';
ORIGIN2 & resize(unsigned m, bool preserve=false)
Does nothing.
Definition: Origin2.cpp:27
A two-dimensional floating point vector used for computational geometry calculations and with associa...
Definition: Vector2.h:15
A two-dimensional floating point vector used for computational geometry calculations and without asso...
Definition: Origin2.h:14
ORIGIN2 & operator=(const VECTOR2 &v)
Constructs this vector with the given values.
Definition: Origin2.cpp:47
VECTOR2 operator-(const VECTOR2 &p) const
Subtract a vector from this origin to yield a vector.
Definition: Origin2.cpp:62