35 #ifndef AMINO_PLANAR_HPP
36 #define AMINO_PLANAR_HPP
60 typedef ::std::complex<double>
type;
89 return reinterpret_cast<const type*
>(&v)->real();
94 return reinterpret_cast<const type*
>(&v)->imag();
104 double&
real_ref() {
return reinterpret_cast<double(&)[2]
>(*this)[0]; }
107 double&
imag_ref() {
return reinterpret_cast<double(&)[2]
>(*this)[1]; }
124 double x()
const {
return real(); }
127 double y()
const {
return imag(); }
157 double angle()
const {
return angle_; };
237 RotMatP(
double r11,
double r12,
double r21,
double r22)
476 memcpy(T.
data, ptr,
sizeof(T));
540 return from(*angle,
v);
static aa_tf_vec2 operator*(const Cmplx &c, const Vec2 &v)
Rotate a 2D vector using a complex number.
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.
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.
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.
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.
aa_tf_vec2 v
translation vector
aa_tf_cmplx c
rotation unit complex
Memory layout for a planar rotation matrix.
Memory layout for a planar transformation matrix.
aa_tf_rotmatp R
the rotation matrix part
aa_tf_vec2 v
the origin vector part
AngleP(const aa_tf_rotmatp *R)
Construct rotation angle from a rotation matrix.
double & angle()
Return assignable reference to the rotation angle.
AngleP(aa_tf_cmplx c)
Construct rotation angle of the C complex number.
AngleP(const aa_tf_rotmatp &R)
Construct rotation angle from a rotation matrix.
AngleP(double theta)
Construct rotation of angle theta.
double angle() const
Return the rotation angle.
AngleP(BaseCmplx::type c)
Construct rotation angle of the C++ complex number.
Base type for complex numbers and 2D vectors.
double & real_ref()
Assignable reference to the real part.
::std::complex< double > type
Convenience typedef for C++ complex numbers.
aa_tf_cmplx c_cmplx() const
Convert to a C complex number.
BaseCmplx()
Construct a zero-valued complex number.
static double c_imag(const aa_tf_cmplx &v)
Extract imaginary part of a C complex number.
static double c_real(const aa_tf_cmplx &v)
Extract real part of a C complex number.
double & imag_ref()
Assignable reference to the imaginary part.
BaseCmplx(const aa_tf_cmplx &v)
Construct from a C complex number.
static aa_tf_cmplx c_cmplx(type c)
Convert to a C complex number.
static type from(const aa_tf_cmplx &v)
Convert C complex number to C++ complex number.
BaseCmplx(type c)
Construct from a C++ complex number.
BaseCmplx(double real, double imag)
Construct from real and imaginary values.
Planar transformation represented with a complex number and translation vector.
CmplxTran(const RotMatP *R, aa_tf_vec2 v_)
Construct from rotation matrix and translation vector.
CmplxTran(Cmplx::type c_, aa_tf_vec2 v_)
Construct from a C++ complex number and translation vector.
static aa_tf_cv from(const aa_tf_cv &cv)
Create a transformation from another complex number and translation vector.
static aa_tf_cv from_tfmatp(const double *T)
Create a transformation from a transformation matrix.
CmplxTran(const RotMatP &R, aa_tf_vec2 v_)
Construct from rotation matrix and translation vector.
static aa_tf_cv from(Cmplx::type c, aa_tf_vec2 v)
Create a transformation from another complex number and translation.
static aa_tf_cv from(double angle, aa_tf_vec2 v)
Create a transformation from a rotation angle and translation vector.
CmplxTran(const struct aa_tf_tfmatp *T)
Construct from a transformation matrix.
static aa_tf_cv from(const aa_tf_tfmatp *T)
Create a transformation from a transformation matrix.
static aa_tf_cv from(aa_tf_cmplx c, aa_tf_vec2 v)
Create a transformation from another complex number and translation.
static aa_tf_cv from(const aa_tf_rotmatp &R, aa_tf_vec2 v)
Create a transformation from a rotation matrix and translation vector.
CmplxTran(const AngleP &angle, aa_tf_vec2 v_)
Construct from rotation angle and translation vector.
static aa_tf_cv from(const AngleP &angle, aa_tf_vec2 v)
Create a transformation from a rotation angle and translation vector.
CmplxTran()
Construct the identity transformation.
CmplxTran(const struct aa_tf_tfmatp &T)
Construct from a transformation matrix.
static aa_tf_cv from(const AngleP *angle, aa_tf_vec2 v)
Create a transformation from a rotation angle and translation vector.
CmplxTran(aa_tf_cmplx c_, aa_tf_vec2 v_)
Construct from a C complex number and translation vector.
aa_tf_cv inv() const
Return the inverse transformation.
CmplxTran(const aa_tf_cv *cv)
Construct from another complex number and translation vector.
static aa_tf_cv from(const aa_tf_tfmatp &T)
Create a transformation from a transformation matrix.
static aa_tf_cv ident()
Return the identity transformation.
CmplxTran(const aa_tf_cv &cv)
Construct from another complex number and translation vector.
CmplxTran(double angle, aa_tf_vec2 v_)
Construct from rotation angle and translation vector.
static aa_tf_cv from(const aa_tf_cv *cv)
Create a transformation from another complex number and translation vector.
static aa_tf_cv from(const aa_tf_rotmatp *R, aa_tf_vec2 v)
Create a transformation from a rotation matrix and translation vector.
static aa_tf_cv from_cv(const double *ptr)
Create a transformation from another complex number and translation.
CmplxTran(const AngleP *angle, aa_tf_vec2 v_)
Construct from rotation angle and translation vector.
Cmplx conj() const
Return the complex conjugate.
Cmplx(double real, double imag)
Construct from real and imaginary components.
static Cmplx from(const aa_tf_rotmatp &R)
Create complex number from a rotation matrix.
static Cmplx from_angle(double theta)
Create complex number from a rotation angle.
static Cmplx from(const AngleP &a)
Create complex number from a rotation angle.
double uln() const
Return the logarithm of the complex number.
static Cmplx from(const AngleP *a)
Create complex number from a rotation angle.
Cmplx()
Construct zero-valued complex number.
Cmplx(const aa_tf_rotmatp *R)
Construct from a rotation matrix.
Cmplx(const aa_tf_rotmatp &R)
Construct from a rotation matrix.
static Cmplx from(const aa_tf_rotmatp *R)
Create complex number from a rotation matrix.
double angle() const
Return the angle of the complex number.
Cmplx(type c)
Construct from a C++ complex number.
Cmplx(const AngleP &a)
Construct from a rotation angle.
static Cmplx from_rotmatp(const double *R)
Create complex number from a rotation matrix.
Cmplx(const AngleP *a)
Construct from a rotation angle.
static aa_tf_cmplx ident()
Return the identity element.
Cmplx(aa_tf_cmplx c)
Construct from a C complex number.
A planar rotation matrix.
static aa_tf_rotmatp from_cmplx(aa_tf_cmplx c)
Create a rotation matrix from a complex number.
static aa_tf_rotmatp from(double angle)
Create a rotation matrix from a rotation angle.
RotMatP()
Construct the identity rotation.
static aa_tf_rotmatp from_rotmatp(double r11, double r12, double r21, double r22)
Create a rotation matrix from elements.
RotMatP(const aa_tf_rotmatp &R)
Construct from another rotation matrix.
static aa_tf_rotmatp from_angle(double theta)
Create a rotation matrix from a rotation angle.
static aa_tf_rotmatp from_rotmatp(const double *R)
Create a rotation matrix from another rotation matrix.
static aa_tf_rotmatp from(aa_tf_cmplx c)
Create a rotation matrix from a complex number.
static aa_tf_rotmatp from_cmplx(Cmplx::type c)
Create a rotation matrix from a complex number.
static aa_tf_rotmatp ident()
Create the identity rotation matrix.
RotMatP(const AngleP *angle)
Construct from a rotation angle.
double angle() const
Return the rotation angle.
RotMatP(const aa_tf_rotmatp *R)
Construct from another rotation matrix.
RotMatP(Cmplx::type c)
Construct from a C++ complex number.
double uln() const
Return the logarithm of the rotation matrix.
static aa_tf_rotmatp from(const AngleP *angle)
Create a rotation matrix from a rotation angle.
static aa_tf_rotmatp from(const AngleP &angle)
Create a rotation matrix from a rotation angle.
RotMatP(aa_tf_cmplx c)
Construct from a C complex number.
RotMatP(const AngleP &angle)
Construct from a rotation angle.
aa_tf_rotmatp inv() const
Return the inverse of the rotation matrix.
static aa_tf_rotmatp from(Cmplx::type c)
Create a rotation matrix from a complex number.
RotMatP(double angle)
Construct from a rotation angle.
RotMatP(double r11, double r12, double r21, double r22)
Construct from another rotation matrix.
A Planar transformation matrix.
TfMatP(double angle, aa_tf_vec2 v_)
Construct from a rotation angle and translation vector.
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.
TfMatP()
Construct the identity transformation.
static aa_tf_tfmatp from(const aa_tf_tfmatp *T)
Create a transformation matrix from another transformation matrix.
TfMatP(const AngleP *angle, aa_tf_vec2 v_)
Construct from a rotation angle and translation vector.
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.
TfMatP(const aa_tf_rotmatp &R_, aa_tf_vec2 v_)
Construct from a rotation matrix and translation vector.
static aa_tf_tfmatp from_tfmatp(const double *ptr)
Create a transformation matrix from values at ptr.
TfMatP(const aa_tf_tfmatp *T)
Construct from another transformation matrix.
TfMatP(const AngleP &angle, aa_tf_vec2 v_)
Construct from a rotation angle and translation vector.
TfMatP(const aa_tf_cv *cv)
Construct from a complex number and translation vector.
TfMatP(aa_tf_cmplx c, aa_tf_vec2 v_)
Construct from a complex number and translation vector.
static aa_tf_tfmatp ident()
Return the identity transformation.
static aa_tf_tfmatp from_cv(Cmplx::type c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
TfMatP(const aa_tf_tfmatp &T)
Construct from another transformation matrix.
TfMatP(Cmplx::type c, aa_tf_vec2 v_)
Construct from a complex number and translation vector.
TfMatP(const aa_tf_rotmatp *R_, aa_tf_vec2 v_)
Construct from a rotation matrix and translation vector.
static aa_tf_tfmatp from(const aa_tf_cv &cv)
Create a transformation matrix from a complex number and translation vector.
static aa_tf_tfmatp from(const AngleP &angle, aa_tf_vec2 v)
Create a transformation matrix from a rotation angle and translation vector.
TfMatP(const aa_tf_cv &cv)
Construct from a complex number and translation vector.
static aa_tf_tfmatp from(aa_tf_cmplx c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
static aa_tf_tfmatp from(double angle, aa_tf_vec2 v)
Create a transformation matrix from a rotation angle and translation vector.
static aa_tf_tfmatp from(const aa_tf_cv *cv)
Create a transformation matrix from a complex number and translation vector.
aa_tf_tfmatp inv() const
Return the inverse transformation.
static aa_tf_tfmatp from(Cmplx::type c, aa_tf_vec2 v)
Create a transformation matrix from a complex number and translation vector.
static aa_tf_tfmatp from(const aa_tf_tfmatp &T)
Create a transformation matrix from another transformation matrix.
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.
static aa_tf_tfmatp from(const AngleP *angle, aa_tf_vec2 v)
Create a transformation matrix from a rotation angle and translation vector.
A 2D vector represented using a complex number.
double & y()
Return assignable reference to the y component.
Vec2()
Construct a zero vector.
Vec2(aa_tf_vec2 v)
Construct from a C complex number.
double & x()
Return assignable reference to the x component.
double y() const
Return value of the y component.
double x() const
Return value of the x component.
Vec2(double x, double y)
Construct from x and y components.
double _Complex aa_tf_cmplx
Typedef for C99 complex numbers.
aa_tf_cmplx aa_tf_vec2
Represent 2D vectors as complex numbers.