engine: github.com/g3n/engine/experimental/physics/equation Index | Files

package equation

import "github.com/g3n/engine/experimental/physics/equation"

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

Package Files

cone.go contact.go equation.go friction.go jacobian.go rotational.go rotationalmotor.go

type Cone Uses

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.

func NewCone Uses

func NewCone(bodyA, bodyB IBody, axisA, axisB *math32.Vector3, angle, maxForce float32) *Cone

NewCone creates and returns a pointer to a new Cone equation object.

func (*Cone) Angle Uses

func (ce *Cone) Angle() float32

MaxAngle returns the cone angle.

func (*Cone) AxisA Uses

func (ce *Cone) AxisA() math32.Vector3

AxisA returns the axis of body A.

func (*Cone) AxisB Uses

func (ce *Cone) AxisB() math32.Vector3

AxisB returns the axis of body B.

func (*Cone) ComputeB Uses

func (ce *Cone) ComputeB(h float32) float32

ComputeB

func (*Cone) SetAngle Uses

func (ce *Cone) SetAngle(angle float32)

SetAngle sets the cone angle.

func (*Cone) SetAxisA Uses

func (ce *Cone) SetAxisA(axisA *math32.Vector3)

SetAxisA sets the axis of body A.

func (*Cone) SetAxisB Uses

func (ce *Cone) SetAxisB(axisB *math32.Vector3)

SetAxisB sets the axis of body B.

type Contact Uses

type Contact struct {
    Equation
    // contains filtered or unexported fields
}

Contact is a contact/non-penetration constraint equation.

func NewContact Uses

func NewContact(bodyA, bodyB IBody, minForce, maxForce float32) *Contact

NewContact creates and returns a pointer to a new Contact equation object.

func (*Contact) ComputeB Uses

func (ce *Contact) ComputeB(h float32) float32

ComputeB

func (*Contact) Normal Uses

func (ce *Contact) Normal() math32.Vector3

func (*Contact) RA Uses

func (ce *Contact) RA() math32.Vector3

func (*Contact) RB Uses

func (ce *Contact) RB() math32.Vector3

func (*Contact) Restitution Uses

func (ce *Contact) Restitution() float32

func (*Contact) SetNormal Uses

func (ce *Contact) SetNormal(newNormal *math32.Vector3)

func (*Contact) SetRA Uses

func (ce *Contact) SetRA(newRa *math32.Vector3)

func (*Contact) SetRB Uses

func (ce *Contact) SetRB(newRb *math32.Vector3)

func (*Contact) SetRestitution Uses

func (ce *Contact) SetRestitution(r float32)

type Equation Uses

type Equation struct {
    // contains filtered or unexported fields
}

Equation is a SPOOK constraint equation.

func NewEquation Uses

func NewEquation(bi, bj IBody, minForce, maxForce float32) *Equation

NewEquation creates and returns a pointer to a new Equation object.

func (*Equation) BodyA Uses

func (e *Equation) BodyA() IBody

func (*Equation) BodyB Uses

func (e *Equation) BodyB() IBody

func (*Equation) ComputeB Uses

func (e *Equation) ComputeB(h float32) float32

ComputeB computes the RHS of the SPOOK equation.

func (*Equation) ComputeC Uses

func (e *Equation) ComputeC() float32

ComputeC computes the denominator part of the SPOOK equation: C = G*inv(M)*G' + eps.

func (*Equation) ComputeGW Uses

func (e *Equation) ComputeGW() float32

ComputeGW computes G*W, where W are the body velocities.

func (*Equation) ComputeGiMGt Uses

func (e *Equation) ComputeGiMGt() float32

ComputeGiMGt computes G*inv(M)*G'.

func (*Equation) ComputeGiMf Uses

func (e *Equation) ComputeGiMf() float32

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) ComputeGq Uses

func (e *Equation) ComputeGq() float32

ComputeGq computes G*q, where q are the generalized body coordinates.

func (*Equation) Enabled Uses

func (e *Equation) Enabled() bool

Enabled returns the enabled flag of the equation.

func (*Equation) Eps Uses

func (e *Equation) Eps() float32

Returns epsilon - the regularization constant which is multiplied by the identity matrix.

func (*Equation) JeA Uses

func (e *Equation) JeA() JacobianElement

func (*Equation) JeB Uses

func (e *Equation) JeB() JacobianElement

func (*Equation) MaxForce Uses

func (e *Equation) MaxForce() float32

MaxForce returns the maximum force to be applied by the constraint.

func (*Equation) MinForce Uses

func (e *Equation) MinForce() float32

MinForce returns the minimum force to be applied by the constraint.

func (*Equation) Multiplier Uses

func (e *Equation) Multiplier() float32

MaxForce returns the multiplier.

func (*Equation) SetBodyA Uses

func (e *Equation) SetBodyA(ibody IBody)

func (*Equation) SetBodyB Uses

func (e *Equation) SetBodyB(ibody IBody)

func (*Equation) SetEnabled Uses

func (e *Equation) SetEnabled(state bool)

SetEnable sets the enabled flag of the equation.

func (*Equation) SetMaxForce Uses

func (e *Equation) SetMaxForce(maxForce float32)

