physics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SymmetricMomentOfInertia

func SymmetricMomentOfInertia(value float32) sprec.Mat3

Types

type Body

type Body struct {
	Name string

	Position    sprec.Vec3
	Orientation sprec.Quat
	IsStatic    bool

	Mass            float32
	MomentOfInertia sprec.Mat3

	Acceleration        sprec.Vec3
	AngularAcceleration sprec.Vec3

	Velocity        sprec.Vec3
	AngularVelocity sprec.Vec3

	DragFactor        float32
	AngularDragFactor float32

	RestitutionCoef float32
	CollisionShapes []shape.Placement
	InCollision     bool
}

func (*Body) AddAcceleration

func (b *Body) AddAcceleration(amount sprec.Vec3)

func (*Body) AddAngularAcceleration

func (b *Body) AddAngularAcceleration(amount sprec.Vec3)

func (*Body) AddAngularVelocity

func (b *Body) AddAngularVelocity(amount sprec.Vec3)

func (*Body) AddVelocity

func (b *Body) AddVelocity(amount sprec.Vec3)

func (*Body) ApplyAngularImpulse

func (b *Body) ApplyAngularImpulse(impulse sprec.Vec3)

func (*Body) ApplyAngularNudge

func (b *Body) ApplyAngularNudge(nudge sprec.Vec3)

func (*Body) ApplyForce

func (b *Body) ApplyForce(force sprec.Vec3)

func (*Body) ApplyImpulse

func (b *Body) ApplyImpulse(impulse sprec.Vec3)

func (*Body) ApplyNudge

func (b *Body) ApplyNudge(nudge sprec.Vec3)

func (*Body) ApplyOffsetForce

func (b *Body) ApplyOffsetForce(offset, force sprec.Vec3)

func (*Body) ApplyOffsetImpulse

func (b *Body) ApplyOffsetImpulse(offset, impulse sprec.Vec3)

func (*Body) ApplyTorque

func (b *Body) ApplyTorque(torque sprec.Vec3)

func (*Body) ResetAcceleration

func (b *Body) ResetAcceleration()

func (*Body) ResetAngularAcceleration

func (b *Body) ResetAngularAcceleration()

func (*Body) Rotate

func (b *Body) Rotate(vector sprec.Vec3)

func (*Body) Translate

func (b *Body) Translate(offset sprec.Vec3)

type ChandelierConstraint

type ChandelierConstraint struct {
	NilConstraint
	Fixture    sprec.Vec3
	Body       *Body
	BodyAnchor sprec.Vec3
	Length     float32
}

func (ChandelierConstraint) ApplyImpulse

func (c ChandelierConstraint) ApplyImpulse(ctx Context)

func (ChandelierConstraint) ApplyNudge

func (c ChandelierConstraint) ApplyNudge(ctx Context)

func (ChandelierConstraint) Calculate

type ChandelierConstraintResult

type ChandelierConstraintResult struct {
	Jacobian Jacobian
	Drift    float32
}

type CoiloverConstraint

type CoiloverConstraint struct {
	NilConstraint

	FirstBody       *Body
	FirstBodyAnchor sprec.Vec3
	SecondBody      *Body
	FrequencyHz     float32
	DampingRatio    float32
	// contains filtered or unexported fields
}

func (*CoiloverConstraint) ApplyImpulse

func (c *CoiloverConstraint) ApplyImpulse(ctx Context)

func (*CoiloverConstraint) Reset

func (c *CoiloverConstraint) Reset()

type Constraint

type Constraint interface {
	Reset()
	ApplyImpulse(ctx Context)
	ApplyNudge(ctx Context)
}

type Context

type Context struct {
	ElapsedSeconds    float32
	ImpulseIterations int
	NudgeIterations   int
}

type Engine

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

func NewEngine

func NewEngine(step time.Duration) *Engine

func (*Engine) Add

func (e *Engine) Add(aspect interface{})

func (*Engine) AddBody

func (e *Engine) AddBody(body *Body)

func (*Engine) AddConstraint

func (e *Engine) AddConstraint(constraint Constraint)

func (*Engine) Bodies

func (e *Engine) Bodies() []*Body

func (*Engine) Update

func (e *Engine) Update(elapsedTime time.Duration)

type FixedTranslationConstraint

type FixedTranslationConstraint struct {
	NilConstraint
	Fixture sprec.Vec3
	Body    *Body
}

func (FixedTranslationConstraint) ApplyImpulse

func (c FixedTranslationConstraint) ApplyImpulse(ctx Context)

func (FixedTranslationConstraint) ApplyNudge

func (c FixedTranslationConstraint) ApplyNudge(ctx Context)

func (FixedTranslationConstraint) Calculate

type FixedTranslationConstraintResult

type FixedTranslationConstraintResult struct {
	Jacobian Jacobian
	Drift    float32
}

type GroundCollisionConstraint

type GroundCollisionConstraint struct {
	NilConstraint
	Body         *Body
	Normal       sprec.Vec3
	ContactPoint sprec.Vec3
	Depth        float32
}

