physics

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyIntersections

func AnyIntersections(boxes []AABB, search AABB) bool

AnyIntersections checks if any of boxes1 have intersections with any of boxes2 and returns true if this happens to be the case.

Types

type AABB

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

AABB represents an Axis Aligned Bounding Box in a 3D space. It is defined as two Vec3s, of which one is the minimum and one is the maximum.

func NewAABB

func NewAABB(min, max mgl64.Vec3) AABB

NewAABB creates a new axis aligned bounding box with the minimum and maximum coordinates provided.

func (AABB) CalculateXOffset

func (aabb AABB) CalculateXOffset(nearby AABB, deltaX float64) float64

CalculateXOffset calculates the offset on the X axis between two bounding boxes, returning a delta always smaller than or equal to deltaX if deltaX is bigger than 0, or always bigger than or equal to deltaX if it is smaller than 0.

func (AABB) CalculateYOffset

func (aabb AABB) CalculateYOffset(nearby AABB, deltaY float64) float64

CalculateYOffset calculates the offset on the Y axis between two bounding boxes, returning a delta always smaller than or equal to deltaY if deltaY is bigger than 0, or always bigger than or equal to deltaY if it is smaller than 0.

func (AABB) CalculateZOffset

func (aabb AABB) CalculateZOffset(nearby AABB, deltaZ float64) float64

CalculateZOffset calculates the offset on the Z axis between two bounding boxes, returning a delta always smaller than or equal to deltaZ if deltaZ is bigger than 0, or always bigger than or equal to deltaZ if it is smaller than 0.

func (AABB) Extend

func (aabb AABB) Extend(vec mgl64.Vec3) AABB

Extend expands the AABB on all axes as represented by the Vec3 passed. Negative coordinates result in an expansion towards the negative axis, and vice versa for positive coordinates.

func (AABB) ExtendTowards

func (aabb AABB) ExtendTowards(d int, x float64) AABB

ExtendTowards extends the bounding box by x in a given direction.

func (AABB) Grow

func (aabb AABB) Grow(x float64) AABB

Grow grows the bounding box in all directions by x and returns the new bounding box.

func (AABB) GrowVec3

func (aabb AABB) GrowVec3(vec mgl64.Vec3) AABB

GrowVec3 grows the AABB on all axes as represented by the Vec3 passed. The vec values are subtracted from the minimum values of the AABB and added to the maximum values of the AABB.

func (AABB) Height

func (aabb AABB) Height() float64

Height returns the height of the AABB.

func (AABB) IntersectsWith

func (aabb AABB) IntersectsWith(other AABB) bool

IntersectsWith checks if the AABB intersects with another AABB, returning true if this is the case.

func (AABB) Length

func (aabb AABB) Length() float64

Length returns the length of the AABB.

func (AABB) Max

func (aabb AABB) Max() mgl64.Vec3

Max returns the maximum coordinate of the bounding box.

func (AABB) Min

func (aabb AABB) Min() mgl64.Vec3

Min returns the minimum coordinate of the bounding box.

func (AABB) Stretch

func (aabb AABB) Stretch(a int, x float64) AABB

Stretch stretches the bounding box by x in a given axis.

func (AABB) Translate

func (aabb AABB) Translate(vec mgl64.Vec3) AABB

Translate moves the entire AABB with the Vec3 given. The (minimum and maximum) x, y and z coordinates are moved by those in the Vec3 passed.

func (AABB) Vec3Within

func (aabb AABB) Vec3Within(vec mgl64.Vec3) bool

Vec3Within checks if the AABB has a Vec3 within it, returning true if it does.

func (AABB) Width

func (aabb AABB) Width() float64

Width returns the width of the AABB.

Jump to

Keyboard shortcuts

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