doxygen: intern/iksolver tagged. Leaving out TNT, since we have it in multiple locations.
[blender.git] / intern / iksolver / intern / IK_QJacobianSolver.h
1 /*
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Original Author: Laurence
25  * Contributor(s): Brecht
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 /** \file iksolver/intern/IK_QJacobianSolver.h
31  *  \ingroup iksolver
32  */
33
34
35 #ifndef NAN_INCLUDED_IK_QJacobianSolver_h
36
37 #define NAN_INCLUDED_IK_QJacobianSolver_h
38
39 /**
40  * @author Laurence Bourn
41  * @date 28/6/2001
42  */
43
44 #include <vector>
45 #include <list>
46
47 #include "MT_Vector3.h"
48 #include "MT_Transform.h"
49 #include "IK_QJacobian.h"
50 #include "IK_QSegment.h"
51 #include "IK_QTask.h"
52
53 class IK_QJacobianSolver
54 {
55 public:
56         IK_QJacobianSolver();
57         ~IK_QJacobianSolver() {};
58
59         // setup pole vector constraint
60         void SetPoleVectorConstraint(IK_QSegment *tip, MT_Vector3& goal,
61                 MT_Vector3& polegoal, float poleangle, bool getangle);
62         float GetPoleAngle() { return m_poleangle; };
63
64         // call setup once before solving, if it fails don't solve
65         bool Setup(IK_QSegment *root, std::list<IK_QTask*>& tasks);
66
67         // returns true if converged, false if max number of iterations was used
68         bool Solve(
69                 IK_QSegment *root,
70                 std::list<IK_QTask*> tasks,
71                 const MT_Scalar tolerance,
72                 const int max_iterations
73         );
74
75 private:
76         void AddSegmentList(IK_QSegment *seg);
77         bool UpdateAngles(MT_Scalar& norm);
78         void ConstrainPoleVector(IK_QSegment *root, std::list<IK_QTask*>& tasks);
79
80         MT_Scalar ComputeScale();
81         void Scale(float scale, std::list<IK_QTask*>& tasks);
82
83 private:
84
85         IK_QJacobian m_jacobian;
86         IK_QJacobian m_jacobian_sub;
87
88         bool m_secondary_enabled;
89
90         std::vector<IK_QSegment*> m_segments;
91
92         MT_Transform m_rootmatrix;
93
94         bool m_poleconstraint;
95         bool m_getpoleangle;
96         MT_Vector3 m_goal;
97         MT_Vector3 m_polegoal;
98         float m_poleangle;
99         IK_QSegment *m_poletip;
100 };
101
102 #endif
103