Documentation ¶
Index ¶
- Constants
- Variables
- func AlwaysCollide(_ *Arbiter, _ *Space, _ interface{}) bool
- func AreaForCircle(r1, r2 float64) float64
- func AreaForPoly(count int, verts []Vector, r float64) float64
- func AreaForSegment(a, b Vector, r float64) float64
- func BodyUpdatePosition(body *Body, dt float64)
- func BodyUpdateVelocity(body *Body, gravity Vector, damping, dt float64)
- func CachedArbitersFilter(arb *Arbiter, space *Space, shape *Shape, body *Body) bool
- func CircleSegmentQuery(shape *Shape, center Vector, r1 float64, a, b Vector, r2 float64, ...)
- func CircleToCircle(info *CollisionInfo)
- func CircleToPoly(info *CollisionInfo)
- func CircleToSegment(info *CollisionInfo)
- func Clamp(f, min, max float64) float64
- func Clamp01(f float64) float64
- func CollisionError(_ *CollisionInfo)
- func ComponentActive(root *Body, threshold float64) bool
- func ContactPoints(e1, e2 Edge, points ClosestPoints, info *CollisionInfo)
- func Contains(bodies []*Body, body *Body) bool
- func ConvexHull(count int, verts []Vector, first *int, tol float64) int
- func DebugInfo(space *Space) string
- func DefaultBegin(arb *Arbiter, space *Space, _ interface{}) bool
- func DefaultPostSolve(arb *Arbiter, space *Space, _ interface{})
- func DefaultPreSolve(arb *Arbiter, space *Space, _ interface{}) bool
- func DefaultSeparate(arb *Arbiter, space *Space, _ interface{})
- func DefaultSpringForce(spring *DampedSpring, dist float64) float64
- func DoNothing(_ *Arbiter, _ *Space, _ interface{})
- func DrawConstraint(constraint *Constraint, options Drawer)
- func DrawShape(shape *Shape, options Drawer)
- func DrawSpace(space *Space, options Drawer)
- func FloodFillComponent(root *Body, body *Body)
- func Lerp(f1, f2, t float64) float64
- func LerpConst(f1, f2, d float64) float64
- func LoopIndexes(verts []Vector, count int) (int, int)
- func MarchCellHard(t, a, b, c, d, x0, x1, y0, y1 float64, marchSegment MarchSegmentFunc, ...)
- func MarchCellSoft(t, a, b, c, d, x0, x1, y0, y1 float64, marchSegment MarchSegmentFunc, ...)
- func MomentForBox(mass, width, height float64) float64
- func MomentForBox2(mass float64, box BB) float64
- func MomentForCircle(mass, r1, r2 float64, offset Vector) float64
- func MomentForPoly(mass float64, count int, verts []Vector, offset Vector, r float64) float64
- func MomentForSegment(mass float64, a, b Vector, r float64) float64
- func NearestPointQueryNearest(obj interface{}, shape *Shape, collisionId uint32, out interface{}) uint32
- func Next(i, count int) int
- func NodeSetA(node, value *Node)
- func NodeSetB(node, value *Node)
- func PolyLineCollectSegment(v0, v1 Vector, pls *PolyLineSet)
- func PolySupportPointIndex(count int, planes []SplittingPlane, n Vector) int
- func PolyToPoly(info *CollisionInfo)
- func PostStepDoNothing(space *Space, key, data interface{})
- func QHullPartition(verts []Vector, count int, a, b Vector, tol float64) int
- func QHullReduce(tol float64, verts []Vector, count int, a, pivot, b Vector, result []Vector) int
- func QueryReject(a, b *Shape) bool
- func QueryRejectConstraints(a, b *Body) bool
- func SegmentToPoly(info *CollisionInfo)
- func SegmentToSegment(info *CollisionInfo)
- func Sharpness(a, b, c Vector) float64
- func SpaceArbiterSetFilter(arb *Arbiter, space *Space) bool
- func SpaceCollideShapesFunc(obj interface{}, b *Shape, collisionId uint32, vspace interface{}) uint32
- func VoidQueryFunc(obj1 interface{}, obj2 *Shape, collisionId uint32, data interface{}) uint32
- type Arbiter
- func (arbiter *Arbiter) ApplyCachedImpulse(dt_coef float64)
- func (arbiter *Arbiter) ApplyImpulse()
- func (arb *Arbiter) Bodies() (*Body, *Body)
- func (arb *Arbiter) CallWildcardBeginA(space *Space) bool
- func (arb *Arbiter) CallWildcardBeginB(space *Space) bool
- func (arb *Arbiter) CallWildcardPostSolveA(space *Space)
- func (arb *Arbiter) CallWildcardPostSolveB(space *Space)
- func (arb *Arbiter) CallWildcardPreSolveA(space *Space) bool
- func (arb *Arbiter) CallWildcardPreSolveB(space *Space) bool
- func (arb *Arbiter) CallWildcardSeparateA(space *Space)
- func (arb *Arbiter) CallWildcardSeparateB(space *Space)
- func (arb *Arbiter) ContactPointSet() ContactPointSet
- func (arb *Arbiter) Count() int
- func (arb *Arbiter) Ignore() bool
- func (arbiter *Arbiter) Init(a, b *Shape) *Arbiter
- func (arbiter *Arbiter) IsFirstContact() bool
- func (node *Arbiter) Next(body *Body) *Arbiter
- func (arb *Arbiter) Normal() Vector
- func (arb *Arbiter) PreStep(dt, slop, bias float64)
- func (arb *Arbiter) SetContactPointSet(set *ContactPointSet)
- func (arb *Arbiter) Shapes() (*Shape, *Shape)
- func (arbiter *Arbiter) ThreadForBody(body *Body) *ArbiterThread
- func (arb *Arbiter) TotalImpulse() Vector
- func (arbiter *Arbiter) Unthread()
- func (arb *Arbiter) Update(info *CollisionInfo, space *Space)
- type ArbiterThread
- type BB
- func (bb BB) Area() float64
- func (bb BB) Center() Vector
- func (bb BB) ClampVect(v *Vector) Vector
- func (bb BB) Contains(other BB) bool
- func (bb BB) ContainsVect(v Vector) bool
- func (bb BB) Expand(v Vector) BB
- func (a BB) Intersects(b BB) bool
- func (bb BB) IntersectsSegment(a, b Vector) bool
- func (a BB) Merge(b BB) BB
- func (a BB) MergedArea(b BB) float64
- func (bb BB) Offset(v Vector) BB
- func (a BB) Proximity(b BB) float64
- func (bb BB) SegmentQuery(a, b Vector) float64
- func (bb BB) String() string
- func (bb BB) WrapVect(v Vector) Vector
- type BBQueryContext
- type BBTree
- func (tree *BBTree) Contains(obj *Shape, hashId HashValue) bool
- func (tree *BBTree) Count() int
- func (tree *BBTree) Each(f SpatialIndexIterator)
- func (tree *BBTree) GetBB(obj *Shape) BB
- func (tree *BBTree) GetMasterTree() *BBTree
- func (tree *BBTree) IncrementStamp()
- func (tree *BBTree) Insert(obj *Shape, hashId HashValue)
- func (tree *BBTree) LeafAddPairs(leaf *Node)
- func (tree *BBTree) LeafUpdate(leaf *Node) bool
- func (tree *BBTree) NewLeaf(obj *Shape) *Node
- func (tree *BBTree) NewNode(a, b *Node) *Node
- func (tree *BBTree) NodeFromPool() *Node
- func (subtree *BBTree) PairFromPool() *Pair
- func (tree *BBTree) PairInsert(a *Node, b *Node)
- func (tree *BBTree) PairsClear(leaf *Node)
- func (tree *BBTree) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
- func (tree *BBTree) RecycleNode(node *Node)
- func (tree *BBTree) RecyclePair(pair *Pair)
- func (tree *BBTree) Reindex()
- func (tree *BBTree) ReindexObject(obj *Shape, hashId HashValue)
- func (tree *BBTree) ReindexQuery(f SpatialIndexQuery, data interface{})
- func (tree *BBTree) Remove(obj *Shape, hashId HashValue)
- func (tree *BBTree) ReplaceChild(parent, child, value *Node)
- func (tree *BBTree) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, ...)
- func (tree *BBTree) SubtreeInsert(subtree *Node, leaf *Node) *Node
- func (tree *BBTree) SubtreeRemove(subtree *Node, leaf *Node) *Node
- type BBTreeVelocityFunc
- type Body
- func (body *Body) AccumulateMassFromShapes()
- func (body *Body) Activate()
- func (body *Body) ActivateStatic(filter *Shape)
- func (body *Body) AddShape(shape *Shape) *Shape
- func (body *Body) Angle() float64
- func (body *Body) AngularVelocity() float64
- func (body *Body) ApplyForceAtLocalPoint(force, point Vector)
- func (body *Body) ApplyForceAtWorldPoint(force, point Vector)
- func (body *Body) ApplyImpulseAtLocalPoint(impulse, point Vector)
- func (body *Body) ApplyImpulseAtWorldPoint(impulse, point Vector)
- func (body Body) CenterOfGravity() Vector
- func (root *Body) ComponentAdd(body *Body)
- func (body *Body) ComponentRoot() *Body
- func (body *Body) EachArbiter(f func(*Arbiter))
- func (body *Body) EachConstraint(f func(*Constraint))
- func (body *Body) EachShape(f func(*Shape))
- func (body *Body) Force() Vector
- func (body *Body) GetType() int
- func (body *Body) IdleTime() float64
- func (body *Body) IsSleeping() bool
- func (body *Body) KineticEnergy() float64
- func (body *Body) LocalToWorld(point Vector) Vector
- func (body *Body) Mass() float64
- func (body Body) Moment() float64
- func (body *Body) Position() Vector
- func (body *Body) PushArbiter(arb *Arbiter)
- func (body *Body) RemoveConstraint(constraint *Constraint)
- func (body *Body) RemoveShape(shape *Shape)
- func (body *Body) Rotation() Vector
- func (body *Body) SetAngle(angle float64)
- func (body *Body) SetAngularVelocity(angularVelocity float64)
- func (body *Body) SetForce(force Vector)
- func (body *Body) SetMass(mass float64)
- func (body *Body) SetMoment(moment float64)
- func (body *Body) SetPosition(position Vector)
- func (body *Body) SetPositionUpdateFunc(f BodyPositionFunc)
- func (body *Body) SetTorque(torque float64)
- func (body *Body) SetTransform(p Vector, a float64)
- func (body *Body) SetType(newType int)
- func (body *Body) SetVelocity(x, y float64)
- func (body *Body) SetVelocityUpdateFunc(f BodyVelocityFunc)
- func (body *Body) SetVelocityVector(v Vector)
- func (b Body) String() string
- func (body *Body) Torque() float64
- func (body *Body) UpdateVelocity(gravity Vector, damping, dt float64)
- func (body *Body) Velocity() Vector
- func (body *Body) VelocityAtLocalPoint(point Vector) Vector
- func (body *Body) VelocityAtWorldPoint(point Vector) Vector
- func (body *Body) WorldToLocal(point Vector) Vector
- type BodyPositionFunc
- type BodyVelocityFunc
- type Children
- type Circle
- func (circle *Circle) CacheData(transform Transform) BB
- func (circle *Circle) PointQuery(p Vector, info *PointQueryInfo)
- func (circle *Circle) Radius() float64
- func (circle *Circle) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo)
- func (circle *Circle) SetRadius(r float64)
- func (circle *Circle) TransformC() Vector
- type ClosestPoints
- func EPA(ctx SupportContext, v0, v1, v2 MinkowskiPoint) ClosestPoints
- func EPARecurse(ctx SupportContext, count int, hull []MinkowskiPoint, iteration int) ClosestPoints
- func GJK(ctx SupportContext, collisionId *uint32) ClosestPoints
- func GJKRecurse(ctx SupportContext, v0, v1 MinkowskiPoint, iteration int) ClosestPoints
- type CollisionBeginFunc
- type CollisionFunc
- type CollisionHandler
- type CollisionInfo
- type CollisionPostSolveFunc
- type CollisionPreSolveFunc
- type CollisionSeparateFunc
- type CollisionType
- type Constrainer
- type Constraint
- func NewConstraint(class Constrainer, a, b *Body) *Constraint
- func NewDampedRotarySpring(a, b *Body, restAngle, stiffness, damping float64) *Constraint
- func NewDampedSpring(a, b *Body, anchorA, anchorB Vector, restLength, stiffness, damping float64) *Constraint
- func NewGearJoint(a, b *Body, phase, ratio float64) *Constraint
- func NewGrooveJoint(a, b *Body, grooveA, grooveB, anchorB Vector) *Constraint
- func NewPinJoint(a, b *Body, anchorA, anchorB Vector) *Constraint
- func NewPivotJoint(a, b *Body, pivot Vector) *Constraint
- func NewPivotJoint2(a, b *Body, anchorA, anchorB Vector) *Constraint
- func NewRatchetJoint(a, b *Body, phase, ratchet float64) *Constraint
- func NewRotaryLimitJoint(a, b *Body, min, max float64) *Constraint
- func NewSimpleMotor(a, b *Body, rate float64) *Constraint
- func NewSlideJoint(a, b *Body, anchorA, anchorB Vector, min, max float64) *Constraint
- func (c *Constraint) ActivateBodies()
- func (c Constraint) ErrorBias() float64
- func (c Constraint) MaxBias() float64
- func (c Constraint) MaxForce() float64
- func (c *Constraint) Next(body *Body) *Constraint
- func (c *Constraint) SetCollideBodies(collideBodies bool)
- func (c *Constraint) SetErrorBias(errorBias float64)
- func (c *Constraint) SetMaxBias(max float64)
- func (c *Constraint) SetMaxForce(max float64)
- type ConstraintPostSolveFunc
- type ConstraintPreSolveFunc
- type Contact
- type ContactBuffer
- type ContactPointSet
- type DampedRotarySpring
- type DampedSpring
- type DampedSpringForceFunc
- type Drawer
- type Edge
- type EdgePoint
- type FColor
- type GearJoint
- type GrooveJoint
- type Handle
- type HashSet
- func (set *HashSet[T, U]) Count() uint
- func (set *HashSet[T, U]) Each(f func(U))
- func (set *HashSet[T, U]) Filter(f func(U) bool)
- func (set *HashSet[T, U]) Find(hash HashValue, ptr T) U
- func (set *HashSet[T, U]) Insert(hash HashValue, ptr T, transform func(obj T) U) U
- func (set *HashSet[T, U]) Remove(hash HashValue, ptr T) U
- type HashSetBin
- type HashValue
- type Leaf
- type MarchCellFunc
- type MarchSampleFunc
- type MarchSegmentFunc
- type MarkContext
- type Mat2x2
- type MinkowskiPoint
- type Node
- func (node *Node) IsLeaf() bool
- func (leaf *Node) MarkLeaf(context *MarkContext)
- func (subtree *Node) MarkLeafQuery(leaf *Node, left bool, context *MarkContext)
- func (subtree *Node) MarkSubtree(context *MarkContext)
- func (node *Node) Other(child *Node) *Node
- func (subtree *Node) SubtreeQuery(obj interface{}, bb BB, query SpatialIndexQuery, data interface{})
- func (subtree *Node) SubtreeSegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, ...) float64
- type Pair
- type PinJoint
- type PivotJoint
- type PointQueryContext
- type PointQueryInfo
- type PolyLine
- func (pl *PolyLine) Enqueue(v Vector) *PolyLine
- func (pl *PolyLine) IsClosed() bool
- func (pl *PolyLine) IsShort(count, start, end int, min float64) bool
- func (pl *PolyLine) Push(v Vector) *PolyLine
- func (pl *PolyLine) SimplifyCurves(tol float64) *PolyLine
- func (pl *PolyLine) SimplifyVertexes(tol float64) *PolyLine
- type PolyLineSet
- type PolyShape
- func (poly *PolyShape) CacheData(transform Transform) BB
- func (poly PolyShape) Count() int
- func (poly *PolyShape) PointQuery(p Vector, info *PointQueryInfo)
- func (poly PolyShape) Radius() float64
- func (poly *PolyShape) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
- func (poly *PolyShape) SetRadius(r float64)
- func (p *PolyShape) SetVerts(count int, verts []Vector)
- func (p *PolyShape) SetVertsRaw(count int, verts []Vector)
- func (p *PolyShape) SetVertsUnsafe(count int, verts []Vector, transform Transform)
- func (poly PolyShape) TransformVert(i int) Vector
- func (poly PolyShape) Vert(i int) Vector
- type PostStepCallback
- type PostStepCallbackFunc
- type RatchetJoint
- type RotaryLimitJoint
- type Segment
- func (seg *Segment) A() Vector
- func (seg *Segment) B() Vector
- func (seg *Segment) CacheData(transform Transform) BB
- func (seg *Segment) Normal() Vector
- func (seg *Segment) PointQuery(p Vector, info *PointQueryInfo)
- func (seg *Segment) Radius() float64
- func (seg *Segment) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
- func (seg *Segment) SetEndpoints(a, b Vector)
- func (seg *Segment) SetRadius(r float64)
- func (seg *Segment) TransformA() Vector
- func (seg *Segment) TransformB() Vector
- type SegmentQueryContext
- type SegmentQueryInfo
- type Shape
- func NewBox(body *Body, w, h, r float64) *Shape
- func NewBox2(body *Body, bb BB, r float64) *Shape
- func NewCircle(body *Body, radius float64, offset Vector) *Shape
- func NewPolyShape(body *Body, vectCount int, verts []Vector, transform Transform, radius float64) *Shape
- func NewPolyShapeRaw(body *Body, count int, verts []Vector, radius float64) *Shape
- func NewSegment(body *Body, a, b Vector, r float64) *Shape
- func NewShape(class ShapeClass, body *Body, massInfo *ShapeMassInfo) *Shape
- func (s *Shape) Area() float64
- func (s *Shape) BB() BB
- func (s *Shape) Body() *Body
- func (s *Shape) CacheBB() BB
- func (s *Shape) CenterOfGravity() Vector
- func (s *Shape) Density() float64
- func (s *Shape) Elasticity() float64
- func (s *Shape) Friction() float64
- func (s *Shape) HashId() HashValue
- func (s *Shape) Mass() float64
- func (s *Shape) MassInfo() *ShapeMassInfo
- func (s *Shape) Moment() float64
- func (s *Shape) Order() int
- func (s *Shape) Point(i uint32) SupportPoint
- func (s *Shape) PointQuery(p Vector) PointQueryInfo
- func (shape *Shape) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo) bool
- func (s *Shape) Sensor() bool
- func (s *Shape) SetBB(bb BB)
- func (s *Shape) SetCollisionType(collisionType CollisionType)
- func (s *Shape) SetDensity(density float64)
- func (s *Shape) SetElasticity(e float64)
- func (s *Shape) SetFilter(filter ShapeFilter)
- func (s *Shape) SetFriction(u float64)
- func (s *Shape) SetHashId(hashid HashValue)
- func (s *Shape) SetMass(mass float64)
- func (s *Shape) SetSensor(sensor bool)
- func (s *Shape) SetSpace(space *Space)
- func (s *Shape) SetSurfaceV(surfaceV Vector)
- func (s *Shape) Space() *Space
- func (s Shape) String() string
- func (s *Shape) Update(transform Transform) BB
- type ShapeClass
- type ShapeFilter
- type ShapeMassInfo
- type ShapePair
- type Shaper
- type SimpleMotor
- type SlideJoint
- type Space
- func (space *Space) Activate(body *Body)
- func (space *Space) AddBody(body *Body) *Body
- func (space *Space) AddConstraint(constraint *Constraint) *Constraint
- func (space *Space) AddPostStepCallback(f PostStepCallbackFunc, key, data interface{}) bool
- func (space *Space) AddShape(shape *Shape) *Shape
- func (space *Space) ArrayForBodyType(bodyType int) *[]*Body
- func (space *Space) BBQuery(bb BB, filter ShapeFilter, f SpaceBBQueryFunc, data interface{})
- func (space *Space) ContactBufferGetArray() []Contact
- func (space *Space) ContainsBody(body *Body) bool
- func (space *Space) ContainsConstraint(constraint *Constraint) bool
- func (space *Space) ContainsShape(shape *Shape) bool
- func (space *Space) Damping() float64
- func (space *Space) Deactivate(body *Body)
- func (space *Space) EachBody(f func(body *Body))
- func (space *Space) EachConstraint(f func(*Constraint))
- func (space *Space) EachShape(f func(*Shape))
- func (space *Space) FilterArbiters(body *Body, filter *Shape)
- func (space *Space) Gravity() Vector
- func (space *Space) Lock()
- func (space *Space) LookupHandler(a, b CollisionType, defaultHandler *CollisionHandler) *CollisionHandler
- func (space *Space) NewCollisionHandler(collisionTypeA, collisionTypeB CollisionType) *CollisionHandler
- func (space *Space) NewWildcardCollisionHandler(collisionType CollisionType) *CollisionHandler
- func (space *Space) PointQueryNearest(point Vector, maxDistance float64, filter ShapeFilter) *PointQueryInfo
- func (space *Space) PopContacts(count int)
- func (space *Space) PostStepCallback(key interface{}) *PostStepCallback
- func (space *Space) ProcessComponents(dt float64)
- func (space *Space) PushContacts(count int)
- func (space *Space) PushFreshContactBuffer()
- func (space *Space) ReindexShape(shape *Shape)
- func (space *Space) RemoveBody(body *Body)
- func (space *Space) RemoveConstraint(constraint *Constraint)
- func (space *Space) RemoveShape(shape *Shape)
- func (space *Space) SegmentQuery(start, end Vector, radius float64, filter ShapeFilter, f SpaceSegmentQueryFunc, ...)
- func (space *Space) SegmentQueryFirst(start, end Vector, radius float64, filter ShapeFilter) SegmentQueryInfo
- func (space *Space) SetCollisionSlop(slop float64)
- func (space *Space) SetDamping(damping float64)
- func (space *Space) SetGravity(gravity Vector)
- func (space *Space) SetStaticBody(body *Body)
- func (space *Space) ShapeQuery(shape *Shape, callback func(shape *Shape, points *ContactPointSet)) bool
- func (space *Space) Step(dt float64)
- func (space *Space) TimeStep() float64
- func (space *Space) UncacheArbiter(arb *Arbiter)
- func (space *Space) Unlock(runPostStep bool)
- func (space *Space) UseSpatialHash(dim float64, count int)
- func (space *Space) UseWildcardDefaultHandler()
- type SpaceBBQueryFunc
- type SpaceHash
- func (hash *SpaceHash) Contains(obj *Shape, hashId HashValue) bool
- func (hash *SpaceHash) Count() int
- func (hash *SpaceHash) Each(f SpatialIndexIterator)
- func (hash *SpaceHash) Insert(obj *Shape, hashId HashValue)
- func (hash *SpaceHash) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
- func (hash *SpaceHash) Reindex()
- func (hash *SpaceHash) ReindexObject(obj *Shape, hashId HashValue)
- func (hash *SpaceHash) ReindexQuery(f SpatialIndexQuery, data interface{})
- func (hash *SpaceHash) Remove(obj *Shape, hashId HashValue)
- func (hash *SpaceHash) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, ...)
- type SpaceHashBin
- type SpacePointQueryFunc
- type SpaceSegmentQueryFunc
- type SpatialIndex
- type SpatialIndexBB
- type SpatialIndexIterator
- type SpatialIndexQuery
- type SpatialIndexSegmentQuery
- type SpatialIndexer
- type SplittingPlane
- type SupportContext
- type SupportPoint
- type SupportPointFunc
- type Thread
- type Transform
- func NewTransform(a, c, tx, b, d, ty float64) Transform
- func NewTransformIdentity() Transform
- func NewTransformRigid(translate Vector, radians float64) Transform
- func NewTransformRigidInverse(t Transform) Transform
- func NewTransformRotate(radians float64) Transform
- func NewTransformScale(scaleX, scaleY float64) Transform
- func NewTransformTranslate(translate Vector) Transform
- func NewTransformTranspose(a, c, tx, b, d, ty float64) Transform
- func (t Transform) AxialScale(axis, pivot Vector, scale float64) Transform
- func (t Transform) BB(bb BB) BB
- func (t Transform) BoneScale(v0, v1 Vector) Transform
- func (t Transform) Inverse() Transform
- func (t Transform) Mult(t2 Transform) Transform
- func (t Transform) Ortho(bb BB) Transform
- func (t Transform) Point(p Vector) Vector
- func (t Transform) Vect(v Vector) Vector
- func (t Transform) Wrap(inner Transform) Transform
- type Vector
- func (v Vector) Add(other Vector) Vector
- func (v Vector) CheckAxis(v1, p, n Vector) bool
- func (v Vector) Clamp(length float64) Vector
- func (v Vector) Clone() Vector
- func (v Vector) ClosestDist(v1 Vector) float64
- func (v Vector) ClosestPointOnSegment(a, b Vector) Vector
- func (v Vector) ClosestT(b Vector) float64
- func (v Vector) Cross(other Vector) float64
- func (v Vector) Distance(other Vector) float64
- func (v Vector) DistanceSq(other Vector) float64
- func (v Vector) Dot(other Vector) float64
- func (v Vector) Equal(other Vector) bool
- func (v Vector) Length() float64
- func (v Vector) LengthSq() float64
- func (v Vector) Lerp(other Vector, t float64) Vector
- func (v Vector) LerpConst(other Vector, d float64) Vector
- func (v Vector) LerpT(b Vector, t float64) Vector
- func (v Vector) Mult(s float64) Vector
- func (v Vector) Near(other Vector, d float64) bool
- func (v Vector) Neg() Vector
- func (v Vector) Normalize() Vector
- func (v Vector) Perp() Vector
- func (v Vector) PointGreater(b, c Vector) bool
- func (v Vector) Project(other Vector) Vector
- func (v Vector) ReversePerp() Vector
- func (v Vector) Rotate(other Vector) Vector
- func (v Vector) SLerp(other Vector, t float64) Vector
- func (v Vector) SlerpConst(other Vector, a float64) Vector
- func (v Vector) String() string
- func (v Vector) Sub(other Vector) Vector
- func (v Vector) ToAngle() float64
- func (v Vector) Unrotate(other Vector) Vector
Constants ¶
const ( BODY_DYNAMIC = iota BODY_KINEMATIC BODY_STATIC )
Body types
const ( DRAW_SHAPES = 1 << 0 DRAW_CONSTRAINTS = 1 << 1 DRAW_COLLISION_POINTS = 1 << 2 )
Draw flags
const ( INFINITY = math.MaxFloat64 MAGIC_EPSILON = 1e-5 RadianConst = math.Pi / 180 DegreeConst = 180 / math.Pi POOLED_BUFFER_SIZE = 1024 )
const ( // Arbiter is active and its the first collision. CP_ARBITER_STATE_FIRST_COLLISION = iota // Arbiter is active and its not the first collision. CP_ARBITER_STATE_NORMAL // Collision has been explicitly ignored. // Either by returning false from a begin collision handler or calling cpArbiterIgnore(). CP_ARBITER_STATE_IGNORE // Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. CP_ARBITER_STATE_CACHED // Collison arbiter is invalid because one of the shapes was removed. CP_ARBITER_STATE_INVALIDATED )
Arbiter states
const CONTACTS_BUFFER_SIZE = 1024
const MAX_CONTACTS_PER_ARBITER = 2
const (
SHAPE_TYPE_NUM = 3
)
Variables ¶
var ( NO_GROUP uint = 0 // Value for group signifying that a shape is in no group. ALL_CATEGORIES uint = ^uint(0) // Value for Shape layers signifying that a shape is in every layer. )
var BuiltinCollisionFuncs = [9]CollisionFunc{ CircleToCircle, CollisionError, CollisionError, CircleToSegment, SegmentToSegment, CollisionError, CircleToPoly, SegmentToPoly, PolyToPoly, }
var CollisionHandlerDefault = CollisionHandler{ WILDCARD_COLLISION_TYPE, WILDCARD_COLLISION_TYPE, DefaultBegin, DefaultPreSolve, DefaultPostSolve, DefaultSeparate, nil, }
var CollisionHandlerDoNothing = CollisionHandler{ WILDCARD_COLLISION_TYPE, WILDCARD_COLLISION_TYPE, AlwaysCollide, AlwaysCollide, DoNothing, DoNothing, nil, }
var SHAPE_FILTER_ALL = ShapeFilter{NO_GROUP, ALL_CATEGORIES, ALL_CATEGORIES}
SHAPE_FILTER_ALL is s collision filter value for a shape that will collide with anything except SHAPE_FILTER_NONE.
var SHAPE_FILTER_NONE = ShapeFilter{NO_GROUP, ^ALL_CATEGORIES, ^ALL_CATEGORIES}
SHAPE_FILTER_NONE is a collision filter value for a shape that does not collide with anything.
var ShapeUpdateFunc = func(shape *Shape) {
shape.CacheBB()
}
var ShapeVelocityFunc = func(obj interface{}) Vector { return obj.(*Shape).body.v }
Functions ¶
func AlwaysCollide ¶
func AreaForCircle ¶
AreaForCircle returns area of a hollow circle.
r1 and r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.
func AreaForPoly ¶
AreaForPoly calculates the signed area of a polygon.
A Clockwise winding gives positive area. This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes.
func AreaForSegment ¶
AreaForSegment calculates the area of a fattened (capsule shaped) line segment.
func BodyUpdatePosition ¶
BodyUpdatePosition is default position integration function.
func BodyUpdateVelocity ¶
BodyUpdateVelocity is default velocity integration function.
func CachedArbitersFilter ¶
func CircleSegmentQuery ¶
func CircleToCircle ¶
func CircleToCircle(info *CollisionInfo)
func CircleToPoly ¶
func CircleToPoly(info *CollisionInfo)
func CircleToSegment ¶
func CircleToSegment(info *CollisionInfo)
func CollisionError ¶
func CollisionError(_ *CollisionInfo)
func ComponentActive ¶
func ContactPoints ¶
func ContactPoints(e1, e2 Edge, points ClosestPoints, info *CollisionInfo)
ContactPoints finds contact point pairs on two support edges' surfaces
func ConvexHull ¶
QuickHull seemed like a neat algorithm, and efficient-ish for large input sets. My implementation performs an in place reduction using the result array as scratch space.
func DefaultBegin ¶
func DefaultPostSolve ¶
func DefaultPreSolve ¶
func DefaultSeparate ¶
func DefaultSpringForce ¶
func DefaultSpringForce(spring *DampedSpring, dist float64) float64
func DrawConstraint ¶
func DrawConstraint(constraint *Constraint, options Drawer)
func FloodFillComponent ¶
func MarchCellHard ¶
func MarchCellHard(t, a, b, c, d, x0, x1, y0, y1 float64, marchSegment MarchSegmentFunc, segmentData *PolyLineSet)
func MarchCellSoft ¶
func MarchCellSoft(t, a, b, c, d, x0, x1, y0, y1 float64, marchSegment MarchSegmentFunc, segmentData *PolyLineSet)
func MomentForBox ¶
MomentForBox calculates the moment of inertia for a solid box.
func MomentForBox2 ¶
MomentForBox2 calculates the moment of inertia for a solid box.
func MomentForCircle ¶
MomentForCircle calculates the moment of inertia for a circle.
r1 and r2 are the inner and outer diameters. A solid circle has an inner diameter of 0.
func MomentForPoly ¶
MomentForPoly calculates the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex.
func MomentForSegment ¶
MomentForSegment calculates the moment of inertia for a line segment.
Beveling radius is not supported.
func PolyLineCollectSegment ¶
func PolyLineCollectSegment(v0, v1 Vector, pls *PolyLineSet)
Add a segment to a polyline set. A segment will either start a new polyline, join two others, or add to or loop an existing polyline.
func PolySupportPointIndex ¶
func PolySupportPointIndex(count int, planes []SplittingPlane, n Vector) int
func PolyToPoly ¶
func PolyToPoly(info *CollisionInfo)
func PostStepDoNothing ¶
func PostStepDoNothing(space *Space, key, data interface{})
func QHullReduce ¶
func QueryReject ¶
func QueryRejectConstraints ¶
func SegmentToPoly ¶
func SegmentToPoly(info *CollisionInfo)
func SegmentToSegment ¶
func SegmentToSegment(info *CollisionInfo)
func SpaceArbiterSetFilter ¶
SpaceArbiterSetFilter throws away old arbiters.
func SpaceCollideShapesFunc ¶
func VoidQueryFunc ¶
Types ¶
type Arbiter ¶
type Arbiter struct { UserData interface{} // contains filtered or unexported fields }
Arbiter struct tracks pairs of colliding shapes.
They are also used in conjuction with collision handler callbacks allowing you to retrieve information on the collision or change it. A unique arbiter value is used for each pair of colliding objects. It persists until the shapes separate.
func ArbiterNext ¶
func (*Arbiter) ApplyCachedImpulse ¶
func (*Arbiter) ApplyImpulse ¶
func (arbiter *Arbiter) ApplyImpulse()
func (*Arbiter) Bodies ¶
Bodies returns the colliding bodies involved for this arbiter. The order of the space.CollisionType the bodies are associated with values will match the order set when the collision handler was registered.
func (*Arbiter) CallWildcardBeginA ¶
CallWildcardBeginA if you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own.
func (*Arbiter) CallWildcardBeginB ¶
CallWildcardBeginB If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
func (*Arbiter) CallWildcardPostSolveA ¶
func (*Arbiter) CallWildcardPostSolveB ¶
func (*Arbiter) CallWildcardPreSolveA ¶
CallWildcardPreSolveA If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly.
func (*Arbiter) CallWildcardPreSolveB ¶
CallWildcardPreSolveB If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly.
func (*Arbiter) CallWildcardSeparateA ¶
func (*Arbiter) CallWildcardSeparateB ¶
func (*Arbiter) ContactPointSet ¶
func (arb *Arbiter) ContactPointSet() ContactPointSet
ContactPointSet returns ContactPointSet
func (*Arbiter) Ignore ¶
Ignore marks a collision pair to be ignored until the two objects separate.
Pre-solve and post-solve callbacks will not be called, but the separate callback will be called.
func (*Arbiter) IsFirstContact ¶
func (*Arbiter) SetContactPointSet ¶
func (arb *Arbiter) SetContactPointSet(set *ContactPointSet)
SetContactPointSet replaces the contact point set.
This can be a very powerful feature, but use it with caution!
func (*Arbiter) Shapes ¶
Shapes return the colliding shapes involved for this arbiter. The order of their space.CollisionType values will match the order set when the collision handler was registered.
func (*Arbiter) ThreadForBody ¶
func (arbiter *Arbiter) ThreadForBody(body *Body) *ArbiterThread
func (*Arbiter) TotalImpulse ¶
TotalImpulse calculates the total impulse including the friction that was applied by this arbiter.
This function should only be called from a post-solve, post-step or EachArbiter callback.
func (*Arbiter) Update ¶
func (arb *Arbiter) Update(info *CollisionInfo, space *Space)
type ArbiterThread ¶
type ArbiterThread struct {
// contains filtered or unexported fields
}
type BB ¶
type BB struct {
L, B, R, T float64
}
BB is Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top)
func NewBBForCircle ¶
NewBBForCircle constructs a BB for a circle with the given position and radius.
func NewBBForExtents ¶
NewBBForExtents constructs a BB centered on a point with the given extents (half sizes).
func ShapeGetBB ¶
func (BB) ContainsVect ¶
ContainsVect returns true if bb contains v.
func (BB) Intersects ¶
Intersects returns true if a and b intersect.
func (BB) IntersectsSegment ¶
IntersectsSegment returns true if the bounding box intersects the line segment with ends a and b.
func (BB) MergedArea ¶
MergedArea merges a and b and returns the area of the merged bounding box.
func (BB) SegmentQuery ¶
SegmentQuery returns the fraction along the segment query the BB is hit. Returns cp.INFINITY if it doesn't hit.
type BBQueryContext ¶
type BBQueryContext struct {
// contains filtered or unexported fields
}
type BBTree ¶
type BBTree struct {
// contains filtered or unexported fields
}
func (*BBTree) Each ¶
func (tree *BBTree) Each(f SpatialIndexIterator)
func (*BBTree) GetMasterTree ¶
func (*BBTree) IncrementStamp ¶
func (tree *BBTree) IncrementStamp()
func (*BBTree) LeafAddPairs ¶
func (*BBTree) LeafUpdate ¶
func (*BBTree) NodeFromPool ¶
func (*BBTree) PairFromPool ¶
func (*BBTree) PairInsert ¶
func (*BBTree) PairsClear ¶
func (*BBTree) Query ¶
func (tree *BBTree) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
func (*BBTree) RecycleNode ¶
func (*BBTree) RecyclePair ¶
func (*BBTree) ReindexObject ¶
func (*BBTree) ReindexQuery ¶
func (tree *BBTree) ReindexQuery(f SpatialIndexQuery, data interface{})
func (*BBTree) ReplaceChild ¶
func (*BBTree) SegmentQuery ¶
func (tree *BBTree) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{})
type BBTreeVelocityFunc ¶
type BBTreeVelocityFunc func(obj interface{}) Vector
type Body ¶
type Body struct { // UserData is an object that this constraint is associated with. // // You can use this get a reference to your game object or controller object from within callbacks. UserData interface{} // contains filtered or unexported fields }
func NewBody ¶
NewBody Initializes a rigid body with the given mass and moment of inertia.
Guessing the moment of inertia is usually a bad idea. Use the moment estimation functions MomentFor*().
func NewKinematicBody ¶
func NewKinematicBody() *Body
NewKinematicBody allocates and initializes a Body, and set it as a kinematic body.
func NewStaticBody ¶
func NewStaticBody() *Body
NewStaticBody allocates and initializes a Body, and set it as a static body.
func (*Body) AccumulateMassFromShapes ¶
func (body *Body) AccumulateMassFromShapes()
AccumulateMassFromShapes should *only* be called when shapes with mass info are modified, added or removed.
func (*Body) ActivateStatic ¶
ActivateStatic wakes up any sleeping or idle bodies touching a static body.
func (*Body) AngularVelocity ¶
AngularVelocity returns the angular velocity of the body.
func (*Body) ApplyForceAtLocalPoint ¶
ApplyForceAtLocalPoint applies a force at local point.
func (*Body) ApplyForceAtWorldPoint ¶
ApplyForceAtWorldPoint applies a force at world point.
func (*Body) ApplyImpulseAtLocalPoint ¶
ApplyImpulseAtLocalPoint applies impulse at local point
func (*Body) ApplyImpulseAtWorldPoint ¶
ApplyImpulseAtWorldPoint applies impulse at world point
func (Body) CenterOfGravity ¶
CenterOfGravity returns the offset of the center of gravity in body local coordinates.
func (*Body) ComponentAdd ¶
func (*Body) ComponentRoot ¶
func (*Body) EachArbiter ¶
EachArbiter calls f once for each arbiter that is currently active on the body.
func (*Body) EachConstraint ¶
func (body *Body) EachConstraint(f func(*Constraint))
EachConstraint calls f once for each constraint attached to this body
func (*Body) IsSleeping ¶
IsSleeping returns true if the body is sleeping.
func (*Body) KineticEnergy ¶
KineticEnergy returns the kinetic energy of this body.
func (*Body) LocalToWorld ¶
LocalToWorld converts from body local to world coordinates.
Convert a point in world (absolute) coordinates to body local coordinates affected by the position and rotation of the rigid body.
func (*Body) PushArbiter ¶
func (*Body) RemoveConstraint ¶
func (body *Body) RemoveConstraint(constraint *Constraint)
RemoveConstraint removes constraint from the body.
func (*Body) RemoveShape ¶
RemoveShape removes collision shape from the body.
func (*Body) Rotation ¶
Rotation returns the rotation vector of the body.
(The x basis vector of it's transform.)
func (*Body) SetAngularVelocity ¶
SetAngularVelocity sets the angular velocity of the body.
func (*Body) SetPosition ¶
SetPosition sets the position of the body.
func (*Body) SetPositionUpdateFunc ¶
func (body *Body) SetPositionUpdateFunc(f BodyPositionFunc)
SetPositionUpdateFunc sets the callback used to update a body's position.
func (*Body) SetTransform ¶
SetTransform sets transform
func (*Body) SetVelocity ¶
SetVelocity sets the velocity of the body.
Shorthand for Body.SetVelocityVector()
func (*Body) SetVelocityUpdateFunc ¶
func (body *Body) SetVelocityUpdateFunc(f BodyVelocityFunc)
SetVelocityUpdateFunc sets the callback used to update a body's velocity.
func (*Body) SetVelocityVector ¶
SetVelocityVector sets the velocity of the body
func (*Body) UpdateVelocity ¶
UpdateVelocity is the default velocity integration function.
func (*Body) VelocityAtLocalPoint ¶
VelocityAtLocalPoint returns the velocity of a point on a body.
Get the world (absolute) velocity of a point on a rigid body specified in body local coordinates.
func (*Body) VelocityAtWorldPoint ¶
VelocityAtWorldPoint returns the velocity of a point on a body.
Get the world (absolute) velocity of a point on a rigid body specified in world coordinates.
func (*Body) WorldToLocal ¶
WorldToLocal converts from world to body local Coordinates.
Convert a point in body local coordinates to world (absolute) coordinates.
type BodyPositionFunc ¶
BodyPositionFunc is rigid body position update function type.
type BodyVelocityFunc ¶
BodyVelocityFunc is rigid body velocity update function type.
type Circle ¶
type Circle struct { *Shape // contains filtered or unexported fields }
func (*Circle) PointQuery ¶
func (circle *Circle) PointQuery(p Vector, info *PointQueryInfo)
func (*Circle) SegmentQuery ¶
func (circle *Circle) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo)
func (*Circle) TransformC ¶
type ClosestPoints ¶
type ClosestPoints struct {
// contains filtered or unexported fields
}
func EPA ¶
func EPA(ctx SupportContext, v0, v1, v2 MinkowskiPoint) ClosestPoints
EPA is called from GJK when two shapes overlap. Finds the closest points on the surface of two overlapping shapes using the EPA algorithm. This is a moderately expensive step! Avoid it by adding radii to your shapes so their inner polygons won't overlap.
func EPARecurse ¶
func EPARecurse(ctx SupportContext, count int, hull []MinkowskiPoint, iteration int) ClosestPoints
EPARecurse implementation of the EPA loop. Each recursion adds a point to the convex hull until it's known that we have the closest point on the surface.
func GJK ¶
func GJK(ctx SupportContext, collisionId *uint32) ClosestPoints
GJK finds the closest points between two shapes using the GJK algorithm.
func GJKRecurse ¶
func GJKRecurse(ctx SupportContext, v0, v1 MinkowskiPoint, iteration int) ClosestPoints
GJKRecurse implementation of the GJK loop.
type CollisionBeginFunc ¶
CollisionBeginFunc is collision begin event function callback type.
Returning false from a begin callback causes the collision to be ignored until the the separate callback is called when the objects stop colliding.
type CollisionFunc ¶
type CollisionFunc func(info *CollisionInfo)
type CollisionHandler ¶
type CollisionHandler struct { // Collision type identifier of the first shape that this handler recognizes. // In the collision handler callback, the shape with this type will be the first argument. Read only. TypeA CollisionType // Collision type identifier of the second shape that this handler recognizes. // In the collision handler callback, the shape with this type will be the second argument. Read only. TypeB CollisionType // This function is called when two shapes with types that match this collision handler begin colliding. BeginFunc CollisionBeginFunc // This function is called each step when two shapes with types that match this collision handler are colliding. // It's called before the collision solver runs so that you can affect a collision's outcome. PreSolveFunc CollisionPreSolveFunc // This function is called each step when two shapes with types that match this collision handler are colliding. // It's called after the collision solver runs so that you can read back information about the collision to trigger events in your game. PostSolveFunc CollisionPostSolveFunc // This function is called when two shapes with types that match this collision handler stop colliding. SeparateFunc CollisionSeparateFunc // This is a user definable context pointer that is passed to all of the collision handler functions. UserData interface{} }
CollisionHandler is struct that holds function callback pointers to configure custom collision handling. Collision handlers have a pair of types; when a collision occurs between two shapes that have these types, the collision handler functions are triggered.
type CollisionInfo ¶
type CollisionInfo struct {
// contains filtered or unexported fields
}
CollisionInfo collision info struct
func Collide ¶
func Collide(a, b *Shape, collisionID uint32, contacts []Contact) CollisionInfo
Collide performs a collision between two shapes
func (*CollisionInfo) PushContact ¶
func (info *CollisionInfo) PushContact(p1, p2 Vector, hash HashValue)
type CollisionPostSolveFunc ¶
CollisionPostSolveFunc is collision post-solve event function callback type.
type CollisionPreSolveFunc ¶
CollisionPreSolveFunc is collision pre-solve event function callback type.
Returning false from a pre-step callback causes the collision to be ignored until the next step.
type CollisionSeparateFunc ¶
CollisionSeparateFunc is collision separate event function callback type.
type CollisionType ¶
type CollisionType uintptr
var WILDCARD_COLLISION_TYPE CollisionType = ^CollisionType(0)
type Constrainer ¶
type Constraint ¶
type Constraint struct { Class Constrainer PreSolve ConstraintPreSolveFunc PostSolve ConstraintPostSolveFunc UserData interface{} // contains filtered or unexported fields }
func NewConstraint ¶
func NewConstraint(class Constrainer, a, b *Body) *Constraint
func NewDampedRotarySpring ¶
func NewDampedRotarySpring(a, b *Body, restAngle, stiffness, damping float64) *Constraint
func NewDampedSpring ¶
func NewDampedSpring(a, b *Body, anchorA, anchorB Vector, restLength, stiffness, damping float64) *Constraint
func NewGearJoint ¶
func NewGearJoint(a, b *Body, phase, ratio float64) *Constraint
func NewGrooveJoint ¶
func NewGrooveJoint(a, b *Body, grooveA, grooveB, anchorB Vector) *Constraint
func NewPinJoint ¶
func NewPinJoint(a, b *Body, anchorA, anchorB Vector) *Constraint
func NewPivotJoint ¶
func NewPivotJoint(a, b *Body, pivot Vector) *Constraint
func NewPivotJoint2 ¶
func NewPivotJoint2(a, b *Body, anchorA, anchorB Vector) *Constraint
func NewRatchetJoint ¶
func NewRatchetJoint(a, b *Body, phase, ratchet float64) *Constraint
func NewRotaryLimitJoint ¶
func NewRotaryLimitJoint(a, b *Body, min, max float64) *Constraint
func NewSimpleMotor ¶
func NewSimpleMotor(a, b *Body, rate float64) *Constraint
func NewSlideJoint ¶
func NewSlideJoint(a, b *Body, anchorA, anchorB Vector, min, max float64) *Constraint
func (*Constraint) ActivateBodies ¶
func (c *Constraint) ActivateBodies()
func (Constraint) ErrorBias ¶
func (c Constraint) ErrorBias() float64
func (Constraint) MaxBias ¶
func (c Constraint) MaxBias() float64
func (Constraint) MaxForce ¶
func (c Constraint) MaxForce() float64
func (*Constraint) Next ¶
func (c *Constraint) Next(body *Body) *Constraint
func (*Constraint) SetCollideBodies ¶
func (c *Constraint) SetCollideBodies(collideBodies bool)
func (*Constraint) SetErrorBias ¶
func (c *Constraint) SetErrorBias(errorBias float64)
func (*Constraint) SetMaxBias ¶
func (c *Constraint) SetMaxBias(max float64)
func (*Constraint) SetMaxForce ¶
func (c *Constraint) SetMaxForce(max float64)
type ConstraintPostSolveFunc ¶
type ConstraintPostSolveFunc func(*Constraint, *Space)
type ConstraintPreSolveFunc ¶
type ConstraintPreSolveFunc func(*Constraint, *Space)
type ContactBuffer ¶
type ContactBuffer struct {
// contains filtered or unexported fields
}
func NewContactBuffer ¶
func NewContactBuffer(stamp uint, slice *ContactBuffer) *ContactBuffer
func (*ContactBuffer) InitHeader ¶
func (c *ContactBuffer) InitHeader(stamp uint, splice *ContactBuffer) *ContactBuffer
type ContactPointSet ¶
type ContactPointSet struct { // Count is the number of contact points in the set. Count int // Normal is the normal of the collision. Normal Vector Points [MAX_CONTACTS_PER_ARBITER]struct { // The position of the contact on the surface of each shape. PointA, PointB Vector // Distance is penetration distance of the two shapes. Overlapping means it will be negative. // // This value is calculated as p2.Sub(p1).Dot(n) and is ignored by Arbiter.SetContactPointSet(). Distance float64 } }
ContactPointSet wraps up the important collision data for an arbiter.
func ShapesCollide ¶
func ShapesCollide(a, b *Shape) ContactPointSet
type DampedRotarySpring ¶
type DampedRotarySpring struct { *Constraint RestAngle, Stiffness, Damping float64 SpringTorqueFunc func(spring *DampedRotarySpring, relativeAngle float64) float64 // contains filtered or unexported fields }
func (*DampedRotarySpring) ApplyCachedImpulse ¶
func (joint *DampedRotarySpring) ApplyCachedImpulse(dt_coef float64)
func (*DampedRotarySpring) ApplyImpulse ¶
func (spring *DampedRotarySpring) ApplyImpulse(dt float64)
func (*DampedRotarySpring) GetImpulse ¶
func (joint *DampedRotarySpring) GetImpulse() float64
func (*DampedRotarySpring) PreStep ¶
func (spring *DampedRotarySpring) PreStep(dt float64)
type DampedSpring ¶
type DampedSpring struct { *Constraint AnchorA, AnchorB Vector RestLength, Stiffness, Damping float64 SpringForceFunc DampedSpringForceFunc // contains filtered or unexported fields }
func (*DampedSpring) ApplyCachedImpulse ¶
func (spring *DampedSpring) ApplyCachedImpulse(dt_coef float64)
func (*DampedSpring) ApplyImpulse ¶
func (spring *DampedSpring) ApplyImpulse(dt float64)
func (*DampedSpring) GetImpulse ¶
func (spring *DampedSpring) GetImpulse() float64
func (*DampedSpring) PreStep ¶
func (spring *DampedSpring) PreStep(dt float64)
type DampedSpringForceFunc ¶
type DampedSpringForceFunc func(spring *DampedSpring, dist float64) float64
type Drawer ¶
type Drawer interface { DrawCircle(pos Vector, angle, radius float64, outline, fill FColor, data interface{}) DrawSegment(a, b Vector, fill FColor, data interface{}) DrawFatSegment(a, b Vector, radius float64, outline, fill FColor, data interface{}) DrawPolygon(count int, verts []Vector, radius float64, outline, fill FColor, data interface{}) DrawDot(size float64, pos Vector, fill FColor, data interface{}) Flags() uint OutlineColor() FColor ShapeColor(shape *Shape, data interface{}) FColor ConstraintColor() FColor CollisionPointColor() FColor Data() interface{} }
type Edge ¶
type Edge struct {
// contains filtered or unexported fields
}
func SupportEdgeForPoly ¶
func SupportEdgeForSegment ¶
type GearJoint ¶
type GearJoint struct { *Constraint // contains filtered or unexported fields }
func (*GearJoint) ApplyCachedImpulse ¶
func (*GearJoint) ApplyImpulse ¶
func (*GearJoint) GetImpulse ¶
type GrooveJoint ¶
type GrooveJoint struct { *Constraint GrooveN, GrooveA, GrooveB Vector AnchorB Vector // contains filtered or unexported fields }
func (*GrooveJoint) ApplyCachedImpulse ¶
func (joint *GrooveJoint) ApplyCachedImpulse(dt_coef float64)
func (*GrooveJoint) ApplyImpulse ¶
func (joint *GrooveJoint) ApplyImpulse(dt float64)
func (*GrooveJoint) GetImpulse ¶
func (joint *GrooveJoint) GetImpulse() float64
func (*GrooveJoint) PreStep ¶
func (joint *GrooveJoint) PreStep(dt float64)
type HashSet ¶
type HashSet[T, U comparable] struct { // contains filtered or unexported fields }
HashSet implements a hash set
func NewHashSet ¶
func NewHashSet[T, U comparable](isEqual func(ptr T, elt U) bool) *HashSet[T, U]
NewHashSet is a HashSet constructor
func (*HashSet[T, U]) Each ¶
func (set *HashSet[T, U]) Each(f func(U))
Each calls f for every U in the HashSet.
type HashSetBin ¶
type HashSetBin[U comparable] struct { // contains filtered or unexported fields }
HashSetBin implements a linked list
type MarchCellFunc ¶
type MarchCellFunc func(t, a, b, c, d, x0, x1, y0, y1 float64, marchSegment MarchSegmentFunc, segmentData *PolyLineSet)
type MarchSampleFunc ¶
This is a user defined function that gets passed every single point from the bounding box the user passes into the March process - you can use this to sample an image and check for alpha values or really any 2d matrix you define like a tile map. NOTE: I could not determine a use case for the sample_data pointer from the original code so I removed it here - open to adding it back in if there is a reason.
type MarchSegmentFunc ¶
type MarchSegmentFunc func(v0 Vector, v1 Vector, segmentData *PolyLineSet)
This is a user defined function that gets passed in to the Marching process the user establishes a PolyLineSet, passes a pointer to their function, and they populate it. In most cases you want to use PolyLineCollectSegment instead of defining your own
type MarkContext ¶
type MarkContext struct {
// contains filtered or unexported fields
}
type Mat2x2 ¶
type Mat2x2 struct {
// contains filtered or unexported fields
}
Mat2x2 is a 2x2 matrix type used for tensors and such.
type MinkowskiPoint ¶
type MinkowskiPoint struct {
// contains filtered or unexported fields
}
MinkowskiPoint is a point on the surface of two shapes' minkowski difference.
func NewMinkowskiPoint ¶
func NewMinkowskiPoint(a, b SupportPoint) MinkowskiPoint
func (MinkowskiPoint) ClosestPoints ¶
func (v0 MinkowskiPoint) ClosestPoints(v1 MinkowskiPoint) ClosestPoints
ClosestPoints calculates the closest points on two shapes given the closest edge on their minkowski difference to (0, 0)
type Node ¶
func (*Node) MarkLeaf ¶
func (leaf *Node) MarkLeaf(context *MarkContext)
func (*Node) MarkLeafQuery ¶
func (subtree *Node) MarkLeafQuery(leaf *Node, left bool, context *MarkContext)
func (*Node) MarkSubtree ¶
func (subtree *Node) MarkSubtree(context *MarkContext)
func (*Node) SubtreeQuery ¶
func (subtree *Node) SubtreeQuery(obj interface{}, bb BB, query SpatialIndexQuery, data interface{})
func (*Node) SubtreeSegmentQuery ¶
func (subtree *Node) SubtreeSegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{}) float64
type PinJoint ¶
type PinJoint struct { *Constraint AnchorA, AnchorB Vector Dist float64 // contains filtered or unexported fields }
func (*PinJoint) ApplyCachedImpulse ¶
func (*PinJoint) ApplyImpulse ¶
func (*PinJoint) GetImpulse ¶
type PivotJoint ¶
type PivotJoint struct { *Constraint AnchorA, AnchorB Vector // contains filtered or unexported fields }
func (*PivotJoint) ApplyCachedImpulse ¶
func (joint *PivotJoint) ApplyCachedImpulse(dt_coef float64)
func (*PivotJoint) ApplyImpulse ¶
func (joint *PivotJoint) ApplyImpulse(dt float64)
func (*PivotJoint) GetImpulse ¶
func (joint *PivotJoint) GetImpulse() float64
func (*PivotJoint) PreStep ¶
func (joint *PivotJoint) PreStep(dt float64)
type PointQueryContext ¶
type PointQueryContext struct {
// contains filtered or unexported fields
}
type PointQueryInfo ¶
type PointQueryInfo struct { // The nearest shape, NULL if no shape was within range. Shape *Shape // The closest point on the shape's surface. (in world space coordinates) Point Vector // The distance to the point. The distance is negative if the point is inside the shape. Distance float64 // The gradient of the signed distance function. // The value should be similar to info.p/info.d, but accurate even for very small values of info.d. Gradient Vector }
PointQueryInfo is point query info struct.
type PolyLine ¶
type PolyLine struct {
Verts []Vector
}
func DouglasPeucker ¶
func DouglasPeucker(verts []Vector, reduced *PolyLine, length, start, end int, min, tol float64) *PolyLine
Recursive function used by cpPolylineSimplifyCurves().
func (*PolyLine) SimplifyCurves ¶
Recursively reduce the vertex count on a polyline. Works best for smooth shapes. 'tol' is the maximum error for the reduction. The reduced polyline will never be farther than this distance from the original polyline.
func (*PolyLine) SimplifyVertexes ¶
Join similar adjacent line segments together. Works well for hard edged shapes. 'tol' is the minimum anglular difference in radians of a vertex.
type PolyLineSet ¶
type PolyLineSet struct {
Lines []*PolyLine
}
func MarchCells ¶
func MarchCells(bb BB, xSamples int64, ySamples int64, t float64, marchSegment MarchSegmentFunc, marchSample MarchSampleFunc, marchCell MarchCellFunc) *PolyLineSet
The looping and sample caching code is shared between cpMarchHard() and cpMarchSoft().
func MarchHard ¶
func MarchHard(bb BB, xSamples, ySamples int64, t float64, marchSegment MarchSegmentFunc, marchSample MarchSampleFunc) *PolyLineSet
Trace an aliased curve of an image along a particular threshold. The given number of samples will be taken and spread across the bounding box area using the sampling function and context. The segment function will be called for each segment detected that lies along the density contour for @c threshold.
func MarchSoft ¶
func MarchSoft(bb BB, xSamples, ySamples int64, t float64, marchSegment MarchSegmentFunc, marchSample MarchSampleFunc) *PolyLineSet
Trace an anti-aliased contour of an image along a particular threshold. The given number of samples will be taken and spread across the bounding box area using the sampling function and context. The segment function will be called for each segment detected that lies along the density contour for @c threshold.
func (*PolyLineSet) FindEnds ¶
func (pls *PolyLineSet) FindEnds(v Vector) int
Find the polyline that ends with v.
func (*PolyLineSet) FindStarts ¶
func (pls *PolyLineSet) FindStarts(v Vector) int
Find the polyline that starts with v.
func (*PolyLineSet) Join ¶
func (pls *PolyLineSet) Join(before, after int)
this may deletion could be slow? https://yourbasic.org/golang/delete-element-slice/
func (*PolyLineSet) Push ¶
func (pls *PolyLineSet) Push(v *PolyLine)
Add a new polyline to a polyline set.
type PolyShape ¶
type PolyShape struct { *Shape // contains filtered or unexported fields }
func (*PolyShape) PointQuery ¶
func (poly *PolyShape) PointQuery(p Vector, info *PointQueryInfo)
func (*PolyShape) SegmentQuery ¶
func (poly *PolyShape) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
func (*PolyShape) SetVertsRaw ¶
func (*PolyShape) SetVertsUnsafe ¶
func (PolyShape) TransformVert ¶
type PostStepCallback ¶
type PostStepCallback struct {
// contains filtered or unexported fields
}
type PostStepCallbackFunc ¶
type PostStepCallbackFunc func(space *Space, key interface{}, data interface{})
type RatchetJoint ¶
type RatchetJoint struct { *Constraint Angle, Phase, Ratchet float64 // contains filtered or unexported fields }
func (*RatchetJoint) ApplyCachedImpulse ¶
func (joint *RatchetJoint) ApplyCachedImpulse(dt_coef float64)
func (*RatchetJoint) ApplyImpulse ¶
func (joint *RatchetJoint) ApplyImpulse(dt float64)
func (*RatchetJoint) GetImpulse ¶
func (joint *RatchetJoint) GetImpulse() float64
func (*RatchetJoint) PreStep ¶
func (joint *RatchetJoint) PreStep(dt float64)
type RotaryLimitJoint ¶
type RotaryLimitJoint struct { *Constraint Min, Max float64 // contains filtered or unexported fields }
func (*RotaryLimitJoint) ApplyCachedImpulse ¶
func (joint *RotaryLimitJoint) ApplyCachedImpulse(dt_coef float64)
func (*RotaryLimitJoint) ApplyImpulse ¶
func (joint *RotaryLimitJoint) ApplyImpulse(dt float64)
func (*RotaryLimitJoint) GetImpulse ¶
func (joint *RotaryLimitJoint) GetImpulse() float64
func (*RotaryLimitJoint) PreStep ¶
func (joint *RotaryLimitJoint) PreStep(dt float64)
type Segment ¶
type Segment struct { *Shape // contains filtered or unexported fields }
func (*Segment) PointQuery ¶
func (seg *Segment) PointQuery(p Vector, info *PointQueryInfo)
func (*Segment) SegmentQuery ¶
func (seg *Segment) SegmentQuery(a, b Vector, r2 float64, info *SegmentQueryInfo)
func (*Segment) SetEndpoints ¶
func (*Segment) TransformA ¶
func (*Segment) TransformB ¶
type SegmentQueryContext ¶
type SegmentQueryContext struct {
// contains filtered or unexported fields
}
type SegmentQueryInfo ¶
type SegmentQueryInfo struct { // The shape that was hit, or NULL if no collision occurred. Shape *Shape // The point of impact. Point Vector // The normal of the surface hit. Normal Vector // The normalized distance along the query segment in the range [0, 1]. Alpha float64 }
SegmentQueryInfo is segment query info struct.
type Shape ¶
type Shape struct { Class ShapeClass UserData interface{} Filter ShapeFilter // contains filtered or unexported fields }
func NewPolyShape ¶
func NewPolyShapeRaw ¶
func NewShape ¶
func NewShape(class ShapeClass, body *Body, massInfo *ShapeMassInfo) *Shape
func (*Shape) CenterOfGravity ¶
func (*Shape) Elasticity ¶
func (*Shape) MassInfo ¶
func (s *Shape) MassInfo() *ShapeMassInfo
func (*Shape) Point ¶
func (s *Shape) Point(i uint32) SupportPoint
func (*Shape) PointQuery ¶
func (s *Shape) PointQuery(p Vector) PointQueryInfo
func (*Shape) SegmentQuery ¶
func (shape *Shape) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo) bool
func (*Shape) SetCollisionType ¶
func (s *Shape) SetCollisionType(collisionType CollisionType)
func (*Shape) SetDensity ¶
func (*Shape) SetElasticity ¶
func (*Shape) SetFilter ¶
func (s *Shape) SetFilter(filter ShapeFilter)
func (*Shape) SetFriction ¶
func (*Shape) SetSurfaceV ¶
type ShapeClass ¶
type ShapeClass interface { CacheData(transform Transform) BB PointQuery(p Vector, info *PointQueryInfo) SegmentQuery(a, b Vector, radius float64, info *SegmentQueryInfo) }
type ShapeFilter ¶
type ShapeFilter struct { // Two objects with the same non-zero group value do not collide. // This is generally used to group objects in a composite object together to disable self collisions. Group uint // A bitmask of user definable categories that this object belongs to. // The category/mask combinations of both objects in a collision must agree for a collision to occur. Categories uint // A bitmask of user definable category types that this object object collides with. // The category/mask combinations of both objects in a collision must agree for a collision to occur. Mask uint }
ShapeFilter is fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks.
func NewShapeFilter ¶
func NewShapeFilter(group, categories, mask uint) ShapeFilter
NewShapeFilter creates a new collision filter.
func (ShapeFilter) Reject ¶
func (a ShapeFilter) Reject(b ShapeFilter) bool
type ShapeMassInfo ¶
type ShapeMassInfo struct {
// contains filtered or unexported fields
}
ShapeMassInfo is mass info struct
func CircleShapeMassInfo ¶
func CircleShapeMassInfo(mass, radius float64, center Vector) *ShapeMassInfo
func NewSegmentMassInfo ¶
func NewSegmentMassInfo(mass float64, a, b Vector, r float64) *ShapeMassInfo
func PolyShapeMassInfo ¶
func PolyShapeMassInfo(mass float64, count int, verts []Vector, r float64) *ShapeMassInfo
type SimpleMotor ¶
type SimpleMotor struct { *Constraint Rate float64 // contains filtered or unexported fields }
func (*SimpleMotor) ApplyCachedImpulse ¶
func (motor *SimpleMotor) ApplyCachedImpulse(dt_coef float64)
func (*SimpleMotor) ApplyImpulse ¶
func (motor *SimpleMotor) ApplyImpulse(dt float64)
func (*SimpleMotor) GetImpulse ¶
func (motor *SimpleMotor) GetImpulse() float64
func (*SimpleMotor) PreStep ¶
func (motor *SimpleMotor) PreStep(dt float64)
type SlideJoint ¶
type SlideJoint struct { *Constraint AnchorA, AnchorB Vector Min, Max float64 // contains filtered or unexported fields }
func (*SlideJoint) ApplyCachedImpulse ¶
func (joint *SlideJoint) ApplyCachedImpulse(dt_coef float64)
func (*SlideJoint) ApplyImpulse ¶
func (joint *SlideJoint) ApplyImpulse(dt float64)
func (*SlideJoint) GetImpulse ¶
func (joint *SlideJoint) GetImpulse() float64
func (*SlideJoint) PreStep ¶
func (joint *SlideJoint) PreStep(dt float64)
type Space ¶
type Space struct { Iterations uint // must be non-zero IdleSpeedThreshold float64 SleepTimeThreshold float64 StaticBody *Body // contains filtered or unexported fields }
func (*Space) AddConstraint ¶
func (space *Space) AddConstraint(constraint *Constraint) *Constraint
func (*Space) AddPostStepCallback ¶
func (space *Space) AddPostStepCallback(f PostStepCallbackFunc, key, data interface{}) bool
func (*Space) ArrayForBodyType ¶
func (*Space) BBQuery ¶
func (space *Space) BBQuery(bb BB, filter ShapeFilter, f SpaceBBQueryFunc, data interface{})
func (*Space) ContactBufferGetArray ¶
func (*Space) ContainsBody ¶
func (*Space) ContainsConstraint ¶
func (space *Space) ContainsConstraint(constraint *Constraint) bool
func (*Space) ContainsShape ¶
func (*Space) Deactivate ¶
func (*Space) EachConstraint ¶
func (space *Space) EachConstraint(f func(*Constraint))
func (*Space) FilterArbiters ¶
func (*Space) LookupHandler ¶
func (space *Space) LookupHandler(a, b CollisionType, defaultHandler *CollisionHandler) *CollisionHandler
func (*Space) NewCollisionHandler ¶
func (space *Space) NewCollisionHandler(collisionTypeA, collisionTypeB CollisionType) *CollisionHandler
func (*Space) NewWildcardCollisionHandler ¶
func (space *Space) NewWildcardCollisionHandler(collisionType CollisionType) *CollisionHandler
func (*Space) PointQueryNearest ¶
func (space *Space) PointQueryNearest(point Vector, maxDistance float64, filter ShapeFilter) *PointQueryInfo
func (*Space) PopContacts ¶
func (*Space) PostStepCallback ¶
func (space *Space) PostStepCallback(key interface{}) *PostStepCallback
func (*Space) ProcessComponents ¶
func (*Space) PushContacts ¶
func (*Space) PushFreshContactBuffer ¶
func (space *Space) PushFreshContactBuffer()
func (*Space) ReindexShape ¶ added in v2.1.0
ReindexShape re-computes the hash of the shape in both the dynamic and static list.
func (*Space) RemoveBody ¶
func (*Space) RemoveConstraint ¶
func (space *Space) RemoveConstraint(constraint *Constraint)
func (*Space) RemoveShape ¶
func (*Space) SegmentQuery ¶
func (space *Space) SegmentQuery(start, end Vector, radius float64, filter ShapeFilter, f SpaceSegmentQueryFunc, data interface{})
func (*Space) SegmentQueryFirst ¶
func (space *Space) SegmentQueryFirst(start, end Vector, radius float64, filter ShapeFilter) SegmentQueryInfo
func (*Space) SetCollisionSlop ¶
func (*Space) SetDamping ¶
func (*Space) SetGravity ¶
func (*Space) SetStaticBody ¶
func (*Space) ShapeQuery ¶
func (space *Space) ShapeQuery(shape *Shape, callback func(shape *Shape, points *ContactPointSet)) bool
ShapeQuery queries a space for any shapes overlapping the given shape and call the callback for each shape found.
func (*Space) UncacheArbiter ¶
func (*Space) UseSpatialHash ¶
func (*Space) UseWildcardDefaultHandler ¶
func (space *Space) UseWildcardDefaultHandler()
type SpaceBBQueryFunc ¶
type SpaceBBQueryFunc func(shape *Shape, data interface{})
type SpaceHash ¶
type SpaceHash struct { *SpatialIndex // contains filtered or unexported fields }
func (*SpaceHash) Each ¶
func (hash *SpaceHash) Each(f SpatialIndexIterator)
func (*SpaceHash) Query ¶
func (hash *SpaceHash) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{})
func (*SpaceHash) ReindexObject ¶
func (*SpaceHash) ReindexQuery ¶
func (hash *SpaceHash) ReindexQuery(f SpatialIndexQuery, data interface{})
func (*SpaceHash) SegmentQuery ¶
func (hash *SpaceHash) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{})
modified from http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html
type SpaceHashBin ¶
type SpaceHashBin struct {
// contains filtered or unexported fields
}
type SpacePointQueryFunc ¶
type SpaceSegmentQueryFunc ¶
type SpatialIndex ¶
type SpatialIndex struct {
// contains filtered or unexported fields
}
func NewBBTree ¶
func NewBBTree(bbfunc SpatialIndexBB, staticIndex *SpatialIndex) *SpatialIndex
func NewSpaceHash ¶
func NewSpaceHash(celldim float64, num int, bbfunc SpatialIndexBB, staticIndex *SpatialIndex) *SpatialIndex
func NewSpatialIndex ¶
func NewSpatialIndex(klass SpatialIndexer, bbfunc SpatialIndexBB, staticIndex *SpatialIndex) *SpatialIndex
func (*SpatialIndex) CollideStatic ¶
func (dynamicIndex *SpatialIndex) CollideStatic(staticIndex *SpatialIndex, f SpatialIndexQuery, data interface{})
func (*SpatialIndex) GetRootIfTree ¶
func (index *SpatialIndex) GetRootIfTree() *Node
func (*SpatialIndex) GetTree ¶
func (index *SpatialIndex) GetTree() *BBTree
type SpatialIndexBB ¶
type SpatialIndexIterator ¶
type SpatialIndexIterator func(obj *Shape)
type SpatialIndexQuery ¶
type SpatialIndexer ¶
type SpatialIndexer interface { Count() int Each(f SpatialIndexIterator) Contains(obj *Shape, hashId HashValue) bool Insert(obj *Shape, hashId HashValue) Remove(obj *Shape, hashId HashValue) Reindex() ReindexObject(obj *Shape, hashId HashValue) ReindexQuery(f SpatialIndexQuery, data interface{}) Query(obj interface{}, bb BB, f SpatialIndexQuery, data interface{}) SegmentQuery(obj interface{}, a, b Vector, t_exit float64, f SpatialIndexSegmentQuery, data interface{}) }
SpatialIndexer implemented by BBTree
type SplittingPlane ¶
type SplittingPlane struct {
// contains filtered or unexported fields
}
type SupportContext ¶
type SupportContext struct {
// contains filtered or unexported fields
}
func (*SupportContext) Support ¶
func (ctx *SupportContext) Support(n Vector) MinkowskiPoint
Support calculates the maximal point on the minkowski difference of two shapes along a particular axis.
type SupportPoint ¶
type SupportPoint struct {
// contains filtered or unexported fields
}
func CircleSupportPoint ¶
func CircleSupportPoint(shape *Shape, _ Vector) SupportPoint
func NewSupportPoint ¶
func NewSupportPoint(p Vector, index uint32) SupportPoint
func PolySupportPoint ¶
func PolySupportPoint(shape *Shape, n Vector) SupportPoint
func SegmentSupportPoint ¶
func SegmentSupportPoint(shape *Shape, n Vector) SupportPoint
type SupportPointFunc ¶
type SupportPointFunc func(shape *Shape, n Vector) SupportPoint
type Transform ¶
type Transform struct {
// contains filtered or unexported fields
}
func NewTransform ¶
func NewTransformIdentity ¶
func NewTransformIdentity() Transform
func NewTransformRigid ¶
func NewTransformRotate ¶
func NewTransformScale ¶
func NewTransformTranslate ¶
func NewTransformTranspose ¶
func (Transform) AxialScale ¶
type Vector ¶
type Vector struct {
X, Y float64
}
func CentroidForPoly ¶
CentroidForPoly calculates the natural centroid of a polygon.
func (Vector) ClosestDist ¶
func (Vector) ClosestPointOnSegment ¶
func (Vector) Cross ¶
Cross calculates the 2D vector cross product analog. The cross product of 2D vectors results in a 3D vector with only a z component. This function returns the magnitude of the z value.
func (Vector) DistanceSq ¶
func (Vector) PointGreater ¶
func (Vector) ReversePerp ¶
Source Files ¶
- arbiter.go
- bb.go
- bbtree.go
- body.go
- circle.go
- collision.go
- constraint.go
- contactbuffer.go
- dampedrotaryspring.go
- dampedspring.go
- draw.go
- everything.go
- gearjoint.go
- groovejoint.go
- hashset.go
- hashset_arbiter.go
- march.go
- pinjoint.go
- pivotjoint.go
- poly.go
- polyline.go
- ratchetjoint.go
- release.go
- rotarylimitjoint.go
- segment.go
- shape.go
- simplemotor.go
- slidejoint.go
- space.go
- spacehash.go
- spatialindex.go
- transform.go
- vector.go