Blender  V3.3
IK_QJacobianSolver.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #pragma once
9 
15 #include <list>
16 #include <vector>
17 
18 #include "IK_Math.h"
19 #include "IK_QJacobian.h"
20 #include "IK_QSegment.h"
21 #include "IK_QTask.h"
22 
24  public:
27  {
28  }
29 
30  // setup pole vector constraint
32  IK_QSegment *tip, Vector3d &goal, Vector3d &polegoal, float poleangle, bool getangle);
33  float GetPoleAngle()
34  {
35  return m_poleangle;
36  }
37 
38  // call setup once before solving, if it fails don't solve
39  bool Setup(IK_QSegment *root, std::list<IK_QTask *> &tasks);
40 
41  // returns true if converged, false if max number of iterations was used
42  bool Solve(IK_QSegment *root,
43  std::list<IK_QTask *> tasks,
44  const double tolerance,
45  const int max_iterations);
46 
47  private:
48  void AddSegmentList(IK_QSegment *seg);
49  bool UpdateAngles(double &norm);
50  void ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTask *> &tasks);
51 
52  double ComputeScale();
53  void Scale(double scale, std::list<IK_QTask *> &tasks);
54 
55  private:
56  IK_QJacobian m_jacobian;
57  IK_QJacobian m_jacobian_sub;
58 
59  bool m_secondary_enabled;
60 
61  std::vector<IK_QSegment *> m_segments;
62 
63  Affine3d m_rootmatrix;
64 
65  bool m_poleconstraint;
66  bool m_getpoleangle;
67  Vector3d m_goal;
68  Vector3d m_polegoal;
69  float m_poleangle;
70  IK_QSegment *m_poletip;
71 };
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)