Documentation ¶
Index ¶
- Constants
- func RestitutionClamp(effectiveVelocity float64) float64
- type Constraint
- type Context
- func (c Context) JacobianImpulseLambda(jacobian Jacobian, drift, restitution float64) float64
- func (c Context) JacobianImpulseSolution(jacobian Jacobian, drift, restitution float64) Impulse
- func (c Context) JacobianNudgeLambda(jacobian Jacobian, drift float64) float64
- func (c Context) JacobianNudgeSolution(jacobian Jacobian, drift float64) Nudge
- type Impulse
- type Jacobian
- type Nudge
- type PairConstraint
- type PairContext
- func (c PairContext) JacobianImpulseLambda(jacobian PairJacobian, drift, restitution float64) float64
- func (c PairContext) JacobianImpulseSolution(jacobian PairJacobian, drift, restitution float64) PairImpulse
- func (c PairContext) JacobianNudgeLambda(jacobian PairJacobian, drift float64) float64
- func (c PairContext) JacobianNudgeSolution(jacobian PairJacobian, drift float64) PairNudge
- type PairImpulse
- type PairJacobian
- type PairNudge
- type Placeholder
- func (p *Placeholder) AngularVelocity() dprec.Vec3
- func (p *Placeholder) ApplyImpulse(impulse Impulse)
- func (p *Placeholder) ApplyNudge(nudge Nudge)
- func (p *Placeholder) Init(state PlaceholderState)
- func (p *Placeholder) LinearVelocity() dprec.Vec3
- func (p *Placeholder) Position() dprec.Vec3
- func (p *Placeholder) Rotation() dprec.Quat
- func (p *Placeholder) SetAngularVelocity(velocity dprec.Vec3)
- func (p *Placeholder) SetLinearVelocity(velocity dprec.Vec3)
- func (p *Placeholder) SetPosition(position dprec.Vec3)
- func (p *Placeholder) SetRotation(rotation dprec.Quat)
- type PlaceholderState
Constants ¶
const Epsilon = float64(0.00001)
Epsilon indicates a small enough amount that something could be ignored.
Variables ¶
This section is empty.
Functions ¶
func RestitutionClamp ¶ added in v0.10.0
RestitutionClamp specifies a ratio that describes how much the restitution coefficient should be allowed to apply.
The goal of this clamp is to reduce bounciness of objects when they are barely moving.
Types ¶
type Constraint ¶ added in v0.10.0
type Constraint interface { // Reset clears the internal cache state for this constraint solver. // // This is called at the start of every iteration. Reset(ctx Context) // ApplyImpulses is called by the physics engine to instruct the solver // to apply the necessary impulses to its object. // // This is called multiple times per iteration. ApplyImpulses(ctx Context) // ApplyNudges is called by the physics engine to instruct the solver to // apply the necessary nudges to its object. // // This is called multiple times per iteration. ApplyNudges(ctx Context) }
Constraint represents the algorithm necessary to solve a single-object constraint.
type Context ¶ added in v0.10.0
type Context struct { DeltaTime float64 ImpulseBeta float64 NudgeBeta float64 Target *Placeholder }
Context contains information related to single-object constraint processing.
func (Context) JacobianImpulseLambda ¶ added in v0.10.0
JacobianImpulseLambda returns the impulse lambda for the specified constraint Jacobian, positional drift and restitution.
func (Context) JacobianImpulseSolution ¶ added in v0.10.0
JacobianImpulseSolution returns an impulse solution based on the specified constraint Jacobian, positional drift and restitution.
func (Context) JacobianNudgeLambda ¶ added in v0.10.0
JacobianNudgeLambda returns the nudge lambda for the specified constraint Jacobian and positional drift.
type Jacobian ¶ added in v0.10.0
Jacobian represents the 1x6 Jacobian matrix of a single-object velocity constraint.
func (Jacobian) EffectiveVelocity ¶ added in v0.10.0
func (j Jacobian) EffectiveVelocity(target *Placeholder) float64
EffectiveVelocity returns the amount of velocity in the wrong direction of the target.
func (Jacobian) Impulse ¶ added in v0.10.0
Impulse returns an Impulse solution based on the lambda impulse amount applied according to this Jacobian.
func (Jacobian) InverseEffectiveMass ¶ added in v0.10.0
func (j Jacobian) InverseEffectiveMass(target *Placeholder) float64
InverseEffectiveMass returns the inverse of the effective mass with which the target affects the constraint.
type PairConstraint ¶ added in v0.10.0
type PairConstraint interface { // Reset clears the internal cache state for this constraint solver. // // This is called at the start of every iteration. Reset(ctx PairContext) // ApplyImpulses is called by the physics engine to instruct the solver // to apply the necessary impulses to its objects. // // This is called multiple times per iteration. ApplyImpulses(ctx PairContext) // ApplyNudges is called by the physics engine to instruct the solver to // apply the necessary nudges to its objects. // // This is called multiple times per iteration. ApplyNudges(ctx PairContext) }
PairConstraint represents the algorithm necessary to solve a double-object constraint.
type PairContext ¶ added in v0.10.0
type PairContext struct { DeltaTime float64 ImpulseBeta float64 NudgeBeta float64 Target *Placeholder Source *Placeholder }
PairContext contains information related to double-object constraint processing.
func (PairContext) JacobianImpulseLambda ¶ added in v0.10.0
func (c PairContext) JacobianImpulseLambda(jacobian PairJacobian, drift, restitution float64) float64
JacobianImpulseLambda returns the impulse lambda for the specified constraint Jacobian, positional drift and restitution.
func (PairContext) JacobianImpulseSolution ¶ added in v0.10.0
func (c PairContext) JacobianImpulseSolution(jacobian PairJacobian, drift, restitution float64) PairImpulse
JacobianImpulseSolution returns an impulse solution based on the specified constraint Jacobian, positional drift and restitution.
func (PairContext) JacobianNudgeLambda ¶ added in v0.10.0
func (c PairContext) JacobianNudgeLambda(jacobian PairJacobian, drift float64) float64
JacobianNudgeLambda returns the nudge lambda for the specified constraint Jacobian and positional drift.
func (PairContext) JacobianNudgeSolution ¶ added in v0.10.0
func (c PairContext) JacobianNudgeSolution(jacobian PairJacobian, drift float64) PairNudge
JacobianNudgeSolution returns a nudge solution based on the specified constraint Jacobian and positional drift.
type PairImpulse ¶ added in v0.10.0
type PairJacobian ¶ added in v0.10.0
PairJacobian represents the 1x12 Jacobian matrix of a double-object velocity constraint.
func (PairJacobian) EffectiveVelocity ¶ added in v0.10.0
func (j PairJacobian) EffectiveVelocity(target, source *Placeholder) float64
EffectiveVelocity returns the amount of the combined velocities of the two objects that is going in the wrong direction.
func (PairJacobian) Impulse ¶ added in v0.10.0
func (j PairJacobian) Impulse(lambda float64) PairImpulse
Impulse returns an impulse solution based on the lambda impulse amount applied according to this Jacobian.
func (PairJacobian) InverseEffectiveMass ¶ added in v0.10.0
func (j PairJacobian) InverseEffectiveMass(target, source *Placeholder) float64
InverseEffectiveMass returns the inverse of the effective mass with which the two bodies affect the constraint.
func (PairJacobian) Nudge ¶ added in v0.10.0
func (j PairJacobian) Nudge(lambda float64) PairNudge
Nudge returns a nudge solution based on the lambda nudge amount applied according to this Jacobian.
type Placeholder ¶ added in v0.10.0
type Placeholder struct {
// contains filtered or unexported fields
}
func (*Placeholder) AngularVelocity ¶ added in v0.10.0
func (p *Placeholder) AngularVelocity() dprec.Vec3
func (*Placeholder) ApplyImpulse ¶ added in v0.10.0
func (p *Placeholder) ApplyImpulse(impulse Impulse)
func (*Placeholder) ApplyNudge ¶ added in v0.10.0
func (p *Placeholder) ApplyNudge(nudge Nudge)
func (*Placeholder) Init ¶ added in v0.10.0
func (p *Placeholder) Init(state PlaceholderState)
func (*Placeholder) LinearVelocity ¶ added in v0.10.0
func (p *Placeholder) LinearVelocity() dprec.Vec3
func (*Placeholder) Position ¶ added in v0.10.0
func (p *Placeholder) Position() dprec.Vec3
func (*Placeholder) Rotation ¶ added in v0.10.0
func (p *Placeholder) Rotation() dprec.Quat
func (*Placeholder) SetAngularVelocity ¶ added in v0.10.0
func (p *Placeholder) SetAngularVelocity(velocity dprec.Vec3)
func (*Placeholder) SetLinearVelocity ¶ added in v0.10.0
func (p *Placeholder) SetLinearVelocity(velocity dprec.Vec3)
func (*Placeholder) SetPosition ¶ added in v0.10.0
func (p *Placeholder) SetPosition(position dprec.Vec3)
func (*Placeholder) SetRotation ¶ added in v0.10.0
func (p *Placeholder) SetRotation(rotation dprec.Quat)