Blender  V2.93
IK_solver.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  * Original author: Laurence
19  */
20 
55 #ifndef __IK_SOLVER_H__
56 #define __IK_SOLVER_H__
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
96 typedef void IK_Segment;
97 
99  IK_XDOF = 1,
100  IK_YDOF = 2,
101  IK_ZDOF = 4,
104  IK_TRANS_ZDOF = 32
105 };
106 
107 typedef enum IK_SegmentAxis {
108  IK_X = 0,
109  IK_Y = 1,
110  IK_Z = 2,
113  IK_TRANS_Z = 5
115 
116 extern IK_Segment *IK_CreateSegment(int flag);
117 extern void IK_FreeSegment(IK_Segment *seg);
118 
119 extern void IK_SetParent(IK_Segment *seg, IK_Segment *parent);
120 extern void IK_SetTransform(
121  IK_Segment *seg, float start[3], float rest_basis[][3], float basis[][3], float length);
122 extern void IK_SetLimit(IK_Segment *seg, IK_SegmentAxis axis, float lmin, float lmax);
123 extern void IK_SetStiffness(IK_Segment *seg, IK_SegmentAxis axis, float stiffness);
124 
125 extern void IK_GetBasisChange(IK_Segment *seg, float basis_change[][3]);
126 extern void IK_GetTranslationChange(IK_Segment *seg, float *translation_change);
127 
141 typedef void IK_Solver;
142 
144 void IK_FreeSolver(IK_Solver *solver);
145 
146 void IK_SolverAddGoal(IK_Solver *solver, IK_Segment *tip, float goal[3], float weight);
148  IK_Segment *tip,
149  float goal[][3],
150  float weight);
152  IK_Segment *tip,
153  float goal[3],
154  float polegoal[3],
155  float poleangle,
156  int getangle);
157 float IK_SolverGetPoleAngle(IK_Solver *solver);
158 
159 int IK_Solve(IK_Solver *solver, float tolerance, int max_iterations);
160 
161 #define IK_STRETCH_STIFF_EPS 0.01f
162 #define IK_STRETCH_STIFF_MIN 0.001f
163 #define IK_STRETCH_STIFF_MAX 1e10
164 
165 #ifdef __cplusplus
166 }
167 #endif
168 
169 #endif // __IK_SOLVER_H__
IK_Solver * IK_CreateSolver(IK_Segment *root)
Definition: IK_Solver.cpp:275
float IK_SolverGetPoleAngle(IK_Solver *solver)
Definition: IK_Solver.cpp:371
IK_Segment * IK_CreateSegment(int flag)
Definition: IK_Solver.cpp:103
void IK_SolverSetPoleVectorConstraint(IK_Solver *solver, IK_Segment *tip, float goal[3], float polegoal[3], float poleangle, int getangle)
Definition: IK_Solver.cpp:348
void IK_Segment
Definition: IK_solver.h:96
void IK_SetParent(IK_Segment *seg, IK_Segment *parent)
Definition: IK_Solver.cpp:137
void IK_FreeSolver(IK_Solver *solver)
Definition: IK_Solver.cpp:286
void IK_FreeSegment(IK_Segment *seg)
Definition: IK_Solver.cpp:128
@ IK_ZDOF
Definition: IK_solver.h:101
@ IK_TRANS_XDOF
Definition: IK_solver.h:102
@ IK_TRANS_ZDOF
Definition: IK_solver.h:104
@ IK_XDOF
Definition: IK_solver.h:99
@ IK_YDOF
Definition: IK_solver.h:100
@ IK_TRANS_YDOF
Definition: IK_solver.h:103
void IK_SolverAddGoalOrientation(IK_Solver *solver, IK_Segment *tip, float goal[][3], float weight)
Definition: IK_Solver.cpp:320
void IK_SetLimit(IK_Segment *seg, IK_SegmentAxis axis, float lmin, float lmax)
Definition: IK_Solver.cpp:187
void IK_SolverAddGoal(IK_Solver *solver, IK_Segment *tip, float goal[3], float weight)
Definition: IK_Solver.cpp:301
int IK_Solve(IK_Solver *solver, float tolerance, int max_iterations)
Definition: IK_Solver.cpp:402
void IK_SetTransform(IK_Segment *seg, float start[3], float rest_basis[][3], float basis[][3], float length)
Definition: IK_Solver.cpp:148
void IK_GetBasisChange(IK_Segment *seg, float basis_change[][3])
Definition: IK_Solver.cpp:240
IK_SegmentAxis
Definition: IK_solver.h:107
@ IK_X
Definition: IK_solver.h:108
@ IK_TRANS_X
Definition: IK_solver.h:111
@ IK_Y
Definition: IK_solver.h:109
@ IK_TRANS_Y
Definition: IK_solver.h:112
@ IK_TRANS_Z
Definition: IK_solver.h:113
@ IK_Z
Definition: IK_solver.h:110
void IK_SetStiffness(IK_Segment *seg, IK_SegmentAxis axis, float stiffness)
Definition: IK_Solver.cpp:210
void IK_GetTranslationChange(IK_Segment *seg, float *translation_change)
Definition: IK_Solver.cpp:261
void IK_Solver
Definition: IK_solver.h:141
SIMD_FORCE_INLINE btScalar length(const btQuaternion &q)
Return the length of a quaternion.
Definition: btQuaternion.h:895
IK_SegmentFlag
IK_SegmentAxis