SetMaxForce sets the maximum force to be applied by the constraint.

func (*Equation) SetMinForce Uses

func (e *Equation) SetMinForce(minForce float32)

SetMinForce sets the minimum force to be applied by the constraint.

func (*Equation) SetMultiplier Uses

func (e *Equation) SetMultiplier(multiplier float32)

SetMultiplier sets the multiplier.

func (*Equation) SetSpookParams Uses

func (e *Equation) SetSpookParams(stiffness, relaxation float32, timeStep float32)

SetSpookParams recalculates a, b, eps.

type Friction Uses

type Friction struct {
    Equation
    // contains filtered or unexported fields
}

Friction is a friction constraint equation.

func NewFriction Uses

func NewFriction(bodyA, bodyB IBody, slipForce float32) *Friction

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) ComputeB Uses

func (fe *Friction) ComputeB(h float32) float32

ComputeB

func (*Friction) RA Uses

func (fe *Friction) RA() math32.Vector3

func (*Friction) RB Uses

func (fe *Friction) RB() math32.Vector3

func (*Friction) SetRA Uses

func (fe *Friction) SetRA(newRa *math32.Vector3)

func (*Friction) SetRB Uses

func (fe *Friction) SetRB(newRb *math32.Vector3)

func (*Friction) SetTangent Uses

func (fe *Friction) SetTangent(newTangent *math32.Vector3)

func (*Friction) Tangent Uses

func (fe *Friction) Tangent() math32.Vector3

type IBody Uses

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 Uses

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 Uses

type JacobianElement struct {
    // contains filtered or unexported fields
}

JacobianElement contains 6 entries, 3 spatial and 3 rotational degrees of freedom.

func (*JacobianElement) MultiplyElement Uses

func (je *JacobianElement) MultiplyElement(je2 *JacobianElement) float32

MultiplyElement multiplies the JacobianElement with another JacobianElement. None of the elements are changed.

func (*JacobianElement) MultiplyVectors Uses

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 Uses

func (je *JacobianElement) Rotational() math32.Vector3

Rotational returns the rotational component of the JacobianElement.

func (*JacobianElement) SetRotational Uses

func (je *JacobianElement) SetRotational(rotational *math32.Vector3)

Rotational sets the rotational component of the JacobianElement.

func (*JacobianElement) SetSpatial Uses

func (je *JacobianElement) SetSpatial(spatial *math32.Vector3)

SetSpatial sets the spatial component of the JacobianElement.

func (*JacobianElement) Spatial Uses

func (je *JacobianElement) Spatial() math32.Vector3

Spatial returns the spatial component of the JacobianElement.

type Rotational Uses

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 Uses

func NewRotational(bodyA, bodyB IBody, maxForce float32) *Rotational

NewRotational creates and returns a pointer to a new Rotational equation object.

func (*Rotational) AxisA Uses

func (re *Rotational) AxisA() math32.Vector3

AxisA returns the axis of body A.

func (*Rotational) AxisB Uses

func (re *Rotational) AxisB() math32.Vector3

AxisB returns the axis of body B.

func (*Rotational) ComputeB Uses

func (re *Rotational) ComputeB(h float32) float32

ComputeB

func (*Rotational) MaxAngle Uses

func (re *Rotational) MaxAngle() float32

MaxAngle returns the maximum angle.

func (*Rotational) SetAxisA Uses

func (re *Rotational) SetAxisA(axisA *math32.Vector3)

SetAxisA sets the axis of body A.

func (*Rotational) SetAxisB Uses

func (re *Rotational) SetAxisB(axisB *math32.Vector3)

SetAxisB sets the axis of body B.

func (*Rotational) SetMaxAngle Uses

func (re *Rotational) SetMaxAngle(angle float32)

SetAngle sets the maximum angle.

type RotationalMotor Uses

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 Uses

func NewRotationalMotor(bodyA, bodyB IBody, maxForce float32) *RotationalMotor

NewRotationalMotor creates and returns a pointer to a new RotationalMotor equation object.

func (*RotationalMotor) AxisA Uses

func (ce *RotationalMotor) AxisA() math32.Vector3

AxisA returns the axis of body A.

func (*RotationalMotor) AxisB Uses

func (ce *RotationalMotor) AxisB() math32.Vector3

AxisB returns the axis of body B.

func (*RotationalMotor) ComputeB Uses

func (re *RotationalMotor) ComputeB(h float32) float32

ComputeB

func (*RotationalMotor) SetAxisA Uses

func (ce *RotationalMotor) SetAxisA(axisA *math32.Vector3)

SetAxisA sets the axis of body A.

func (*RotationalMotor) SetAxisB Uses

func (ce *RotationalMotor) SetAxisB(axisB *math32.Vector3)

SetAxisB sets the axis of body B.

func (*RotationalMotor) SetTargetSpeed Uses

func (ce *RotationalMotor) SetTargetSpeed(speed float32)

SetTargetSpeed sets the target speed.

func (*RotationalMotor) TargetSpeed Uses

func (ce *RotationalMotor) TargetSpeed() float32

TargetSpeed returns the target speed.

Package equation imports 1 packages (graph) and is imported by 3 packages. Updated 2018-07-24. Refresh now. Tools for package owners.