solver

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package physics implements a basic physics engine.

Package physics implements a basic physics engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GaussSeidel

type GaussSeidel struct {
	Solver
	// contains filtered or unexported fields
}

GaussSeidel equation solver. See https://en.wikipedia.org/wiki/Gauss-Seidel_method. The number of solver iterations determines the quality of the solution. More iterations yield a better solution but require more computation.

func NewGaussSeidel

func NewGaussSeidel() *GaussSeidel

NewGaussSeidel creates and returns a pointer to a new GaussSeidel constraint equation solver.

func (*GaussSeidel) Reset

func (gs *GaussSeidel) Reset(numBodies int)

func (*GaussSeidel) Solve

func (gs *GaussSeidel) Solve(dt float32, nBodies int) *Solution

Solve

type ISolver

type ISolver interface {
	Solve(dt float32, nBodies int) *Solution // Solve should return the number of iterations performed
	AddEquation(eq equation.IEquation)
	RemoveEquation(eq equation.IEquation) bool
	ClearEquations()
}

ISolver is the interface type for all constraint solvers.

type Solution

type Solution struct {
	VelocityDeltas        []math32.Vector3
	AngularVelocityDeltas []math32.Vector3
	Iterations            int
}

Solution represents a solver solution

type Solver

type Solver struct {
	Solution
	// contains filtered or unexported fields
}

Constraint equation solver base class.

func (*Solver) AddEquation

func (s *Solver) AddEquation(eq equation.IEquation)

AddEquation adds an equation to the solver.

func (*Solver) ClearEquations

func (s *Solver) ClearEquations()

ClearEquations removes all equations from the solver.

func (*Solver) RemoveEquation

func (s *Solver) RemoveEquation(eq equation.IEquation) bool

RemoveEquation removes the specified equation from the solver. Returns true if found, false otherwise.

Jump to

Keyboard shortcuts

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