#include <Rotation.h>
Public Member Functions | |
AffineTrans (void) | |
virtual | ~AffineTrans (void) |
void | initComponents (void) |
void | setup (void) |
void | set (Vector< T > s, Quaternion< T > q, Vector< T > t, bool inv=false) |
void | free (void) |
void | clear (void) |
void | dup (AffineTrans a) |
void | computeMatrix (bool with_scale=true) |
void | computeComponents (void) |
void | initShift (void) |
void | initScale (void) |
void | initRotate (void) |
void | setShift (T x, T y, T z) |
void | setScale (T x, T y, T z) |
void | setRotate (T s, T x, T y, T z) |
void | addShift (T x, T y, T z) |
void | addScale (T x, T y, T z) |
void | addRotate (T s, T x, T y, T z) |
Vector< T > | getShift (void) |
Vector< T > | getScale (void) |
Quaternion< T > | getRotate (void) |
Matrix< T > | getMatrix (void) |
Matrix< T > | getRotMatrix (void) |
AffineTrans< T > | getInvAffine (void) |
bool | isSetComponents (void) |
bool | isSetShift (void) |
bool | isSetScale (void) |
bool | isSetRotate (void) |
bool | isNormal (void) |
Vector< T > | execMatrixTrans (Vector< T > v) |
Vector< T > | execTrans (Vector< T > v) |
Vector< T > | execInvTrans (Vector< T > v) |
Vector< T > | execRotateScale (Vector< T > v) |
Vector< T > | execInvRotateScale (Vector< T > v) |
Vector< T > | execShift (Vector< T > v) |
Vector< T > | execInvShift (Vector< T > v) |
Vector< T > | execScale (Vector< T > v) |
Vector< T > | execInvScale (Vector< T > v) |
Vector< T > | execRotate (Vector< T > v) |
Vector< T > | execInvRotate (Vector< T > v) |
T * | execTrans (T *v) |
T * | execInvTrans (T *v) |
T * | execRotateScale (T *v) |
T * | execInvRotateScale (T *v) |
T * | execShift (T *v) |
T * | execInvShift (T *v) |
T * | execScale (T *v) |
T * | execInvScale (T *v) |
T * | execRotate (T *v) |
T * | execInvRotate (T *v) |
Public Attributes | |
Matrix< T > | matrix |
Vector< T > | shift |
Vector< T > | scale |
Quaternion< T > | rotate |
bool | isInverse |
アフィン変換 拡大縮小,回転,平行移動(のみ)
変換の合成:A*B => Bの変換 -> Aの変換
Definition at line 283 of file Rotation.h.
AffineTrans | ( | void | ) | [inline] |
Definition at line 295 of file Rotation.h.
00295 { setup();}
virtual ~AffineTrans | ( | void | ) | [inline, virtual] |
Definition at line 296 of file Rotation.h.
void addRotate | ( | T | s, | |
T | x, | |||
T | y, | |||
T | z | |||
) | [inline] |
Definition at line 319 of file Rotation.h.
void addScale | ( | T | x, | |
T | y, | |||
T | z | |||
) | [inline] |
Definition at line 318 of file Rotation.h.
void addShift | ( | T | x, | |
T | y, | |||
T | z | |||
) | [inline] |
Definition at line 317 of file Rotation.h.
void clear | ( | void | ) | [inline] |
Definition at line 303 of file Rotation.h.
00303 { initComponents(); matrix.clear();}
void computeComponents | ( | void | ) | [inline] |
Definition at line 1727 of file Rotation.h.
References Matrix< T >::element(), Matrix< T >::free(), AffineTrans< T >::getRotMatrix(), AffineTrans< T >::isInverse, AffineTrans< T >::isNormal(), AffineTrans< T >::rotate, AffineTrans< T >::scale, and AffineTrans< T >::shift.
Referenced by AffineTrans< T >::getInvAffine().
01728 { 01729 T sx, sy, sz; 01730 sx = sy = sz = (T)0.0; 01731 if (!isInverse) { 01732 for (int i=1; i<=3; i++) { 01733 sx += matrix.element(i,1)*matrix.element(i,1); 01734 sy += matrix.element(i,2)*matrix.element(i,2); 01735 sz += matrix.element(i,3)*matrix.element(i,3); 01736 } 01737 } 01738 else { 01739 for (int i=1; i<=3; i++) { 01740 sx += matrix.element(1,i)*matrix.element(1,i); 01741 sy += matrix.element(2,i)*matrix.element(2,i); 01742 sz += matrix.element(3,i)*matrix.element(3,i); 01743 } 01744 } 01745 sx = (T)sqrt(sx); 01746 sy = (T)sqrt(sy); 01747 sz = (T)sqrt(sz); 01748 if (!isNormal()) return; 01749 01750 scale.set(sx, sy, sz); 01751 01752 // 01753 Matrix<T> mt = getRotMatrix(); 01754 if (!isInverse) { 01755 for (int i=1; i<=3; i++) { 01756 mt.element(i,1) /= sx; 01757 mt.element(i,2) /= sy; 01758 mt.element(i,3) /= sz; 01759 } 01760 } 01761 else { 01762 for (int i=1; i<=3; i++) { 01763 mt.element(1,i) /= sx; 01764 mt.element(2,i) /= sy; 01765 mt.element(3,i) /= sz; 01766 } 01767 } 01768 rotate = RotMatrix2Quaternion<T>(mt); 01769 mt.free(); 01770 01771 // 01772 if (!isInverse) { 01773 shift.set(matrix.element(1,4), matrix.element(2,4), matrix.element(3,4)); 01774 } 01775 else { 01776 Vector<T> sh(matrix.element(1,4)/sx, matrix.element(2,4)/sy, matrix.element(3,4)/sz); 01777 shift = rotate.execInvRotate(sh); 01778 } 01779 01780 return; 01781 }
void computeMatrix | ( | bool | with_scale = true |
) | [inline] |
Definition at line 1692 of file Rotation.h.
References Matrix< T >::element(), Matrix< T >::free(), AffineTrans< T >::rotate, AffineTrans< T >::scale, and AffineTrans< T >::shift.
Referenced by ColladaXML::addCenterScene(), ColladaXML::addScene(), and AffineTrans< T >::execMatrixTrans().
01693 { 01694 Matrix<T> sz(2, 3, 3); 01695 if (with_scale) { 01696 sz.element(1,1) = scale.x; 01697 sz.element(2,2) = scale.y; 01698 sz.element(3,3) = scale.z; 01699 } 01700 else { 01701 sz.element(1,1) = (T)1.0; 01702 sz.element(2,2) = (T)1.0; 01703 sz.element(3,3) = (T)1.0; 01704 } 01705 01706 matrix.clear(); 01707 Matrix<T> mt = rotate.getRotMatrix()*sz; 01708 for (int j=1; j<=3; j++) { 01709 for (int i=1; i<=3; i++) { 01710 matrix.element(i, j) = mt.element(i, j); 01711 } 01712 } 01713 sz.free(); 01714 mt.free(); 01715 01716 matrix.element(1,4) = shift.x; 01717 matrix.element(2,4) = shift.y; 01718 matrix.element(3,4) = shift.z; 01719 matrix.element(4,4) = (T)1.0; 01720 01721 return; 01722 }
void dup | ( | AffineTrans< T > | a | ) | [inline] |
Definition at line 1621 of file Rotation.h.
References AffineTrans< T >::dup(), and AffineTrans< T >::matrix.
Referenced by AffineTrans< T >::dup(), jbxl::newAffineTrans(), and MeshObjectData::setAffineTrans().
01622 { 01623 *this = a; 01624 matrix.dup(a.matrix); 01625 01626 return; 01627 }
T* execInvRotate | ( | T * | v | ) | [inline] |
Definition at line 370 of file Rotation.h.
00370 { return VectorInvRotation(v, rotate);}
Definition at line 352 of file Rotation.h.
00352 { return VectorInvRotation(v, rotate);}
T* execInvRotateScale | ( | T * | v | ) | [inline] |
Definition at line 362 of file Rotation.h.
00362 { if(!isInverse) return execInvScale(execInvRotate(v)); 00363 else return execInvRotate(execInvScale(v));}
Definition at line 344 of file Rotation.h.
00344 { if(!isInverse) return execInvScale(execInvRotate(v)); 00345 else return execInvRotate(execInvScale(v));}
T* execInvScale | ( | T * | v | ) | [inline] |
Definition at line 368 of file Rotation.h.
T* execInvShift | ( | T * | v | ) | [inline] |
Definition at line 366 of file Rotation.h.
T* execInvTrans | ( | T * | v | ) | [inline] |
Definition at line 357 of file Rotation.h.
00357 { if(!isInverse) return execInvScale(execInvRotate(execInvShift(v))); 00358 else return execInvShift(execInvRotate(execInvScale(v)));}
Definition at line 339 of file Rotation.h.
00339 { if(!isInverse) return execInvScale(execInvRotate(execInvShift(v))); 00340 else return execInvShift(execInvRotate(execInvScale(v)));}
Definition at line 1786 of file Rotation.h.
References AffineTrans< T >::computeMatrix(), Matrix< T >::free(), Matrix< T >::mx, Vector< T >::x, Vector< T >::y, and Vector< T >::z.
01787 { 01788 if (matrix.element(4,4)!=(T)1.0) computeMatrix(true); 01789 01790 Matrix<T> mv(1, 4); 01791 mv.mx[0] = v.x; 01792 mv.mx[1] = v.y; 01793 mv.mx[2] = v.z; 01794 mv.mx[3] = (T)1.0; 01795 01796 Matrix<T> mt = matrix*mv; 01797 Vector<T> vct; 01798 vct.x = mt.mx[0]; 01799 vct.y = mt.mx[1]; 01800 vct.z = mt.mx[2]; 01801 01802 mt.free(); 01803 mv.free(); 01804 01805 return vct; 01806 }
T* execRotate | ( | T * | v | ) | [inline] |
Definition at line 369 of file Rotation.h.
00369 { return VectorRotation(v, rotate);}
Definition at line 351 of file Rotation.h.
Referenced by BrepSolidList::addSolid().
00351 { return VectorRotation(v, rotate);}
T* execRotateScale | ( | T * | v | ) | [inline] |
Definition at line 360 of file Rotation.h.
00360 { if(!isInverse) return execRotate(execScale(v)); 00361 else return execScale(execRotate(v));}
Definition at line 342 of file Rotation.h.
00342 { if(!isInverse) return execRotate(execScale(v)); 00343 else return execScale(execRotate(v));}
T* execScale | ( | T * | v | ) | [inline] |
Definition at line 367 of file Rotation.h.
T* execShift | ( | T * | v | ) | [inline] |
Definition at line 365 of file Rotation.h.
T* execTrans | ( | T * | v | ) | [inline] |
Definition at line 355 of file Rotation.h.
00355 { if(!isInverse) return execShift(execRotate(execScale(v))); 00356 else return execScale(execRotate(execShift(v)));}
Definition at line 337 of file Rotation.h.
Referenced by BrepSolidList::addSolid().
00337 { if(!isInverse) return execShift(execRotate(execScale(v))); 00338 else return execScale(execRotate(execShift(v)));}
void free | ( | void | ) | [inline] |
Definition at line 302 of file Rotation.h.
Referenced by ColladaXML::addCenterScene(), ColladaXML::addScene(), and jbxl::freeAffineTrans().
00302 { initComponents(); matrix.free();}
AffineTrans< T > getInvAffine | ( | void | ) | [inline] |
Definition at line 1653 of file Rotation.h.
References AffineTrans< T >::computeComponents(), Matrix< T >::element(), Matrix< T >::free(), AffineTrans< T >::isInverse, AffineTrans< T >::isNormal(), AffineTrans< T >::matrix, AffineTrans< T >::rotate, AffineTrans< T >::scale, and AffineTrans< T >::shift.
01654 { 01655 AffineTrans<T> affine; 01656 if (!isNormal()) return affine; 01657 01658 Matrix<T> rsz(2, 3, 3); 01659 rsz.element(1,1) = (T)1.0/scale.x; 01660 rsz.element(2,2) = (T)1.0/scale.y; 01661 rsz.element(3,3) = (T)1.0/scale.z; 01662 01663 Matrix<T> rmt = rsz*(~rotate).getRotMatrix(); 01664 01665 affine.matrix.element(4,4) = (T)1.0; 01666 for (int j=1; j<=3; j++) { 01667 for (int i=1; i<=3; i++) { 01668 affine.matrix.element(i,j) = rmt.element(i,j); 01669 } 01670 } 01671 rsz.free(); 01672 rmt.free(); 01673 01674 Matrix<T> rst(2, 4, 4); 01675 rst.element(1,1) = rst.element(2,2) = rst.element(3,3) = rst.element(4,4) = (T)1.0; 01676 rst.element(1,4) = -shift.x; 01677 rst.element(2,4) = -shift.y; 01678 rst.element(3,4) = -shift.z; 01679 01680 affine.matrix = affine.matrix*rst; 01681 affine.isInverse = !isInverse; 01682 affine.computeComponents(); 01683 01684 rst.free(); 01685 01686 return affine; 01687 }
Matrix<T> getMatrix | ( | void | ) | [inline] |
Definition at line 324 of file Rotation.h.
00324 { return matrix;}
Quaternion<T> getRotate | ( | void | ) | [inline] |
Definition at line 323 of file Rotation.h.
00323 { return rotate;}
Matrix< T > getRotMatrix | ( | void | ) | [inline] |
Definition at line 1632 of file Rotation.h.
References Matrix< T >::element(), Matrix< T >::init(), and AffineTrans< T >::rotate.
Referenced by AffineTrans< T >::computeComponents().
01633 { 01634 Matrix<T> mt; 01635 01636 if (matrix.element(4,4)==(T)1.0) { 01637 mt.init(2, 3, 3); 01638 for (int j=1; j<=3; j++) { 01639 for (int i=1; i<=3; i++) { 01640 mt.element(i, j) = matrix.element(i, j); 01641 } 01642 } 01643 } 01644 else { 01645 mt = rotate.getRotMatrix(); 01646 } 01647 return mt; 01648 }
Vector<T> getScale | ( | void | ) | [inline] |
Definition at line 322 of file Rotation.h.
00322 { return scale;}
Vector<T> getShift | ( | void | ) | [inline] |
Definition at line 321 of file Rotation.h.
00321 { return shift;}
void initComponents | ( | void | ) | [inline] |
Definition at line 298 of file Rotation.h.
00298 { initScale(); initRotate(); initShift(); isInverse = false;}
void initRotate | ( | void | ) | [inline] |
Definition at line 311 of file Rotation.h.
00311 { rotate.init();}
void initScale | ( | void | ) | [inline] |
Definition at line 310 of file Rotation.h.
00310 { scale.set((T)1.0, (T)1.0, (T)1.0);}
void initShift | ( | void | ) | [inline] |
Definition at line 309 of file Rotation.h.
00309 { shift.init();}
bool isNormal | ( | void | ) | [inline] |
Definition at line 332 of file Rotation.h.
Referenced by AffineTrans< T >::computeComponents(), and AffineTrans< T >::getInvAffine().
00332 { if(scale.x>=JBXL_EPS && scale.y>=JBXL_EPS && scale.z>=JBXL_EPS) return true; else return false;}
bool isSetComponents | ( | void | ) | [inline] |
Definition at line 328 of file Rotation.h.
00328 { if(isSetShift() || isSetScale() || isSetRotate()) return true; else return false;}
bool isSetRotate | ( | void | ) | [inline] |
Definition at line 331 of file Rotation.h.
00331 { return (rotate!=Quaternion<T>());}
bool isSetScale | ( | void | ) | [inline] |
Definition at line 330 of file Rotation.h.
00330 { return (scale !=Vector<T>((T)1.0, (T)1.0, (T)1.0));}
bool isSetShift | ( | void | ) | [inline] |
Definition at line 329 of file Rotation.h.
00329 { return (shift !=Vector<T>());}
void set | ( | Vector< T > | s, | |
Quaternion< T > | q, | |||
Vector< T > | t, | |||
bool | inv = false | |||
) | [inline] |
Definition at line 301 of file Rotation.h.
Referenced by jbxl::operator*().
00301 { scale=s; shift=t, rotate=q; isInverse=inv; computeMatrix(true);}
void setRotate | ( | T | s, | |
T | x, | |||
T | y, | |||
T | z | |||
) | [inline] |
Definition at line 315 of file Rotation.h.
00315 { rotate.setRotation(s, x, y, z);}
void setScale | ( | T | x, | |
T | y, | |||
T | z | |||
) | [inline] |
Definition at line 314 of file Rotation.h.
00314 { scale.set(x, y, z);}
void setShift | ( | T | x, | |
T | y, | |||
T | z | |||
) | [inline] |
Definition at line 313 of file Rotation.h.
00313 { shift.set(x, y, z);}
void setup | ( | void | ) | [inline] |
Definition at line 300 of file Rotation.h.
00300 { initComponents(); matrix = Matrix<T>(2, 4, 4);}
bool isInverse |
Definition at line 292 of file Rotation.h.
Referenced by AffineTrans< T >::computeComponents(), AffineTrans< T >::getInvAffine(), and jbxl::operator*().
Definition at line 286 of file Rotation.h.
Referenced by ColladaXML::addCenterScene(), ColladaXML::addScene(), AffineTrans< T >::dup(), and AffineTrans< T >::getInvAffine().
Quaternion<T> rotate |
Definition at line 290 of file Rotation.h.
Referenced by AffineTrans< T >::computeComponents(), AffineTrans< T >::computeMatrix(), AffineTrans< T >::getInvAffine(), AffineTrans< T >::getRotMatrix(), and jbxl::operator*().
Definition at line 289 of file Rotation.h.
Referenced by ColladaXML::addScene(), ColladaXML::addTexcrdSource(), AffineTrans< T >::computeComponents(), AffineTrans< T >::computeMatrix(), AffineTrans< T >::getInvAffine(), and jbxl::operator*().
Definition at line 288 of file Rotation.h.
Referenced by AffineTrans< T >::computeComponents(), AffineTrans< T >::computeMatrix(), AffineTrans< T >::getInvAffine(), and jbxl::operator*().