shape

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: BSD-2-Clause Imports: 3 Imported by: 50

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConvexHull

type ConvexHull struct {
	geometry.Geometry
	// contains filtered or unexported fields
}

ConvexHull is a convex triangle-based geometry used for collision detection and contact resolution.

func NewConvexHull

func NewConvexHull(geom *geometry.Geometry) *ConvexHull

func (*ConvexHull) ClipAgainstHull

func (ch *ConvexHull) ClipAgainstHull(chB *ConvexHull, posA, posB *math32.Vector3, quatA, quatB *math32.Quaternion, penAxis *math32.Vector3, minDist, maxDist float32) []collision.Contact

{array} result The an array of contact point objects, see clipFaceAgainstHull

func (*ConvexHull) ComputeWorldFaceNormalsAndUniqueEdges

func (ch *ConvexHull) ComputeWorldFaceNormalsAndUniqueEdges(quat *math32.Quaternion)

ComputeWorldFaceNormalsAndUniqueEdges

func (*ConvexHull) FaceNormals

func (ch *ConvexHull) FaceNormals() []math32.Vector3

func (*ConvexHull) Faces

func (ch *ConvexHull) Faces() [][3]math32.Vector3

func (*ConvexHull) FindPenetrationAxis

func (ch *ConvexHull) FindPenetrationAxis(chB *ConvexHull, posA, posB *math32.Vector3, quatA, quatB *math32.Quaternion) (bool, math32.Vector3)

FindPenetrationAxis finds the penetration axis between two convex bodies. The normal points from bodyA to bodyB. Returns false if there is no penetration. If there is a penetration - returns true and the penetration axis.

func (*ConvexHull) ProjectOntoWorldAxis

func (ch *ConvexHull) ProjectOntoWorldAxis(worldAxis, pos *math32.Vector3, quat *math32.Quaternion) (float32, float32)

ProjectOntoWorldAxis projects the geometry onto the specified world axis.

func (*ConvexHull) TestPenetrationAxis

func (ch *ConvexHull) TestPenetrationAxis(chB *ConvexHull, worldAxis, posA, posB *math32.Vector3, quatA, quatB *math32.Quaternion) (bool, float32)

Both hulls are projected onto the axis and the overlap size (penetration depth) is returned if there is one. return {number} The overlap depth, or FALSE if no penetration.

func (*ConvexHull) UniqueEdges

func (ch *ConvexHull) UniqueEdges() []math32.Vector3

func (*ConvexHull) WorldFace

func (ch *ConvexHull) WorldFace(face [3]math32.Vector3, pos *math32.Vector3, quat *math32.Quaternion) [3]math32.Vector3

func (*ConvexHull) WorldFaceNormals

func (ch *ConvexHull) WorldFaceNormals() []math32.Vector3

func (*ConvexHull) WorldUniqueEdges

func (ch *ConvexHull) WorldUniqueEdges() []math32.Vector3

type IShape

type IShape interface {
	BoundingBox() math32.Box3
	BoundingSphere() math32.Sphere
	Area() float32
	Volume() float32
	RotationalInertia(mass float32) math32.Matrix3
	ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)
}

IShape is the interface for all collision shapes. Shapes in this package satisfy this interface and also geometry.Geometry.

type Plane

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

Plane is an analytical collision Plane. A plane, facing in the +Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid.

func NewPlane

func NewPlane() *Plane

NewPlane creates and returns a pointer to a new analytical collision plane.

func (*Plane) Area

func (p *Plane) Area() float32

Area returns the surface area of the analytical collision plane.

func (*Plane) BoundingBox

func (p *Plane) BoundingBox() math32.Box3

BoundingBox computes and returns the bounding box of the analytical collision plane.

func (*Plane) BoundingSphere

func (p *Plane) BoundingSphere() math32.Sphere

BoundingSphere computes and returns the bounding sphere of the analytical collision plane.

func (*Plane) Normal

func (p *Plane) Normal() math32.Vector3

Normal returns the normal of the analytical collision plane.

func (*Plane) ProjectOntoAxis

func (p *Plane) ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)

ProjectOntoAxis returns the minimum and maximum distances of the analytical collision plane projected onto the specified local axis.

func (*Plane) RotationalInertia

func (p *Plane) RotationalInertia(mass float32) math32.Matrix3

RotationalInertia computes and returns the rotational inertia of the analytical collision plane.

func (*Plane) Volume

func (p *Plane) Volume() float32

Volume returns the volume of the analytical collision sphere.

type Shape

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

Shape is a collision shape. It can be an analytical geometry such as a sphere, plane, etc.. or it can be defined by a polygonal Geometry.

type Sphere

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

Sphere is an analytical collision sphere.

func NewSphere

func NewSphere(radius float32) *Sphere

NewSphere creates and returns a pointer to a new analytical collision sphere.

func (*Sphere) Area

func (s *Sphere) Area() float32

Area computes and returns the surface area of the analytical collision sphere.

func (*Sphere) BoundingBox

func (s *Sphere) BoundingBox() math32.Box3

BoundingBox computes and returns the bounding box of the analytical collision sphere.

func (*Sphere) BoundingSphere

func (s *Sphere) BoundingSphere() math32.Sphere

BoundingSphere computes and returns the bounding sphere of the analytical collision sphere.

func (*Sphere) ProjectOntoAxis

func (s *Sphere) ProjectOntoAxis(localAxis *math32.Vector3) (float32, float32)

ProjectOntoAxis computes and returns the minimum and maximum distances of the analytical collision sphere projected onto the specified local axis.

func (*Sphere) Radius

func (s *Sphere) Radius() float32

Radius returns the radius of the analytical collision sphere.

func (*Sphere) RotationalInertia

func (s *Sphere) RotationalInertia(mass float32) math32.Matrix3

RotationalInertia computes and returns the rotational inertia of the analytical collision sphere.

func (*Sphere) SetRadius

func (s *Sphere) SetRadius(radius float32)

SetRadius sets the radius of the analytical collision sphere.

func (*Sphere) Volume

func (s *Sphere) Volume() float32

Volume computes and returns the volume of the analytical collision sphere.

Jump to

Keyboard shortcuts

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