Documentation ¶
Index ¶
- Constants
- func RestitutionClamp(effectiveVelocity float64) float64
- type Acceleration
- type AccelerationContext
- type AccelerationTarget
- func (t *AccelerationTarget) AccumulatedAngularAcceleration() dprec.Vec3
- func (t *AccelerationTarget) AccumulatedLinearAcceleration() dprec.Vec3
- func (t *AccelerationTarget) AddAngularAcceleration(acceleration dprec.Vec3)
- func (t *AccelerationTarget) AddLinearAcceleration(acceleration dprec.Vec3)
- func (t *AccelerationTarget) AngularVelocity() dprec.Vec3
- func (t *AccelerationTarget) ApplyForce(force dprec.Vec3)
- func (t *AccelerationTarget) ApplyTorque(torque dprec.Vec3)
- func (t *AccelerationTarget) LinearVelocity() dprec.Vec3
- func (t *AccelerationTarget) Mass() float64
- func (t *AccelerationTarget) Position() dprec.Vec3
- func (t *AccelerationTarget) Rotation() dprec.Quat
- 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 Medium
- 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 Acceleration ¶ added in v0.18.0
type Acceleration interface { // ApplyAcceleration applies acceleration to the target. ApplyAcceleration(ctx AccelerationContext) }
Acceleration represents a solver that can apply acceleration to a target.
type AccelerationContext ¶ added in v0.18.0
type AccelerationContext struct {
Target *AccelerationTarget
}
AccelerationContext provides information about the target that is being accelerated.
type AccelerationTarget ¶ added in v0.18.0
type AccelerationTarget struct {
// contains filtered or unexported fields
}
AccelerationTarget represents a target that can be accelerated.
func NewAccelerationTarget ¶ added in v0.18.0
func NewAccelerationTarget( mass float64, momentOfInertia dprec.Mat3, position dprec.Vec3, rotation dprec.Quat, linearVelocity dprec.Vec3, angularVelocity dprec.Vec3, ) AccelerationTarget
NewAccelerationTarget creates a new AccelerationTarget.
func (*AccelerationTarget) AccumulatedAngularAcceleration ¶ added in v0.18.0
func (t *AccelerationTarget) AccumulatedAngularAcceleration() dprec.Vec3
AccumulatedAngularAcceleration returns the accumulated angular acceleration of the target.
func (*AccelerationTarget) AccumulatedLinearAcceleration ¶ added in v0.18.0
func (t *AccelerationTarget) AccumulatedLinearAcceleration() dprec.Vec3
AccumulatedLinearAcceleration returns the accumulated linear acceleration of the target.
func (*AccelerationTarget) AddAngularAcceleration ¶ added in v0.18.0
func (t *AccelerationTarget) AddAngularAcceleration(acceleration dprec.Vec3)
AddAngularAcceleration adds angular acceleration to the target.
func (*AccelerationTarget) AddLinearAcceleration ¶ added in v0.18.0
func (t *AccelerationTarget) AddLinearAcceleration(acceleration dprec.Vec3)
AddLinearAcceleration adds linear acceleration to the target.
func (*AccelerationTarget) AngularVelocity ¶ added in v0.18.0
func (t *AccelerationTarget) AngularVelocity() dprec.Vec3
AngularVelocity returns the angular velocity of the target.
func (*AccelerationTarget) ApplyForce ¶ added in v0.18.0
func (t *AccelerationTarget) ApplyForce(force dprec.Vec3)
ApplyForce adds force to the target.
func (*AccelerationTarget) ApplyTorque ¶ added in v0.18.0
func (t *AccelerationTarget) ApplyTorque(torque dprec.Vec3)
func (*AccelerationTarget) LinearVelocity ¶ added in v0.18.0
func (t *AccelerationTarget) LinearVelocity() dprec.Vec3
LinearVelocity returns the linear velocity of the target.
func (*AccelerationTarget) Mass ¶ added in v0.18.0
func (t *AccelerationTarget) Mass() float64
Mass returns the mass of the target.
func (*AccelerationTarget) Position ¶ added in v0.18.0
func (t *AccelerationTarget) Position() dprec.Vec3
Position returns the position of the target.
func (*AccelerationTarget) Rotation ¶ added in v0.18.0
func (t *AccelerationTarget) Rotation() dprec.Quat
Rotation returns the rotation of the target.
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 Medium ¶ added in v0.18.0
type Medium interface { // Density returns the density of the medium at the specified // position. Density(position dprec.Vec3) float64 // Velocity returns the velocity of the medium at the specified // position. Velocity(position dprec.Vec3) dprec.Vec3 }
Medium represents a medium that can be used to simulate the effects of drag and lift.
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)