collision

package
v0.0.0-...-e7bc4dc Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoundingBox

type BoundingBox struct {
	Min, Max, Cnt, Dim *Vector3
}

Encapsulates an axis aligned bounding box represented by a minimum and a maximum Vector. Additionally you can query for the bounding box's center, dimensions and corner points.

func NewBoundingBox

func NewBoundingBox() *BoundingBox

Constructs a new bounding box with the minimum and maximum vector set to zeros.

func NewBoundingBoxCopy

func NewBoundingBoxCopy(bounds *BoundingBox) *BoundingBox

Constructs a new bounding box from the given bounding box. param bounds The bounding box to copy

func NewBoundingBoxVector3

func NewBoundingBoxVector3(minimum, maximum *Vector3) *BoundingBox

Constructs the new bounding box using the given minimum and maximum vector. param minimum The minimum vector param maximum The maximum vector

func (*BoundingBox) Clr

func (self *BoundingBox) Clr() *BoundingBox

Sets the minimum and maximum vector to zeros. return This bounding box for chaining.

func (*BoundingBox) Contains

func (self *BoundingBox) Contains(b *BoundingBox) bool

Returns whether the given bounding box is contained in this bounding box. param b The bounding box return Whether the given bounding box is contained

func (*BoundingBox) ContainsV3

func (self *BoundingBox) ContainsV3(v *Vector3) bool

Returns whether the given vector is contained in this bounding box. param v The vector return Whether the vector is contained or not.

func (*BoundingBox) Ext

func (self *BoundingBox) Ext(x, y, z float32) *BoundingBox

Extends the bounding box by the given vector. param x The x-coordinate param y The y-coordinate param z The z-coordinate return This bounding box for chaining.

func (*BoundingBox) ExtB

func (self *BoundingBox) ExtB(bounds *BoundingBox) *BoundingBox

Extends this bounding box by the given bounding box. param bounds The bounding box return This bounding box for chaining.

func (*BoundingBox) ExtBT

func (self *BoundingBox) ExtBT(bounds *BoundingBox, transform *Matrix4) *BoundingBox

Extends this bounding box by the given transformed bounding box. param bounds The bounding box param transform The transformation matrix to apply to bounds, before using it to extend this bounding box. return This bounding box for chaining.

func (*BoundingBox) ExtV3

func (self *BoundingBox) ExtV3(point *Vector3) *BoundingBox

Extends the bounding box to incorporate the given {@link Vector3}. param point The vector return This bounding box for chaining.

func (*BoundingBox) GetCenter

func (self *BoundingBox) GetCenter(out *Vector3) *Vector3

@param out The {@link Vector3} to receive the center of the bounding box. return The vector specified with the out argument.

func (*BoundingBox) GetCenterX

func (self *BoundingBox) GetCenterX() float32

func (*BoundingBox) GetCenterY

func (self *BoundingBox) GetCenterY() float32

func (*BoundingBox) GetCenterZ

func (self *BoundingBox) GetCenterZ() float32

func (*BoundingBox) GetCorner000

func (self *BoundingBox) GetCorner000(out *Vector3) *Vector3

func (*BoundingBox) GetCorner001

func (self *BoundingBox) GetCorner001(out *Vector3) *Vector3

func (*BoundingBox) GetCorner010

func (self *BoundingBox) GetCorner010(out *Vector3) *Vector3

func (*BoundingBox) GetCorner011

func (self *BoundingBox) GetCorner011(out *Vector3) *Vector3

func (*BoundingBox) GetCorner100

func (self *BoundingBox) GetCorner100(out *Vector3) *Vector3

func (*BoundingBox) GetCorner101

func (self *BoundingBox) GetCorner101(out *Vector3) *Vector3

func (*BoundingBox) GetCorner110

func (self *BoundingBox) GetCorner110(out *Vector3) *Vector3

func (*BoundingBox) GetCorner111

func (self *BoundingBox) GetCorner111(out *Vector3) *Vector3

func (*BoundingBox) GetDepth

func (self *BoundingBox) GetDepth() float32

func (*BoundingBox) GetDimensions

func (self *BoundingBox) GetDimensions(out *Vector3) *Vector3

@param out The {@link Vector3} to receive the dimensions of this bounding box on all three axis. return The vector specified with the out argument

func (*BoundingBox) GetHeight

func (self *BoundingBox) GetHeight() float32

func (*BoundingBox) GetMax

func (self *BoundingBox) GetMax(out *Vector3) *Vector3

@param out The {@link Vector3} to receive the maximum values. return The vector specified with the out argument

func (*BoundingBox) GetMin

func (self *BoundingBox) GetMin(out *Vector3) *Vector3

@param out The {@link Vector3} to receive the minimum values. return The vector specified with the out argument

func (*BoundingBox) GetWidth

