1 #ifndef math_LinearTransformations_H__
2 #define math_LinearTransformations_H__
8 #include "../geo/Vectors.h"
19 template<
class Scalar>
26 Myself(): theta_(0, 0, 0), need_(
true) {
29 Myself(Myself
const& b): theta_(b.theta_), need_(b.need_) {
38 void calcMatrix()
const {
41 if (
noEPS(self->theta_.length2()) == 0) {
46 double angle(self->theta_.length());
47 double cs(cos(angle / 2.0));
48 double sn(sin(angle / 2.0));
53 tmp.
entry(0, 1, 2*axis.x()*axis.y()*
squ(sn) - 2*axis.z()*cs*sn);
54 tmp.
entry(1, 0, 2*axis.y()*axis.x()*
squ(sn) + 2*axis.z()*cs*sn);
55 tmp.
entry(0, 2, 2*axis.x()*axis.z()*
squ(sn) + 2*axis.y()*cs*sn);
56 tmp.
entry(2, 0, 2*axis.z()*axis.x()*
squ(sn) - 2*axis.y()*cs*sn);
57 tmp.
entry(1, 2, 2*axis.y()*axis.z()*
squ(sn) - 2*axis.x()*cs*sn);
58 tmp.
entry(2, 1, 2*axis.z()*axis.y()*
squ(sn) + 2*axis.x()*cs*sn);
60 ((
Rotation3D*)
this)->LinearTransformation<Scalar>::matrix(tmp);
61 self()->need_ =
false;
76 self(b.self,
Self<Myself>::COPY_FROM) {
131 Scalar
const&
theta(
size_t i)
const {
132 return self->theta_(i);
144 Scalar
const&
theta(
size_t i, Scalar
const& s) {
146 if (i == 0)
self()->theta_.x(s);
147 else if (i == 1)
self()->theta_.y(s);
148 else if (i == 2)
self()->theta_.z(s);
149 self()->need_ =
true;
162 for (
size_t i = 0; i < 3; i++) {
163 theta(i, n(i) * angle);
172 for (
size_t i = 0; i < 3; i++) {
324 mid.
entry(1, 2, Scalar(-1.0));
325 mid.
entry(2, 1, Scalar( 1.0));
328 mid.
entry(0, 2, Scalar( 1.0));
329 mid.
entry(2, 0, Scalar(-1.0));
332 mid.
entry(0, 1, Scalar(-1.0));
333 mid.
entry(1, 0, Scalar( 1.0));
369 mid.
entry(1, 2, Scalar(-1.0));
370 mid.
entry(2, 1, Scalar( 1.0));
373 mid.
entry(0, 2, Scalar( 1.0));
374 mid.
entry(2, 0, Scalar(-1.0));
377 mid.
entry(0, 1, Scalar(-1.0));
378 mid.
entry(1, 0, Scalar( 1.0));
404 #endif // math_LinearTransformations_H__
Rotation3D & operator=(Rotation3D const &b)
same as copyFrom(b)
Scalar parameter(size_t i, Scalar const &s)
same as theta(i, s)
Matrix< Scalar > jacobian(Matrix< Scalar > const &x, size_t i) const
Return the jacobian matrix of this transformate.
Rotation3D & copyFrom(Rotation3D const &b)
Copy data.
Scalar const & theta(size_t i) const
Get the i -th theta.
Rotation3D & referenceFrom(Rotation3D const &b)
Reference data.
Matrix< Scalar > transformate(Matrix< Scalar > const &x) const
Do the transformate.
Matrix< Scalar > jacobian(Matrix< Scalar > const &x) const
Return the jacobian matrix (derivate by the input vector) of this transformate.
Matrix< Scalar > matrixInv() const
Return the inverse matrix.
Scalar parameter(size_t i) const
same as theta(i)
T noEPS(T value, T eps=1e-9)
如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值
Matrix< Scalar > jacobianInv(Matrix< Scalar > const &x) const
Return the jacobian matrix of the inverse form of this transformate.
Matrix transpose() const
return itself's transpose matrix
Rotation a point/vector alone an axis with given angle in 3D world.
Rotation3D(Rotation3D const &b)
Matrix & identitied()
Let itself be an identity matrix.
Entry entry(size_t r, size_t c) const
Access the entry at r x c.
void axisAngle(Vector< Scalar > const &axis, Scalar const &angle)
Setting.
Matrix< Scalar > transformateInv(Matrix< Scalar > const &x) const
Do the inverse transformate.
Rotation3D & add(Rotation3D const &r)
Concat another rotation transformation.
Matrix< Scalar > jacobianInv(Matrix< Scalar > const &x, size_t i) const
Return the jacobian matrix of the inverse form of this transformate.
Scalar const & theta(size_t i, Scalar const &s)
Set the i -th theta.
Vector normalize() const
return a normalize form of itself