2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Original author: Laurence
24 * Contributor(s): Brecht
26 * ***** END GPL LICENSE BLOCK *****
29 /** \file iksolver/intern/IK_QTask.h
34 #ifndef __IK_QTASK_H__
35 #define __IK_QTASK_H__
37 #include "MT_Vector3.h"
38 #include "MT_Transform.h"
39 #include "MT_Matrix4x4.h"
40 #include "IK_QJacobian.h"
41 #include "IK_QSegment.h"
50 const IK_QSegment *segment
52 virtual ~IK_QTask() {}
69 MT_Scalar Weight() const
70 { return m_weight*m_weight; }
72 void SetWeight(MT_Scalar weight)
73 { m_weight = sqrt(weight); }
75 virtual void ComputeJacobian(IK_QJacobian& jacobian)=0;
77 virtual MT_Scalar Distance() const=0;
79 virtual bool PositionTask() const { return false; }
81 virtual void Scale(MT_Scalar) {}
88 const IK_QSegment *m_segment;
92 class IK_QPositionTask : public IK_QTask
97 const IK_QSegment *segment,
98 const MT_Vector3& goal
101 void ComputeJacobian(IK_QJacobian& jacobian);
103 MT_Scalar Distance() const;
105 bool PositionTask() const { return true; }
106 void Scale(MT_Scalar scale) { m_goal *= scale; m_clamp_length *= scale; }
110 MT_Scalar m_clamp_length;
113 class IK_QOrientationTask : public IK_QTask
118 const IK_QSegment *segment,
119 const MT_Matrix3x3& goal
122 MT_Scalar Distance() const { return m_distance; }
123 void ComputeJacobian(IK_QJacobian& jacobian);
127 MT_Scalar m_distance;
131 class IK_QCenterOfMassTask : public IK_QTask
134 IK_QCenterOfMassTask(
136 const IK_QSegment *segment,
137 const MT_Vector3& center
140 void ComputeJacobian(IK_QJacobian& jacobian);
142 MT_Scalar Distance() const;
144 void Scale(MT_Scalar scale) { m_goal_center *= scale; m_distance *= scale; }
147 MT_Scalar ComputeTotalMass(const IK_QSegment *segment);
148 MT_Vector3 ComputeCenter(const IK_QSegment *segment);
149 void JacobianSegment(IK_QJacobian& jacobian, MT_Vector3& center, const IK_QSegment *segment);
151 MT_Vector3 m_goal_center;
152 MT_Scalar m_total_mass_inv;
153 MT_Scalar m_distance;