Documentation ¶
Overview ¶
Package equation implements SPOOK equations based on the 2007 PhD thesis of Claude Lacoursière titled "Ghosts and Machines: Regularized Variational Methods for Interactive Simulations of Multibodies with Dry Frictional Contacts"
Index ¶
- type Cone
- type Contact
- func (ce *Contact) ComputeB(h float32) float32
- func (ce *Contact) Normal() math32.Vector3
- func (ce *Contact) RA() math32.Vector3
- func (ce *Contact) RB() math32.Vector3
- func (ce *Contact) Restitution() float32
- func (ce *Contact) SetNormal(newNormal *math32.Vector3)
- func (ce *Contact) SetRA(newRa *math32.Vector3)
- func (ce *Contact) SetRB(newRb *math32.Vector3)
- func (ce *Contact) SetRestitution(r float32)
- type Equation
- func (e *Equation) BodyA() IBody
- func (e *Equation) BodyB() IBody
- func (e *Equation) ComputeB(h float32) float32
- func (e *Equation) ComputeC() float32
- func (e *Equation) ComputeGW() float32
- func (e *Equation) ComputeGiMGt() float32
- func (e *Equation) ComputeGiMf() float32
- func (e *Equation) ComputeGq() float32
- func (e *Equation) Enabled() bool
- func (e *Equation) Eps() float32
- func (e *Equation) JeA() JacobianElement
- func (e *Equation) JeB() JacobianElement
- func (e *Equation) MaxForce() float32
- func (e *Equation) MinForce() float32
- func (e *Equation) Multiplier() float32
- func (e *Equation) SetBodyA(ibody IBody)
- func (e *Equation) SetBodyB(ibody IBody)
- func (e *Equation) SetEnabled(state bool)
- func (e *Equation) SetMaxForce(maxForce float32)
- func (e *Equation) SetMinForce(minForce float32)
- func (e *Equation) SetMultiplier(multiplier float32)
- func (e *Equation) SetSpookParams(stiffness, relaxation float32, timeStep float32)
- type Friction
- func (fe *Friction) ComputeB(h float32) float32
- func (fe *Friction) RA() math32.Vector3
- func (fe *Friction) RB() math32.Vector3
- func (fe *Friction) SetRA(newRa *math32.Vector3)
- func (fe *Friction) SetRB(newRb *math32.Vector3)
- func (fe *Friction) SetTangent(newTangent *math32.Vector3)
- func (fe *Friction) Tangent() math32.Vector3
- type IBody
- type IEquation
- type JacobianElement
- func (je *JacobianElement) MultiplyElement(je2 *JacobianElement) float32
- func (je *JacobianElement) MultiplyVectors(spatial *math32.Vector3, rotational *math32.Vector3) float32
- func (je *JacobianElement) Rotational() math32.Vector3
- func (je *JacobianElement) SetRotational(rotational *math32.Vector3)
- func (je *JacobianElement) SetSpatial(spatial *math32.Vector3)
- func (je *JacobianElement) Spatial() math32.Vector3
- type Rotational
- func (re *Rotational) AxisA() math32.Vector3
- func (re *Rotational) AxisB() math32.Vector3
- func (re *Rotational) ComputeB(h float32) float32
- func (re *Rotational) MaxAngle() float32
- func (re *Rotational) SetAxisA(axisA *math32.Vector3)
- func (re *Rotational) SetAxisB(axisB *math32.Vector3)
- func (re *Rotational) SetMaxAngle(angle float32)
- type RotationalMotor
- func (ce *RotationalMotor) AxisA() math32.Vector3
- func (ce *RotationalMotor) AxisB() math32.Vector3
- func (re *RotationalMotor) ComputeB(h float32) float32
- func (ce *RotationalMotor) SetAxisA(axisA *math32.Vector3)
- func (ce *RotationalMotor) SetAxisB(axisB *math32.Vector3)
- func (ce *RotationalMotor) SetTargetSpeed(speed float32)
- func (ce *RotationalMotor) TargetSpeed() float32
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cone ¶
type Cone struct { Equation // contains filtered or unexported fields }
Cone is a cone constraint equation. Works to keep the given body world vectors aligned, or tilted within a given angle from each other.
type Contact ¶
type Contact struct { Equation // contains filtered or unexported fields }
Contact is a contact/non-penetration constraint equation.
func NewContact ¶
NewContact creates and returns a pointer to a new Contact equation object.
func (*Contact) Restitution ¶
func (*Contact) SetRestitution ¶
type Equation ¶
type Equation struct {
// contains filtered or unexported fields
}
Equation is a SPOOK constraint equation.
func NewEquation ¶
NewEquation creates and returns a pointer to a new Equation object.
func (*Equation) ComputeC ¶
ComputeC computes the denominator part of the SPOOK equation: C = G*inv(M)*G' + eps.
func (*Equation) ComputeGiMGt ¶
ComputeGiMGt computes G*inv(M)*G'.
func (*Equation) ComputeGiMf ¶
ComputeGiMf computes G*inv(M)*f, where M is the mass matrix with diagonal blocks for each body, and f are the forces on the bodies.
func (*Equation) Eps ¶
Returns epsilon - the regularization constant which is multiplied by the identity matrix.
func (*Equation) JeA ¶
func (e *Equation) JeA() JacobianElement
func (*Equation) JeB ¶
func (e *Equation) JeB() JacobianElement
func (*Equation) Multiplier ¶
MaxForce returns the multiplier.
func (*Equation) SetEnabled ¶
SetEnable sets the enabled flag of the equation.
func (*Equation) SetMaxForce ¶
SetMaxForce sets the maximum force to be applied by the constraint.
func (*Equation) SetMinForce ¶
SetMinForce sets the minimum force to be applied by the constraint.
func (*Equation) SetMultiplier ¶
SetMultiplier sets the multiplier.
func (*Equation) SetSpookParams ¶
SetSpookParams recalculates a, b, eps.
type Friction ¶
type Friction struct { Equation // contains filtered or unexported fields }
Friction is a friction constraint equation.
func NewFriction ¶
NewFriction creates and returns a pointer to a new Friction equation object. slipForce should be +-F_friction = +-mu * F_normal = +-mu * m * g
func (*Friction) SetTangent ¶
type IBody ¶
type IBody interface { Index() int Position() math32.Vector3 Velocity() math32.Vector3 AngularVelocity() math32.Vector3 Force() math32.Vector3 Torque() math32.Vector3 InvMassEff() float32 InvRotInertiaWorldEff() *math32.Matrix3 }
IBody is the interface of all body types.
type IEquation ¶
type IEquation interface { SetBodyA(IBody) BodyA() IBody SetBodyB(IBody) BodyB() IBody JeA() JacobianElement JeB() JacobianElement SetEnabled(state bool) Enabled() bool MinForce() float32 MaxForce() float32 Eps() float32 SetMultiplier(multiplier float32) ComputeB(h float32) float32 ComputeC() float32 }
IEquation is the interface type for all equations types.
type JacobianElement ¶
type JacobianElement struct {
// contains filtered or unexported fields
}
JacobianElement contains 6 entries, 3 spatial and 3 rotational degrees of freedom.
func (*JacobianElement) MultiplyElement ¶
func (je *JacobianElement) MultiplyElement(je2 *JacobianElement) float32
MultiplyElement multiplies the JacobianElement with another JacobianElement. None of the elements are changed.
func (*JacobianElement) MultiplyVectors ¶
func (je *JacobianElement) MultiplyVectors(spatial *math32.Vector3, rotational *math32.Vector3) float32
MultiplyElement multiplies the JacobianElement with two vectors. None of the elements are changed.
func (*JacobianElement) Rotational ¶
func (je *JacobianElement) Rotational() math32.Vector3
Rotational returns the rotational component of the JacobianElement.
func (*JacobianElement) SetRotational ¶
func (je *JacobianElement) SetRotational(rotational *math32.Vector3)
Rotational sets the rotational component of the JacobianElement.
func (*JacobianElement) SetSpatial ¶
func (je *JacobianElement) SetSpatial(spatial *math32.Vector3)
SetSpatial sets the spatial component of the JacobianElement.
func (*JacobianElement) Spatial ¶
func (je *JacobianElement) Spatial() math32.Vector3
Spatial returns the spatial component of the JacobianElement.
type Rotational ¶
type Rotational struct { Equation // contains filtered or unexported fields }
Rotational is a rotational constraint equation. Works to keep the local vectors orthogonal to each other in world space.
func NewRotational ¶
func NewRotational(bodyA, bodyB IBody, maxForce float32) *Rotational
NewRotational creates and returns a pointer to a new Rotational equation object.
func (*Rotational) AxisA ¶
func (re *Rotational) AxisA() math32.Vector3
AxisA returns the axis of body A.
func (*Rotational) AxisB ¶
func (re *Rotational) AxisB() math32.Vector3
AxisB returns the axis of body B.
func (*Rotational) MaxAngle ¶
func (re *Rotational) MaxAngle() float32
MaxAngle returns the maximum angle.
func (*Rotational) SetAxisA ¶
func (re *Rotational) SetAxisA(axisA *math32.Vector3)
SetAxisA sets the axis of body A.
func (*Rotational) SetAxisB ¶
func (re *Rotational) SetAxisB(axisB *math32.Vector3)
SetAxisB sets the axis of body B.
func (*Rotational) SetMaxAngle ¶
func (re *Rotational) SetMaxAngle(angle float32)
SetAngle sets the maximum angle.
type RotationalMotor ¶
type RotationalMotor struct { Equation // TODO maybe this should embed Rotational instead ? // contains filtered or unexported fields }
RotationalMotor is a rotational motor constraint equation. Tries to keep the relative angular velocity of the bodies to a given value.
func NewRotationalMotor ¶
func NewRotationalMotor(bodyA, bodyB IBody, maxForce float32) *RotationalMotor
NewRotationalMotor creates and returns a pointer to a new RotationalMotor equation object.
func (*RotationalMotor) AxisA ¶
func (ce *RotationalMotor) AxisA() math32.Vector3
AxisA returns the axis of body A.
func (*RotationalMotor) AxisB ¶
func (ce *RotationalMotor) AxisB() math32.Vector3
AxisB returns the axis of body B.
func (*RotationalMotor) SetAxisA ¶
func (ce *RotationalMotor) SetAxisA(axisA *math32.Vector3)
SetAxisA sets the axis of body A.
func (*RotationalMotor) SetAxisB ¶
func (ce *RotationalMotor) SetAxisB(axisB *math32.Vector3)
SetAxisB sets the axis of body B.
func (*RotationalMotor) SetTargetSpeed ¶
func (ce *RotationalMotor) SetTargetSpeed(speed float32)
SetTargetSpeed sets the target speed.
func (*RotationalMotor) TargetSpeed ¶
func (ce *RotationalMotor) TargetSpeed() float32
TargetSpeed returns the target speed.