amino  1.0-beta2
Lightweight Robot Utility Library
planar.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 4 -*- */
2 /* ex: set shiftwidth=4 tabstop=4 expandtab: */
3 /*
4  * Copyright (c) 2022, Colorado School of Mines
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or
8  * without modification, are permitted provided that the following
9  * conditions are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
20  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
27  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #ifndef AMINO_PLANAR_HPP
36 #define AMINO_PLANAR_HPP
37 
51 #include <complex>
52 
53 namespace amino {
54 
58 struct BaseCmplx : ::std::complex<double> {
60  typedef ::std::complex<double> type;
61 
63  BaseCmplx() {}
64 
66  BaseCmplx(double real, double imag) : type(real, imag) {}
67 
69  BaseCmplx(type c) : type(c) {}
70 
72  BaseCmplx(const aa_tf_cmplx& v) : type(from(v)) {}
73 
75  static aa_tf_cmplx c_cmplx(type c) {
76  return *reinterpret_cast<const aa_tf_cmplx*>(&c);
77  }
78 
80  aa_tf_cmplx c_cmplx() const {
81  return c_cmplx(*this);
82  }
83 
85  operator aa_tf_cmplx() const { return c_cmplx(); }
86 
88  static double c_real (const aa_tf_cmplx& v) {
89  return reinterpret_cast<const type*>(&v)->real();
90  }
91 
93  static double c_imag (const aa_tf_cmplx& v) {
94  return reinterpret_cast<const type*>(&v)->imag();
95  }
96 
98  static type from(const aa_tf_cmplx& v) {
99  return type(c_real(v), c_imag(v));
100  }
101 
102 protected:
104  double& real_ref() { return reinterpret_cast<double(&)[2]>(*this)[0]; }
105 
107  double& imag_ref() { return reinterpret_cast<double(&)[2]>(*this)[1]; }
108 };
109 
113 struct Vec2 : BaseCmplx {
115  Vec2() {}
116 
118  Vec2(double x, double y) : BaseCmplx(x, y) {}
119 
122 
124  double x() const { return real(); }
125 
127  double y() const { return imag(); }
128 
130  double& x() { return real_ref(); }
131 
133  double& y() { return imag_ref(); }
134 };
135 
137 struct AngleP {
139  AngleP() {}
140 
142  AngleP(double theta) : angle_(theta) {}
143 
146 
148  AngleP(BaseCmplx::type c) : angle_(atan2(c.imag(), c.real())) {}
149 
151  AngleP(const aa_tf_rotmatp* R) : angle_(aa_tf_rotmatp2angle(R->data)) {}
152 
154  AngleP(const aa_tf_rotmatp& R) : angle_(aa_tf_rotmatp2angle(R.data)) {}
155 
157  double angle() const { return angle_; };
158 
160  double& angle() { return angle_; };
161 
162  private:
163  double angle_;
164 };
165 
167 struct Cmplx : BaseCmplx {
169  Cmplx() {}
170 
172  Cmplx(double real, double imag) : BaseCmplx(real, imag) {}
173 
175  Cmplx(type c) : BaseCmplx(c) {}
176 
179 
181  Cmplx(const aa_tf_rotmatp& R) : BaseCmplx(from(R)) {}
182 
184  Cmplx(const aa_tf_rotmatp* R) : BaseCmplx(from(R)) {}
185 
187  Cmplx(const AngleP& a) : BaseCmplx(from(a)) {}
188 
190  Cmplx(const AngleP* a) : BaseCmplx(from(a)) {}
191 
193  static Cmplx from_angle(double theta) {
194  return aa_tf_angle2cmplx(theta);
195  }
196 
198  static Cmplx from_rotmatp(const double *R) {
199  return aa_tf_rotmatp2cmplx(R);
200  }
201 
203  static Cmplx from(const aa_tf_rotmatp* R) { return from_rotmatp(R->data); }
205  static Cmplx from(const aa_tf_rotmatp& R) { return from_rotmatp(R.data); }
207  static Cmplx from(const AngleP& a) { return from_angle(a.angle()); }
209  static Cmplx from(const AngleP* a) { return from_angle(a->angle()); }
210 
212  static aa_tf_cmplx ident() { return 1; }
213 
215  double angle() const { return aa_tf_cmplx2angle(*this); }
216 
218  double uln() const { return aa_tf_culn(*this); }
219 
221  Cmplx conj() const { return aa_tf_cconj(*this); }
222 };
223 
231 
237  RotMatP(double r11, double r12, double r21, double r22)
238  : aa_tf_rotmatp(from_rotmatp(r11, r12, r21, r22))
239  {}
240 
251 
253  static aa_tf_rotmatp from_angle(double theta) {
254  aa_tf_rotmatp R;
255  aa_tf_angle2rotmatp(theta, R.data);
256  return R;
257  }
258 
260  static aa_tf_rotmatp
261  from_rotmatp (double r11, double r12, double r21, double r22)
262  {
263  aa_tf_rotmatp R;
264  R.data[0] = r11;
265  R.data[1] = r21;
266  R.data[2] = r12;
267  R.data[3] = r22;
268  return R;
269  }
270 
272  static aa_tf_rotmatp
273  from_rotmatp (const double *R) {
274  return from_rotmatp(R[0], R[2], R[1], R[3]);
275  }
276 
278  static aa_tf_rotmatp
280  aa_tf_rotmatp R;
281  aa_tf_cmplx2rotmatp(c, R.data);
282  return R;
283  }
284 
286  static aa_tf_rotmatp
288  return from_cmplx(Cmplx::c_cmplx(c));
289  }
290 
292  static aa_tf_rotmatp from(aa_tf_cmplx c) { return from_cmplx(c); }
294  static aa_tf_rotmatp from(Cmplx::type c) { return from_cmplx(c); }
296  static aa_tf_rotmatp from(double angle) { return from_angle(angle); }
298  static aa_tf_rotmatp from(const AngleP& angle) {
299  return from_angle(angle.angle());
300  }
302  static aa_tf_rotmatp from(const AngleP* angle) { return from_angle(angle->angle()); }
303 
305  static aa_tf_rotmatp ident() {
306  static const double R[] = AA_TF_ROTMATP_IDENT_INITIALIZER;
307  return from_rotmatp(R);
308  }
309 
311  double angle() const { return aa_tf_rotmatp2angle(this->data); }
312 
314  double uln() const { return aa_tf_rotmatp_uln(this->data); }
315 
317  aa_tf_rotmatp inv() const {
318  aa_tf_rotmatp Ri;
319  aa_tf_rotmatp_inv2(this->data, Ri.data);
320  return Ri;
321  }
322 };
323 
327 struct CmplxTran : aa_tf_cv {
335  CmplxTran(double angle, aa_tf_vec2 v_) : aa_tf_cv(from(angle, v_)) {}
337  CmplxTran(const AngleP &angle, aa_tf_vec2 v_) : aa_tf_cv(from(angle, v_)) {}
339  CmplxTran(const AngleP *angle, aa_tf_vec2 v_) : aa_tf_cv(from(angle, v_)) {}
341  CmplxTran(const RotMatP &R, aa_tf_vec2 v_) : aa_tf_cv(from(R, v_)) {}
343  CmplxTran(const RotMatP *R, aa_tf_vec2 v_) : aa_tf_cv(from(R, v_)) {}
345  CmplxTran(const aa_tf_cv &cv) : aa_tf_cv(from(cv)) {}
347  CmplxTran(const aa_tf_cv *cv) : aa_tf_cv(from(cv)) {}
349  CmplxTran(const struct aa_tf_tfmatp &T) : aa_tf_cv(from(T)) {}
351  CmplxTran(const struct aa_tf_tfmatp *T) : aa_tf_cv(from(T)) {}
352 
354  static aa_tf_cv ident() {
355  static const double data[] = AA_TF_COTR_IDENT_INITIALIZER;
356  return from_cv(data);
357  }
358 
360  static aa_tf_cv from_cv(const double *ptr) {
361  aa_tf_cv e;
362  e.data[0] = ptr[0];
363  e.data[1] = ptr[1];
364  e.data[2] = ptr[2];
365  e.data[3] = ptr[3];
366  return e;
367  }
368 
371  {
372  aa_tf_cv e;
373  e.c = c;
374  e.v = v;
375  return e;
376  }
377 
380  return from(Cmplx::c_cmplx(c), v);
381  }
382 
384  static aa_tf_cv from_tfmatp(const double *T) {
385  aa_tf_cv e;
386  aa_tf_tfmatp2cv(T, &e.c, &e.v);
387  return e;
388  }
389 
391  static aa_tf_cv from(double angle, aa_tf_vec2 v) {
392  return from(Cmplx::from_angle(angle), v);
393  }
395  static aa_tf_cv from(const AngleP &angle, aa_tf_vec2 v) {
396  return from(angle.angle(), v);
397  }
399  static aa_tf_cv from(const AngleP *angle, aa_tf_vec2 v) {
400  return from(angle->angle(), v);
401  }
402 
404  static aa_tf_cv from(const aa_tf_cv& cv) { return from(cv.c, cv.v); }
406  static aa_tf_cv from(const aa_tf_cv* cv) { return from(*cv); }
408  static aa_tf_cv from(const aa_tf_tfmatp& T) { return from_tfmatp(T.data); }
410  static aa_tf_cv from(const aa_tf_tfmatp* T) { return from(*T); }
411 
413  static aa_tf_cv from(const aa_tf_rotmatp *R, aa_tf_vec2 v) {
414  aa_tf_cv e;
415  e.c = aa_tf_rotmatp2cmplx(R->data);
416  e.v = v;
417  return e;
418  }
419 
421  static aa_tf_cv from(const aa_tf_rotmatp &R, aa_tf_vec2 v) {
422  return from(&R, v);
423  }
424 
426  aa_tf_cv inv() const {
427  aa_tf_cv e;
428  aa_tf_cv_inv(this->c, this->v, &e.c, &e.v);
429  return e;
430  }
431 };
432 
439 
441  TfMatP(const aa_tf_rotmatp* R_, aa_tf_vec2 v_) : aa_tf_tfmatp(from(R_, v_))
442  {}
444  TfMatP(const aa_tf_rotmatp& R_, aa_tf_vec2 v_) : aa_tf_tfmatp(from(R_, v_))
445  {}
450 
452  TfMatP(double angle, aa_tf_vec2 v_) : aa_tf_tfmatp(from(angle,v_)) {}
454  TfMatP(const AngleP &angle, aa_tf_vec2 v_) : aa_tf_tfmatp(from(angle,v_)) {}
456  TfMatP(const AngleP *angle, aa_tf_vec2 v_) : aa_tf_tfmatp(from(angle,v_)) {}
457 
459  TfMatP(const aa_tf_tfmatp *T) : aa_tf_tfmatp(*T) {}
461  TfMatP(const aa_tf_tfmatp &T) : aa_tf_tfmatp(T) {}
463  TfMatP(const aa_tf_cv* cv) : aa_tf_tfmatp(from(cv)) {}
465  TfMatP(const aa_tf_cv& cv) : aa_tf_tfmatp(from(cv)) {}
466 
468  static aa_tf_tfmatp ident() {
469  static const double data[] = AA_TF_TFMATP_IDENT_INITIALIZER;
470  return from_tfmatp(data);
471  }
472 
474  static aa_tf_tfmatp from_tfmatp(const double * ptr) {
475  aa_tf_tfmatp T;
476  memcpy(T.data, ptr, sizeof(T));
477  return T;
478  }
479 
482  aa_tf_tfmatp T;
483  aa_tf_cmplx2rotmatp(c, T.R.data);
484 
485  T.v = v;
486  return T;
487  }
488 
491  return from_cv(Cmplx::c_cmplx(c), v);
492  }
493 
494 
496  static aa_tf_tfmatp from(const aa_tf_tfmatp* T) {
497  return from_tfmatp(T->data);
498  }
499 
501  static aa_tf_tfmatp from(const aa_tf_tfmatp& T) {
502  return from_tfmatp(T.data);
503  }
504 
507  aa_tf_tfmatp T;
508  T.R = R;
509  T.v = v;
510  return T;
511  }
512 
515  return from(*R, v);
516  }
517 
520  return from_cv(c, v);
521  }
522 
525  return from_cv(c, v);
526  }
527 
529  static aa_tf_tfmatp from(double angle, aa_tf_vec2 v) {
530  return from_cv(Cmplx::from_angle(angle), v);
531  }
532 
534  static aa_tf_tfmatp from(const AngleP &angle, aa_tf_vec2 v) {
535  return from(angle.angle(), v);
536  }
537 
539  static aa_tf_tfmatp from(const AngleP* angle, aa_tf_vec2 v) {
540  return from(*angle, v);
541  }
542 
544  static aa_tf_tfmatp from(const aa_tf_cv& cv) { return from(cv.c, cv.v); }
545 
547  static aa_tf_tfmatp from(const aa_tf_cv* cv) { return from(*cv); }
548 
550  aa_tf_tfmatp inv() const {
551  aa_tf_tfmatp T;
552  aa_tf_tfmatp_inv2(this->data, T.data);
553  return T;
554  }
555 };
556 
558 static inline aa_tf_vec2
559 operator*(const Cmplx& c, const Vec2& v)
560 {
561  return aa_tf_crot(c,v);
562 }
563 
565 static inline aa_tf_vec2
566 operator*(const aa_tf_rotmatp& R, const Vec2& v)
567 {
568  return aa_tf_rotmatp_rot(R.data,v);
569 }
570 
572 static inline aa_tf_rotmatp
573 operator*(const aa_tf_rotmatp& R1, const aa_tf_rotmatp& R2)
574 {
575  aa_tf_rotmatp R12;
576  aa_tf_rotmatp_mul(R1.data,R2.data, R12.data);
577  return R12;
578 }
579 
581 static inline aa_tf_vec2
582 operator*(const aa_tf_tfmatp& T, const aa_tf_vec2& p)
583 {
584  return aa_tf_tfmatp_tf(T.data, p);
585 }
586 
588 static inline aa_tf_vec2
589 operator*(const aa_tf_cv& E, const aa_tf_vec2& p)
590 {
591  return aa_tf_cv_tf(E.c, E.v, p);
592 }
593 
594 
596 static inline aa_tf_tfmatp
597 operator*(const aa_tf_tfmatp& T1, const aa_tf_tfmatp& T2)
598 {
599  aa_tf_tfmatp T12;
600  aa_tf_tfmatp_mul(T1.data, T2.data, T12.data);
601  return T12;
602 }
603 
605 static inline aa_tf_cv
606 operator*(const aa_tf_cv& E1, const aa_tf_cv& E2)
607 {
608  aa_tf_cv E12;
609  aa_tf_cv_mul(E1.c, E1.v, E2.c, E2.v, &E12.c, &E12.v);
610  return E12;
611 }
612 
613 } // namespace amino
614 
615 #endif /* AMINO_TFP_HPP */
amino namespace
Definition: amino.hpp:60
static aa_tf_vec2 operator*(const Cmplx &c, const Vec2 &v)
Rotate a 2D vector using a complex number.
Definition: planar.hpp:559
AA_API void aa_tf_cv_inv(const aa_tf_cmplx c, const aa_tf_vec2 v, aa_tf_cmplx *ci, aa_tf_vec2 *vi)
Invert a complex number and translation vector planar transform.
AA_API void aa_tf_rotmatp_mul(const double R1[AA_RESTRICT 4], const double R2[AA_RESTRICT 4], double R12[AA_RESTRICT 4])
Multiply planar rotation matrices.
AA_API double aa_tf_rotmatp2angle(const double R[AA_RESTRICT 4])
Convert a planar rotation matrix to a rotation angle.
AA_API void aa_tf_angle2rotmatp(double angle, double R[AA_RESTRICT 4])
Convert a rotation angle to a planar rotation matrix.
AA_API double aa_tf_rotmatp_uln(const double R[4])
Logarithm of a planar rotation matrix.
AA_API aa_tf_vec2 aa_tf_cv_tf(const aa_tf_cmplx c, const aa_tf_vec2 v, const aa_tf_vec2 p)
Apply a planar transform represented with a complex number and translation vector.
AA_API double aa_tf_cmplx2angle(const aa_tf_cmplx c)
Convert a complex number to a rotation angle.
AA_API void aa_tf_tfmatp_mul(const double T1[AA_RESTRICT 6], const double T2[AA_RESTRICT 6], double T12[AA_RESTRICT 6])
Multiply (chain) two complex number and translation vector planar transforms.
AA_API void aa_tf_tfmatp2cv(const double T[AA_RESTRICT 6], aa_tf_cmplx *c, aa_tf_vec2 *v)
Convert a planar transformation matrix to a complex number and translation vector.
AA_API double aa_tf_culn(const aa_tf_cmplx c)
Logarithm of a unit complex number.
#define AA_TF_ROTMATP_IDENT_INITIALIZER
Initializer for planar rotation matrix identity element.
Definition: planar.h:74
AA_API aa_tf_cmplx aa_tf_cconj(const aa_tf_cmplx c)
Conjugate a complex number, giving the inverse rotation.
AA_API void aa_tf_tfmatp_inv2(const double T[AA_RESTRICT 6], double Ti[AA_RESTRICT 6])
Invert a planar transformation matrix.
AA_API void aa_tf_rotmatp_inv2(const double R[AA_RESTRICT 4], double Ri[AA_RESTRICT 4])
Invert a planar rotation matrix.
#define AA_TF_COTR_IDENT_INITIALIZER
Initializer for complex number and translation identity element.
Definition: planar.h:78
AA_API aa_tf_vec2 aa_tf_crot(const aa_tf_cmplx c, const aa_tf_vec2 v)
Apply a planar rotation via complex number.
AA_API void aa_tf_cmplx2rotmatp(const aa_tf_cmplx c, double R[AA_RESTRICT 4])
Convert a unit complex number to a rotation matrix.
AA_API aa_tf_vec2 aa_tf_tfmatp_tf(const double T[AA_RESTRICT 6], const aa_tf_vec2 p)
Apply a planar transform represented matrix.
AA_API aa_tf_vec2 aa_tf_rotmatp_rot(const double R[AA_RESTRICT 4], const aa_tf_vec2 v)
Apply a planar rotation via rotation matrix.
AA_API aa_tf_cmplx aa_tf_rotmatp2cmplx(const double R[AA_RESTRICT 4])
Convert a planar rotation matrix to a complex number.
AA_API void aa_tf_cv_mul(const aa_tf_cmplx c1, const aa_tf_vec2 v1, const aa_tf_cmplx c2, const aa_tf_vec2 v2, aa_tf_cmplx *c12, aa_tf_vec2 *v12)
Multiply (chain) two complex number and translation vector planar transforms.
#define AA_TF_TFMATP_IDENT_INITIALIZER
Initializer for planar transformation matrix identity element.
Definition: planar.h:81
AA_API aa_tf_cmplx aa_tf_angle2cmplx(double angle)
Convert a rotation angle to a complex number.
Memory layout for planar transform as complex number and translation vector.
Definition: type.h:81
double data[4]
data array
Definition: type.h:83
aa_tf_vec2 v
translation vector
Definition: type.h:86
aa_tf_cmplx c
rotation unit complex
Definition: type.h:85
Memory layout for a planar rotation matrix.
Definition: type.h:68
double data[4]
data array
Definition: type.h:74
Memory layout for a planar transformation matrix.
Definition: type.h:100
aa_tf_rotmatp R
the rotation matrix part
Definition: type.h:103
aa_tf_vec2 v
the origin vector part
Definition: type.h:104
double data[6]
data array
Definition: type.h:106
A planar rotation angle.
Definition: planar.hpp:137
AngleP(const aa_tf_rotmatp *R)
Construct rotation angle from a rotation matrix.
Definition: planar.hpp:151
double & angle()
Return assignable reference to the rotation angle.
Definition: planar.hpp:160
AngleP(aa_tf_cmplx c)
Construct rotation angle of the C complex number.
Definition: planar.hpp:145
AngleP()
Zero rotation.
Definition: planar.hpp:139
AngleP(const aa_tf_rotmatp &R)
Construct rotation angle from a rotation matrix.
Definition: planar.hpp:154
AngleP(double theta)
Construct rotation of angle theta.
Definition: planar.hpp:142
double angle() const
Return the rotation angle.
Definition: planar.hpp:157
AngleP(BaseCmplx::type c)
Construct rotation angle of the C++ complex number.
Definition: planar.hpp:148
Base type for complex numbers and 2D vectors.
Definition: planar.hpp:58
double & real_ref()
Assignable reference to the real part.
Definition: planar.hpp:104
::std::complex< double > type
Convenience typedef for C++ complex numbers.
Definition: planar.hpp:60
aa_tf_cmplx c_cmplx() const
Convert to a C complex number.
Definition: planar.hpp:80
BaseCmplx()
Construct a zero-valued complex number.
Definition: planar.hpp:63
static double c_imag(const aa_tf_cmplx &v)
Extract imaginary part of a C complex number.
Definition: planar.hpp:93
static double c_real(const aa_tf_cmplx &v)
Extract real part of a C complex number.
Definition: planar.hpp:88
double & imag_ref()
Assignable reference to the imaginary part.
Definition: planar.hpp:107
BaseCmplx(const aa_tf_cmplx &v)
Construct from a C complex number.
Definition: planar.hpp:72
static aa_tf_cmplx c_cmplx(type c)
Convert to a C complex number.
Definition: planar.hpp:75
static type from(const aa_tf_cmplx &v)
Convert C complex number to C++ complex number.
Definition: planar.hpp:98
BaseCmplx(type c)
Construct from a C++ complex number.
Definition: planar.hpp:69
BaseCmplx(double real, double imag)
Construct from real and imaginary values.
Definition: planar.hpp:66
Planar transformation represented with a complex number and translation vector.
Definition: planar.hpp:327
CmplxTran(const RotMatP *R, aa_tf_vec2 v_)
Construct from rotation matrix and translation vector.
Definition: planar.hpp:343
CmplxTran(Cmplx::type c_, aa_tf_vec2 v_)
Construct from a C++ complex number and translation vector.
Definition: planar.hpp:333
static aa_tf_cv from(const aa_tf_cv &cv)
Create a transformation from another complex number and translation vector.
Definition: planar.hpp:404
static aa_tf_cv from_tfmatp(const double *T)
Create a transformation from a transformation matrix.
Definition: planar.hpp:384
CmplxTran(const RotMatP &R, aa_tf_vec2 v_)
Construct from rotation matrix and translation vector.
Definition: planar.hpp:341
static aa_tf_cv from(Cmplx::type c, aa_tf_vec2 v)
Create a transformation from another complex number and translation.
Definition: planar.hpp:379
static aa_tf_cv from(double angle, aa_tf_vec2 v)
Create a transformation from a rotation angle and translation vector.
Definition: planar.hpp:391
CmplxTran(const struct aa_tf_tfmatp *T)
Construct from a transformation matrix.
Definition: planar.hpp:351
static aa_tf_cv from(const aa_tf_tfmatp *T)
Create a transformation from a transformation matrix.
Definition: planar.hpp:410
static aa_tf_cv from(aa_tf_cmplx c, aa_tf_vec2 v)
Create a transformation from another complex number and translation.
Definition: planar.hpp:370
static aa_tf_cv from(const aa_tf_rotmatp &R, aa_tf_vec2 v)
Create a transformation from a rotation matrix and translation vector.
Definition: planar.hpp:421
CmplxTran(const AngleP &angle, aa_tf_vec2 v_)
Construct from rotation angle and translation vector.
Definition: planar.hpp:337
static aa_tf_cv from(const AngleP &angle, aa_tf_vec2 v)
Create a transformation from a rotation angle and translation vector.
Definition: planar.hpp:395
CmplxTran()
Construct the identity transformation.
Definition: planar.hpp:329
CmplxTran(const struct aa_tf_tfmatp &T)
Construct from a transformation matrix.
Definition: planar.hpp:349
static aa_tf_cv from(const AngleP *angle, aa_tf_vec2 v)
Create a transformation from a rotation angle and translation vector.
Definition: planar.hpp:399
CmplxTran(aa_tf_cmplx c_, aa_tf_vec2 v_)
Construct from a C complex number and translation vector.
Definition: planar.hpp:331
aa_tf_cv inv() const
Return the inverse transformation.
Definition: planar.hpp:426
CmplxTran(const aa_tf_cv *cv)
Construct from another complex number and translation vector.
Definition: planar.hpp:347
static aa_tf_cv from(const aa_tf_tfmatp &T)
Create a transformation from a transformation matrix.
Definition: planar.hpp:408
static aa_tf_cv ident()
Return the identity transformation.
Definition: planar.hpp:354
CmplxTran(const aa_tf_cv &cv)
Construct from another complex number and translation vector.
Definition: planar.hpp:345
CmplxTran(double angle, aa_tf_vec2 v_)
Construct from rotation angle and translation vector.
Definition: planar.hpp:335
static aa_tf_cv from(const aa_tf_cv *cv)
Create a transformation from another complex number and translation vector.
Definition: planar.hpp:406
static aa_tf_cv from(const aa_tf_rotmatp *R, aa_tf_vec2 v)
Create a transformation from a rotation matrix and translation vector.
Definition: planar.hpp:413
static aa_tf_cv from_cv(const double *ptr)
Create a transformation from another complex number and translation.
Definition: planar.hpp:360
CmplxTran(const AngleP *angle, aa_tf_vec2 v_)
Construct from rotation angle and translation vector.
Definition: planar.hpp:339
A complex number.
Definition: planar.hpp:167
Cmplx conj() const
Return the complex conjugate.
Definition: planar.hpp:221
Cmplx(double real, double imag)
Construct from real and imaginary components.
Definition: planar.hpp:172
static Cmplx from(const aa_tf_rotmatp &R)
Create complex number from a rotation matrix.
Definition: planar.hpp:205
static Cmplx from_angle(double theta)
Create complex number from a rotation angle.
Definition: planar.hpp:193
static Cmplx from(const AngleP &a)
Create complex number from a rotation angle.
Definition: planar.hpp:207
double uln() const
Return the logarithm of the complex number.
Definition: planar.hpp:218
static Cmplx from(const AngleP *a)
Create complex number from a rotation angle.
Definition: planar.hpp:209
Cmplx()
Construct zero-valued complex number.
Definition: planar.hpp:169
Cmplx(const aa_tf_rotmatp *R)
Construct from a rotation matrix.
Definition: planar.hpp:184
Cmplx(const aa_tf_rotmatp &R)
Construct from a rotation matrix.
Definition: planar.hpp:181
static Cmplx from(const aa_tf_rotmatp *R)
Create complex number from a rotation matrix.
Definition: planar.hpp:203
double angle() const
Return the angle of the complex number.
Definition: planar.hpp:215
Cmplx(type c)
Construct from a C++ complex number.
Definition: planar.hpp:175
Cmplx(const AngleP &a)
Construct from a rotation angle.
Definition: planar.hpp:187
static Cmplx from_rotmatp(const double *R)
Create complex number from a rotation matrix.
Definition: planar.hpp:198
Cmplx(const AngleP *a)
Construct from a rotation angle.
Definition: planar.hpp:190
static aa_tf_cmplx ident()
Return the identity element.
Definition: planar.hpp:212
Cmplx(aa_tf_cmplx c)
Construct from a C complex number.
Definition: planar.hpp:178
A planar rotation matrix.
Definition: planar.hpp:228
static aa_tf_rotmatp from_cmplx(aa_tf_cmplx c)
Create a rotation matrix from a complex number.
Definition: planar.hpp:279
static aa_tf_rotmatp from(double angle)
Create a rotation matrix from a rotation angle.
Definition: planar.hpp:296
RotMatP()
Construct the identity rotation.
Definition: planar.hpp:230
static aa_tf_rotmatp from_rotmatp(double r11, double r12, double r21, double r22)
Create a rotation matrix from elements.
Definition: planar.hpp:261
RotMatP(const aa_tf_rotmatp &R)
Construct from another rotation matrix.
Definition: planar.hpp:233
static aa_tf_rotmatp from_angle(double theta)
Create a rotation matrix from a rotation angle.
Definition: planar.hpp:253
static aa_tf_rotmatp from_rotmatp(const double *R)
Create a rotation matrix from another rotation matrix.
Definition: planar.hpp:273
static aa_tf_rotmatp from(aa_tf_cmplx c)
Create a rotation matrix from a complex number.
Definition: planar.hpp:292
static aa_tf_rotmatp from_cmplx(Cmplx::type c)
Create a rotation matrix from a complex number.
Definition: planar.hpp:287
static aa_tf_rotmatp ident()
Create the identity rotation matrix.
Definition: planar.hpp:305
RotMatP(const AngleP *angle)
Construct from a rotation angle.
Definition: planar.hpp:250
double angle() const
Return the rotation angle.
Definition: planar.hpp:311
RotMatP(const aa_tf_rotmatp *R)
Construct from another rotation matrix.
Definition: planar.hpp:235
RotMatP(Cmplx::type c)
Construct from a C++ complex number.
Definition: planar.hpp:242
double uln() const
Return the logarithm of the rotation matrix.
Definition: planar.hpp:314
static aa_tf_rotmatp from(const AngleP *angle)
Create a rotation matrix from a rotation angle.
Definition: planar.hpp:302
static aa_tf_rotmatp from(const AngleP &angle)
Create a rotation matrix from a rotation angle.
Definition: planar.hpp:298
RotMatP(aa_tf_cmplx c)
Construct from a C complex number.
Definition: planar.hpp:244
RotMatP(const AngleP &angle)
Construct from a rotation angle.
Definition: planar.hpp:248
aa_tf_rotmatp inv() const
Return the inverse of the rotation matrix.
Definition: planar.hpp:317
static aa_tf_rotmatp from(Cmplx::type c)
Create a rotation matrix from a complex number.
Definition: planar.hpp:294
RotMatP(double angle)
Construct from a rotation angle.
Definition: planar.hpp:246
RotMatP(double r11, double r12, double r21, double r22)
Construct from another rotation matrix.
Definition: planar.hpp:237
A Planar transformation matrix.
Definition: planar.hpp:436
TfMatP(double angle, aa_tf_vec2 v_)
Construct from a rotation angle and translation vector.
Definition: planar.hpp:452
static aa_tf_tfmatp from_cv(aa_tf_cmplx c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
Definition: planar.hpp:481
TfMatP()
Construct the identity transformation.
Definition: planar.hpp:438
static aa_tf_tfmatp from(const aa_tf_tfmatp *T)
Create a transformation matrix from another transformation matrix.
Definition: planar.hpp:496
TfMatP(const AngleP *angle, aa_tf_vec2 v_)
Construct from a rotation angle and translation vector.
Definition: planar.hpp:456
static aa_tf_tfmatp from(const aa_tf_rotmatp &R, aa_tf_vec2 v)
Create a transformation matrix from a rotation matrix and translation vector.
Definition: planar.hpp:506
TfMatP(const aa_tf_rotmatp &R_, aa_tf_vec2 v_)
Construct from a rotation matrix and translation vector.
Definition: planar.hpp:444
static aa_tf_tfmatp from_tfmatp(const double *ptr)
Create a transformation matrix from values at ptr.
Definition: planar.hpp:474
TfMatP(const aa_tf_tfmatp *T)
Construct from another transformation matrix.
Definition: planar.hpp:459
TfMatP(const AngleP &angle, aa_tf_vec2 v_)
Construct from a rotation angle and translation vector.
Definition: planar.hpp:454
TfMatP(const aa_tf_cv *cv)
Construct from a complex number and translation vector.
Definition: planar.hpp:463
TfMatP(aa_tf_cmplx c, aa_tf_vec2 v_)
Construct from a complex number and translation vector.
Definition: planar.hpp:447
static aa_tf_tfmatp ident()
Return the identity transformation.
Definition: planar.hpp:468
static aa_tf_tfmatp from_cv(Cmplx::type c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
Definition: planar.hpp:490
TfMatP(const aa_tf_tfmatp &T)
Construct from another transformation matrix.
Definition: planar.hpp:461
TfMatP(Cmplx::type c, aa_tf_vec2 v_)
Construct from a complex number and translation vector.
Definition: planar.hpp:449
TfMatP(const aa_tf_rotmatp *R_, aa_tf_vec2 v_)
Construct from a rotation matrix and translation vector.
Definition: planar.hpp:441
static aa_tf_tfmatp from(const aa_tf_cv &cv)
Create a transformation matrix from a complex number and translation vector.
Definition: planar.hpp:544
static aa_tf_tfmatp from(const AngleP &angle, aa_tf_vec2 v)
Create a transformation matrix from a rotation angle and translation vector.
Definition: planar.hpp:534
TfMatP(const aa_tf_cv &cv)
Construct from a complex number and translation vector.
Definition: planar.hpp:465
static aa_tf_tfmatp from(aa_tf_cmplx c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
Definition: planar.hpp:519
static aa_tf_tfmatp from(double angle, aa_tf_vec2 v)
Create a transformation matrix from a rotation angle and translation vector.
Definition: planar.hpp:529
static aa_tf_tfmatp from(const aa_tf_cv *cv)
Create a transformation matrix from a complex number and translation vector.
Definition: planar.hpp:547
aa_tf_tfmatp inv() const
Return the inverse transformation.
Definition: planar.hpp:550
static aa_tf_tfmatp from(Cmplx::type c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
Definition: planar.hpp:524
static aa_tf_tfmatp from(const aa_tf_tfmatp &T)
Create a transformation matrix from another transformation matrix.
Definition: planar.hpp:501
static aa_tf_tfmatp from(const aa_tf_rotmatp *R, aa_tf_vec2 v)
Create a transformation matrix from a rotation matrix and translation vector.
Definition: planar.hpp:514
static aa_tf_tfmatp from(const AngleP *angle, aa_tf_vec2 v)
Create a transformation matrix from a rotation angle and translation vector.
Definition: planar.hpp:539
A 2D vector represented using a complex number.
Definition: planar.hpp:113
double & y()
Return assignable reference to the y component.
Definition: planar.hpp:133
Vec2()
Construct a zero vector.
Definition: planar.hpp:115
Vec2(aa_tf_vec2 v)
Construct from a C complex number.
Definition: planar.hpp:121
double & x()
Return assignable reference to the x component.
Definition: planar.hpp:130
double y() const
Return value of the y component.
Definition: planar.hpp:127
double x() const
Return value of the x component.
Definition: planar.hpp:124
Vec2(double x, double y)
Construct from x and y components.
Definition: planar.hpp:118
double _Complex aa_tf_cmplx
Typedef for C99 complex numbers.
Definition: type.h:57
aa_tf_cmplx aa_tf_vec2
Represent 2D vectors as complex numbers.
Definition: type.h:60