func (self *BoundingBox) GetWidth() float32

func (*BoundingBox) Inf

func (self *BoundingBox) Inf() *BoundingBox

Todo check Infinity Sets the minimum and maximum vector to positive and negative infinity. return This bounding box for chaining.

func (*BoundingBox) Intersects

func (self *BoundingBox) Intersects(b *BoundingBox) bool

Returns whether the given bounding box is intersecting this bounding box (at least one point in). param b The bounding box return Whether the given bounding box is intersected

func (*BoundingBox) IsValid

func (self *BoundingBox) IsValid() bool

Returns whether this bounding box is valid. This means that {@link #max} is greater than {@link #min}. return True in case the bounding box is valid, false otherwise

func (*BoundingBox) Mul

func (self *BoundingBox) Mul(transform *Matrix4) *BoundingBox

Multiplies the bounding box by the given matrix. This is achieved by multiplying the 8 corner points and then calculating the minimum and maximum vectors from the transformed points. param transform The matrix return This bounding box for chaining.

func (*BoundingBox) Set

func (self *BoundingBox) Set(min, max *Vector3) *BoundingBox

Sets the given minimum and maximum vector. param minimum The minimum vector param maximum The maximum vector return This bounding box for chaining.

func (*BoundingBox) SetB

func (self *BoundingBox) SetB(bounds *BoundingBox) *BoundingBox

Sets the given bounding box. param bounds The bounds. return This bounding box for chaining.

func (*BoundingBox) SetV

func (self *BoundingBox) SetV(points []*Vector3) *BoundingBox

Sets the bounding box minimum and maximum vector from the given points. param points The points. return This bounding box for chaining.

func (*BoundingBox) String

func (self *BoundingBox) String() string

type Ray

type Ray struct {
	Origin    *Vector3
	Direction *Vector3
}

Encapsulates a ray having a starting position and a unit length direction.

func NewRay

func NewRay(origin, direction *Vector3) *Ray

Constructor, sets the starting position of the ray and the direction. param origin The starting position param direction The direction

func NewRayEmpty

func NewRayEmpty() *Ray

func (*Ray) Copy

func (self *Ray) Copy() *Ray

return a copy of this ray.

func (*Ray) GetEndPoint

func (self *Ray) GetEndPoint(out *Vector3, distance float32) *Vector3

Returns the endpoint given the distance. This is calculated as startpoint + distance * direction. param out The vector to set to the result param distance The distance from the end point to the start point.

func (*Ray) Mul

func (self *Ray) Mul(matrix *Matrix4) *Ray

Multiplies the ray by the given matrix. Use this to transform a ray into another coordinate system. param matrix The matrix

func (*Ray) Set

func (self *Ray) Set(x, y, z, dx, dy, dz float32) *Ray

Sets this ray from the given starting position and direction. param x The x-component of the starting position param y The y-component of the starting position param z The z-component of the starting position param dx The x-component of the direction param dy The y-component of the direction param dz The z-component of the direction

func (*Ray) SetRay

func (self *Ray) SetRay(ray *Ray) *Ray

Sets the starting position and direction from the given ray param ray The ray

func (*Ray) SetV3

func (self *Ray) SetV3(origin, direction *Vector3) *Ray

Sets the starting position and the direction of this ray. param origin The starting position param direction The direction

func (*Ray) String

func (self *Ray) String() string

type Segment

type Segment struct {
	// the starting position
	A *Vector3

	// the ending position
	B *Vector3
}

A Segment is a line in 3-space having a staring and an ending position.

func NewSegment

func NewSegment(aX, aY, aZ, bX, bY, bZ float32) *Segment

Constructs a new Segment from the two points given. param aX the x-coordinate of the first point param aY the y-coordinate of the first point param aZ the z-coordinate of the first point param bX the x-coordinate of the second point param bY the y-coordinate of the second point param bZ the z-coordinate of the second point

func NewSegmentV

func NewSegmentV(a, b *Vector3) *Segment

Constructs a new Segment from the two points given. param b the second point

func (*Segment) Len

func (self *Segment) Len() float32

func (*Segment) Len2

func (self *Segment) Len2() float32

type Sphere

type Sphere struct {
	Radius float32
	Center *Vector3
}

Encapsulates a 3D sphere with a center and a radius

func NewSphere

func NewSphere(center *Vector3, radius float32) *Sphere

Constructs a sphere with the given center and radius param center The center param radius The radius

func (*Sphere) Overlaps

func (self *Sphere) Overlaps(sphere *Sphere) bool

@param sphere the other sphere return whether this and the other sphere overlap

func (*Sphere) SurfaceArea

func (self *Sphere) SurfaceArea() float32

func (*Sphere) Volume

func (self *Sphere) Volume() float32

Jump to

Keyboard shortcuts

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