equation

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2019 License: BSD-2-Clause Imports: 1 Imported by: 0

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

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.

func NewCone

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

func (ce *Cone) Angle() float32

MaxAngle returns the cone angle.

func (*Cone) AxisA

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

AxisA returns the axis of body A.

func (*Cone) AxisB

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

AxisB returns the axis of body B.

func (*Cone) ComputeB

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

ComputeB

func (*Cone) SetAngle

func (ce *Cone) SetAngle(angle float32)

SetAngle sets the cone angle.

func (*Cone) SetAxisA

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

SetAxisA sets the axis of body A.

func (*Cone) SetAxisB

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

SetAxisB sets the axis of body B.

type Contact

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

Contact is a contact/non-penetration constraint equation.

func NewContact

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

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

func (*Contact) ComputeB

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

ComputeB

func (*Contact) Normal

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

func (*Contact) RA

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

func (*Contact) RB

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

func (*Contact) Restitution

func (ce *Contact) Restitution() float32

func (*Contact) SetNormal

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

func (*Contact) SetRA

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

func (*Contact) SetRB

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

func (*Contact) SetRestitution

func (ce *Contact) SetRestitution(r float32)

type Equation

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

Equation is a SPOOK constraint equation.

func NewEquation

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

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

func (*Equation) BodyA

func (e *Equation) BodyA() IBody

func (*Equation) BodyB

func (e *Equation) BodyB() IBody

func (*Equation) ComputeB

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

ComputeB computes the RHS of the SPOOK equation.

func (*Equation) ComputeC

func (e *Equation) ComputeC() float32

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

func (*Equation) ComputeGW

func (e *Equation) ComputeGW() float32

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

func (*Equation) ComputeGiMGt

func (e *Equation) ComputeGiMGt() float32

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

func (*Equation) ComputeGiMf

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

func (e *Equation) ComputeGq() float32

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

func (*Equation) Enabled

func (e *Equation) Enabled() bool

Enabled returns the enabled flag of the equation.

func (*Equation) Eps

func (e *Equation) Eps() float32

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) MaxForce

func (e *Equation) MaxForce() float32

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

func (*Equation) MinForce

func (e *Equation) MinForce() float32

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

func (*Equation) Multiplier

func (e *Equation) Multiplier() float32

MaxForce returns the multiplier.

func (*Equation) SetBodyA

func (e *Equation) SetBodyA(ibody IBody)

func (*Equation) SetBodyB

func (e *Equation) SetBodyB(ibody IBody)

func (*Equation) SetEnabled

func (e *Equation) SetEnabled(state bool)

SetEnable sets the enabled flag of the equation.

func (*Equation) SetMaxForce

func (e *Equation) SetMaxForce(maxForce float32)

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

func (*Equation) SetMinForce

func (e *Equation) SetMinForce(minForce float32)

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

func (*Equation) SetMultiplier

func (e *Equation) SetMultiplier(multiplier float32)

SetMultiplier sets the multiplier.

func (*Equation) SetSpookParams

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

SetSpookParams recalculates a, b, eps.

type Friction

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

Friction is a friction constraint equation.

func NewFriction

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

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

ComputeB

func (*Friction) RA

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

func (*Friction) RB

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

func (*Friction) SetRA

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

func (*Friction) SetRB

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

func (*Friction) SetTangent

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

func (*Friction) Tangent

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

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

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

ComputeB

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

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

ComputeB

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL