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