Blender  V2.93
IK_QJacobian.h
Go to the documentation of this file.
1 
2 /*
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public License
5  * as published by the Free Software Foundation; either version 2
6  * of the License, or (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software Foundation,
15  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16  *
17  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
18  * All rights reserved.
19  */
20 
25 #pragma once
26 
27 #include "IK_Math.h"
28 
29 class IK_QJacobian {
30  public:
31  IK_QJacobian();
32  ~IK_QJacobian();
33 
34  // Call once to initialize
35  void ArmMatrices(int dof, int task_size);
36  void SetDoFWeight(int dof, double weight);
37 
38  // Iteratively called
39  void SetBetas(int id, int size, const Vector3d &v);
40  void SetDerivatives(int id, int dof_id, const Vector3d &v, double norm_weight);
41 
42  void Invert();
43 
44  double AngleUpdate(int dof_id) const;
45  double AngleUpdateNorm() const;
46 
47  // DoF locking for inner clamping loop
48  void Lock(int dof_id, double delta);
49 
50  // Secondary task
51  bool ComputeNullProjection();
52 
53  void Restrict(VectorXd &d_theta, MatrixXd &nullspace);
54  void SubTask(IK_QJacobian &jacobian);
55 
56  private:
57  void InvertSDLS();
58  void InvertDLS();
59 
60  int m_dof, m_task_size;
61  bool m_transpose;
62 
63  // the jacobian matrix and its null space projector
64  MatrixXd m_jacobian, m_jacobian_tmp;
65  MatrixXd m_nullspace;
66 
68  VectorXd m_beta;
69 
71  VectorXd m_d_theta;
72  VectorXd m_d_norm_weight;
73 
75  VectorXd m_svd_w;
76  MatrixXd m_svd_v;
77  MatrixXd m_svd_u;
78 
79  VectorXd m_svd_u_beta;
80 
81  // space required for SDLS
82 
83  bool m_sdls;
84  VectorXd m_norm;
85  VectorXd m_d_theta_tmp;
86  double m_min_damp;
87 
88  // null space task vector
89  VectorXd m_alpha;
90 
91  // dof weighting
92  VectorXd m_weight;
93  VectorXd m_weight_sqrt;
94 };
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
void Lock(int dof_id, double delta)
void SetDerivatives(int id, int dof_id, const Vector3d &v, double norm_weight)
void SetDoFWeight(int dof, double weight)
void Restrict(VectorXd &d_theta, MatrixXd &nullspace)
void SubTask(IK_QJacobian &jacobian)
double AngleUpdateNorm() const
void SetBetas(int id, int size, const Vector3d &v)
double AngleUpdate(int dof_id) const
void ArmMatrices(int dof, int task_size)
bool ComputeNullProjection()