Blender V2.61 - r43446
|
00001 00002 /* 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Original Author: Laurence 00025 * Contributor(s): Brecht 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #ifndef NAN_INCLUDED_IK_QJacobian_h 00036 00037 #define NAN_INCLUDED_IK_QJacobian_h 00038 00039 #include "TNT/cmat.h" 00040 #include <vector> 00041 #include "MT_Vector3.h" 00042 00043 class IK_QJacobian 00044 { 00045 public: 00046 typedef TNT::Matrix<MT_Scalar> TMatrix; 00047 typedef TNT::Vector<MT_Scalar> TVector; 00048 00049 IK_QJacobian(); 00050 ~IK_QJacobian(); 00051 00052 // Call once to initialize 00053 void ArmMatrices(int dof, int task_size); 00054 void SetDoFWeight(int dof, MT_Scalar weight); 00055 00056 // Iteratively called 00057 void SetBetas(int id, int size, const MT_Vector3& v); 00058 void SetDerivatives(int id, int dof_id, const MT_Vector3& v, MT_Scalar norm_weight); 00059 00060 void Invert(); 00061 00062 MT_Scalar AngleUpdate(int dof_id) const; 00063 MT_Scalar AngleUpdateNorm() const; 00064 00065 // DoF locking for inner clamping loop 00066 void Lock(int dof_id, MT_Scalar delta); 00067 00068 // Secondary task 00069 bool ComputeNullProjection(); 00070 00071 void Restrict(TVector& d_theta, TMatrix& null); 00072 void SubTask(IK_QJacobian& jacobian); 00073 00074 private: 00075 00076 void InvertSDLS(); 00077 void InvertDLS(); 00078 00079 int m_dof, m_task_size; 00080 bool m_transpose; 00081 00082 // the jacobian matrix and it's null space projector 00083 TMatrix m_jacobian, m_jacobian_tmp; 00084 TMatrix m_null; 00085 00087 TVector m_beta; 00088 00090 TVector m_d_theta; 00091 TVector m_d_norm_weight; 00092 00094 00095 TVector m_svd_w; 00096 TMatrix m_svd_v; 00097 TMatrix m_svd_u; 00098 TVector m_work1; 00099 TVector m_work2; 00100 00101 TMatrix m_svd_u_t; 00102 TVector m_svd_u_beta; 00103 00104 // space required for SDLS 00105 00106 bool m_sdls; 00107 TVector m_norm; 00108 TVector m_d_theta_tmp; 00109 MT_Scalar m_min_damp; 00110 00111 // null space task vector 00112 TVector m_alpha; 00113 00114 // dof weighting 00115 TVector m_weight; 00116 TVector m_weight_sqrt; 00117 }; 00118 00119 #endif 00120