|
|
|
@ -16,12 +16,12 @@ Matrix3d ULink::GetInertia() const { |
|
|
|
|
return R * Inertia_Tensor_Local * R.transpose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
double ULink::GetPositionalInverseMass(const Vector3d R, const Vector3d N) const{ |
|
|
|
|
double ULink::GetPositionalInverseMass(const Vector3d& R, const Vector3d& N) const{ |
|
|
|
|
const double M = Mass; |
|
|
|
|
const Matrix3d I = GetInertia(); |
|
|
|
|
return 1 / M + R.cross(N).transpose() * I.inverse() * R.cross(N); |
|
|
|
|
} |
|
|
|
|
double ULink::GetRotationalInverseMass(const Vector3d N) const{ |
|
|
|
|
double ULink::GetRotationalInverseMass(const Vector3d& N) const{ |
|
|
|
|
const Matrix3d I = GetInertia(); |
|
|
|
|
return N.transpose() * I.inverse() * N; |
|
|
|
|
} |
|
|
|
@ -62,19 +62,12 @@ void ULink::SetupJoints() const { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ULink::Update(const double H){ |
|
|
|
|
void ULink::Update(const double H, const Vector3d& ExtTransForce, const Vector3d& ExtRotForce){ |
|
|
|
|
|
|
|
|
|
// Translation
|
|
|
|
|
Vector3d ExtTransForce = Vector3d(0, 0, -9.81 * 100) * Mass * 1; |
|
|
|
|
if (IsBase) |
|
|
|
|
ExtTransForce = Vector3d::Zero(); |
|
|
|
|
|
|
|
|
|
Last_Position = Position; |
|
|
|
|
Velocity += H * ExtTransForce / Mass; |
|
|
|
|
Position += H * Velocity; |
|
|
|
|
|
|
|
|
|
// Rotation
|
|
|
|
|
const Vector3d ExtRotForce = Vector3d::Zero(); |
|
|
|
|
|
|
|
|
|
Last_Orientation = Orientation; |
|
|
|
|
Vector3d w = AngularVelocity; |
|
|
|
|