-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathSingleBoneAngularPlaneConstraint.cs
48 lines (32 loc) · 1.19 KB
/
SingleBoneAngularPlaneConstraint.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System;
using BEPUutilities;
namespace BEPUik
{
public class SingleBoneAngularPlaneConstraint : SingleBoneConstraint
{
/// <summary>
/// Gets or sets normal of the plane which the bone's axis will be constrained to..
/// </summary>
public Vector3 PlaneNormal;
/// <summary>
/// Axis to constrain to the plane in the bone's local space.
/// </summary>
public Vector3 BoneLocalAxis;
protected internal override void UpdateJacobiansAndVelocityBias()
{
linearJacobian = new Matrix3x3();
Vector3 boneAxis;
Quaternion.Transform(ref BoneLocalAxis, ref TargetBone.Orientation, out boneAxis);
Vector3 jacobian;
Vector3.Cross(ref boneAxis, ref PlaneNormal, out jacobian);
angularJacobian = new Matrix3x3
{
M11 = jacobian.X,
M12 = jacobian.Y,
M13 = jacobian.Z,
};
Vector3.Dot(ref boneAxis, ref PlaneNormal, out velocityBias.X);
velocityBias.X = -errorCorrectionFactor * velocityBias.X;
}
}
}