func (cube *CollisionCube) GetTransform() m.Matrix3x4 {
	return cube.transform
}
GetTransform returns a copy of the transform matrix for the collider object.
package cubez
import (
	m "github.com/tbogdala/cubez/math"
)
type Collider interface {
	Clone() Collider
	CalculateDerivedData()
	GetBody() *RigidBody
	GetTransform() m.Matrix3x4
	CheckAgainstHalfSpace(plane *CollisionPlane, existingContacts []*Contact) (bool, []*Contact)
	CheckAgainstSphere(sphere *CollisionSphere, existingContacts []*Contact) (bool, []*Contact)
	CheckAgainstCube(secondCube *CollisionCube, existingContacts []*Contact) (bool, []*Contact)
}
type CollisionPlane struct {
	Normal m.Vector3
	Offset m.Real
}
type CollisionCube struct {
	Body *RigidBody
	Offset m.Matrix3x4
	transform m.Matrix3x4
	HalfSize m.Vector3
}
type CollisionSphere struct {
	Body *RigidBody
	Offset m.Matrix3x4
	transform m.Matrix3x4
	Radius m.Real
}
func NewCollisionPlane(n m.Vector3, o m.Real) *CollisionPlane {
	plane := new(CollisionPlane)
	plane.Normal = n
	plane.Offset = o
	return plane
}
func (p *CollisionPlane) Clone() Collider {
	newPlane := NewCollisionPlane(p.Normal, p.Offset)
	return newPlane
}
func (p *CollisionPlane) CalculateDerivedData() {
}
func (p *CollisionPlane) GetTransform() m.Matrix3x4 {
	var m m.Matrix3x4
	m.SetIdentity()
	return m
}
func (p *CollisionPlane) GetBody() *RigidBody {
	return nil
}
func (p *CollisionPlane) CheckAgainstHalfSpace(plane *CollisionPlane, existingContacts []*Contact) (bool, []*Contact) {
	return false, existingContacts
}
func (p *CollisionPlane) CheckAgainstSphere(sphere *CollisionSphere, existingContacts []*Contact) (bool, []*Contact) {
	return sphere.CheckAgainstHalfSpace(p, existingContacts)
}
func (p *CollisionPlane) CheckAgainstCube(cube *CollisionCube, existingContacts []*Contact) (bool, []*Contact) {
	return cube.CheckAgainstHalfSpace(p, existingContacts)
}
func NewCollisionSphere(optBody *RigidBody, radius m.Real) *CollisionSphere {
	s := new(CollisionSphere)
	s.Offset.SetIdentity()
	s.Radius = radius
	s.Body = optBody
	if s.Body == nil {
		s.Body = NewRigidBody()
	}
	return s
}
func (s *CollisionSphere) Clone() Collider {
	var bClone *RigidBody
	if s.Body != nil {
		bClone = s.Body.Clone()
	}
	newSphere := NewCollisionSphere(bClone, s.Radius)
	newSphere.Offset = s.Offset
	newSphere.transform = s.transform
	return newSphere
}
func (s *CollisionSphere) GetTransform() m.Matrix3x4 {
	return s.transform
}
func (s *CollisionSphere) GetBody() *RigidBody {
	return s.Body
}
func (s *CollisionSphere) CalculateDerivedData() {
	transform := s.Body.GetTransform()
	s.transform = transform.MulMatrix3x4(&s.Offset)
}
func (s *CollisionSphere) CheckAgainstHalfSpace(plane *CollisionPlane, existingContacts []*Contact) (bool, []*Contact) {
	positionAxis := s.transform.GetAxis(3)
	distance := plane.Normal.Dot(&positionAxis) - s.Radius
	if distance <= plane.Offset == false {
		return false, existingContacts
	}
	c := NewContact()
	c.ContactPoint = plane.Normal
	c.ContactPoint.MulWith(distance + s.Radius*-1.0)
	c.ContactPoint.Add(&positionAxis)
	c.ContactNormal = plane.Normal
	c.Penetration = -distance
	c.Bodies[0] = s.Body
	c.Bodies[1] = nil
	c.Friction = 0.9
	c.Restitution = 0.1
	contacts := append(existingContacts, c)
	return true, contacts
}
func (s *CollisionSphere) CheckAgainstCube(cube *CollisionCube, existingContacts []*Contact) (bool, []*Contact) {
	return cube.CheckAgainstSphere(s, existingContacts)
}
func (s *CollisionSphere) CheckAgainstSphere(secondSphere *CollisionSphere, existingContacts []*Contact) (bool, []*Contact) {
	positionOne := s.transform.GetAxis(3)
	positionTwo := secondSphere.transform.GetAxis(3)
	midline := positionOne
	midline.Sub(&positionTwo)
	size := midline.Magnitude()
	if size <= 0.0 || size >= s.Radius+secondSphere.Radius {
		return false, existingContacts
	}
	c := NewContact()
	c.ContactPoint = midline
	c.ContactPoint.MulWith(0.5)
	c.ContactPoint.Add(&positionOne)
	c.ContactNormal = midline
	c.ContactNormal.MulWith(1.0 / size)
	c.Penetration = s.Radius + secondSphere.Radius - size
	c.Bodies[0] = s.Body
	c.Bodies[1] = secondSphere.Body
	c.Friction = 0.9
	c.Restitution = 0.1
	contacts := append(existingContacts, c)
	return true, contacts
}
func NewCollisionCube(optBody *RigidBody, halfSize m.Vector3) *CollisionCube {
	cube := new(CollisionCube)
	cube.Offset.SetIdentity()
	cube.HalfSize = halfSize
	cube.Body = optBody
	if cube.Body == nil {
		cube.Body = NewRigidBody()
	}
	return cube
}
func (cube *CollisionCube) Clone() Collider {
	var bClone *RigidBody
	if cube.Body != nil {
		bClone = cube.Body.Clone()
	}
	newCube := NewCollisionCube(bClone, cube.HalfSize)
	newCube.Offset = cube.Offset
	newCube.transform = cube.transform
	return newCube
}