Blender  V2.93
IK_QJacobianSolver.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
31 #include <list>
32 #include <vector>
33 
34 #include "IK_Math.h"
35 #include "IK_QJacobian.h"
36 #include "IK_QSegment.h"
37 #include "IK_QTask.h"
38 
40  public:
43  {
44  }
45 
46  // setup pole vector constraint
48  IK_QSegment *tip, Vector3d &goal, Vector3d &polegoal, float poleangle, bool getangle);
49  float GetPoleAngle()
50  {
51  return m_poleangle;
52  }
53 
54  // call setup once before solving, if it fails don't solve
55  bool Setup(IK_QSegment *root, std::list<IK_QTask *> &tasks);
56 
57  // returns true if converged, false if max number of iterations was used
58  bool Solve(IK_QSegment *root,
59  std::list<IK_QTask *> tasks,
60  const double tolerance,
61  const int max_iterations);
62 
63  private:
64  void AddSegmentList(IK_QSegment *seg);
65  bool UpdateAngles(double &norm);
66  void ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTask *> &tasks);
67 
68  double ComputeScale();
69  void Scale(double scale, std::list<IK_QTask *> &tasks);
70 
71  private:
72  IK_QJacobian m_jacobian;
73  IK_QJacobian m_jacobian_sub;
74 
75  bool m_secondary_enabled;
76 
77  std::vector<IK_QSegment *> m_segments;
78 
79  Affine3d m_rootmatrix;
80 
81  bool m_poleconstraint;
82  bool m_getpoleangle;
83  Vector3d m_goal;
84  Vector3d m_polegoal;
85  float m_poleangle;
86  IK_QSegment *m_poletip;
87 };
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition: btVector3.h:263
void SetPoleVectorConstraint(IK_QSegment *tip, Vector3d &goal, Vector3d &polegoal, float poleangle, bool getangle)
bool Solve(IK_QSegment *root, std::list< IK_QTask * > tasks, const double tolerance, const int max_iterations)
bool Setup(IK_QSegment *root, std::list< IK_QTask * > &tasks)