func (GroundCollisionConstraint) ApplyImpulse

func (c GroundCollisionConstraint) ApplyImpulse(ctx Context)

type HingedRodConstraint

type HingedRodConstraint struct {
	NilConstraint
	FirstBody        *Body
	FirstBodyAnchor  sprec.Vec3
	SecondBody       *Body
	SecondBodyAnchor sprec.Vec3
	Length           float32
}

func (HingedRodConstraint) ApplyImpulse

func (c HingedRodConstraint) ApplyImpulse(ctx Context)

func (HingedRodConstraint) ApplyNudge

func (c HingedRodConstraint) ApplyNudge(ctx Context)

func (HingedRodConstraint) Calculate

type HingedRodConstraintResult

type HingedRodConstraintResult struct {
	Jacobian PairJacobian
	Drift    float32
}

type Jacobian

type Jacobian struct {
	SlopeVelocity        sprec.Vec3
	SlopeAngularVelocity sprec.Vec3
}

func (Jacobian) ApplyImpulse

func (j Jacobian) ApplyImpulse(body *Body, lambda float32)

func (Jacobian) ApplyNudge

func (j Jacobian) ApplyNudge(body *Body, lambda float32)

func (Jacobian) CorrectPosition

func (j Jacobian) CorrectPosition(body *Body, drift float32)

func (Jacobian) CorrectVelocity

func (j Jacobian) CorrectVelocity(body *Body)

func (Jacobian) EffectiveVelocity

func (j Jacobian) EffectiveVelocity(body *Body) float32

func (Jacobian) InverseEffectiveMass

func (j Jacobian) InverseEffectiveMass(body *Body) float32

type LimitTranslationConstraint

type LimitTranslationConstraint struct {
	NilConstraint
	FirstBody  *Body
	SecondBody *Body
	MinY       float32
	MaxY       float32
}

func (LimitTranslationConstraint) ApplyImpulse

func (c LimitTranslationConstraint) ApplyImpulse(ctx Context)

type MatchAxisConstraint

type MatchAxisConstraint struct {
	NilConstraint
	FirstBody      *Body
	FirstBodyAxis  sprec.Vec3
	SecondBody     *Body
	SecondBodyAxis sprec.Vec3
}

func (MatchAxisConstraint) ApplyImpulse

func (c MatchAxisConstraint) ApplyImpulse(ctx Context)

func (MatchAxisConstraint) ApplyNudge

func (c MatchAxisConstraint) ApplyNudge(ctx Context)

func (MatchAxisConstraint) Calculate

type MatchAxisConstraintResult

type MatchAxisConstraintResult struct {
	Jacobian PairJacobian
	Drift    float32
}

type MatchRotationConstraint

type MatchRotationConstraint struct {
	NilConstraint
	FirstBody  *Body
	SecondBody *Body
}

func (MatchRotationConstraint) ApplyImpulse

func (c MatchRotationConstraint) ApplyImpulse(ctx Context)

func (MatchRotationConstraint) ApplyNudge

func (c MatchRotationConstraint) ApplyNudge(ctx Context)

type MatchTranslationConstraint

type MatchTranslationConstraint struct {
	NilConstraint
	FirstBody       *Body
	FirstBodyAnchor sprec.Vec3
	SecondBody      *Body
	IgnoreX         bool
	IgnoreY         bool
	IgnoreZ         bool
}

func (MatchTranslationConstraint) ApplyImpulse

func (c MatchTranslationConstraint) ApplyImpulse(ctx Context)

func (MatchTranslationConstraint) ApplyNudge

func (c MatchTranslationConstraint) ApplyNudge(ctx Context)

func (MatchTranslationConstraint) Calculate

type MatchTranslationResultConstraint

type MatchTranslationResultConstraint struct {
	Jacobian PairJacobian
	Drift    float32
}

type NilConstraint

type NilConstraint struct{}

func (NilConstraint) ApplyImpulse

func (NilConstraint) ApplyImpulse(Context)

func (NilConstraint) ApplyNudge

func (NilConstraint) ApplyNudge(Context)

func (NilConstraint) Reset

func (NilConstraint) Reset()

type PairJacobian

type PairJacobian struct {
	First  Jacobian
	Second Jacobian
}

func (PairJacobian) ApplyImpulse

func (j PairJacobian) ApplyImpulse(firstBody, secondBody *Body, lambda float32)

func (PairJacobian) ApplyNudge

func (j PairJacobian) ApplyNudge(firstBody, secondBody *Body, lambda float32)

func (PairJacobian) CorrectPosition

func (j PairJacobian) CorrectPosition(firstBody, secondBody *Body, drift float32)

func (PairJacobian) CorrectVelocity

func (j PairJacobian) CorrectVelocity(firstBody, secondBody *Body)

func (PairJacobian) EffectiveVelocity

func (j PairJacobian) EffectiveVelocity(firstBody, secondBody *Body) float32

func (PairJacobian) InverseEffectiveMass

func (j PairJacobian) InverseEffectiveMass(firstBody, secondBody *Body) float32

Jump to

Keyboard shortcuts

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