mobile: golang.org/x/mobile/exp/f32 Index | Files

package f32

import "golang.org/x/mobile/exp/f32"

Package f32 implements some linear algebra and GL helpers for float32s.

Types defined in this package have methods implementing common mathematical operations. The common form for these functions is

func (dst *T) Op(lhs, rhs *T)

which reads in traditional mathematical notation as

dst = lhs op rhs.

It is safe to use the destination address as the left-hand side, that is, dst *= rhs is dst.Mul(dst, rhs).

WARNING

The interface to this package is not stable. It will change considerably. Only use functions that provide package documentation. Semantics are non-obvious. Be prepared for the package name to change.

Index

Package Files

affine.go f32.go mat3.go mat4.go table.go vec3.go vec4.go

func Bytes Uses

func Bytes(byteOrder binary.ByteOrder, values ...float32) []byte

Bytes returns the byte representation of float32 values in the given byte order. byteOrder must be either binary.BigEndian or binary.LittleEndian.

func Cos Uses

func Cos(x float32) float32

func Sin Uses

func Sin(x float32) float32

func Sqrt Uses

func Sqrt(x float32) float32

func Tan Uses

func Tan(x float32) float32

type Affine Uses

type Affine [2]Vec3

An Affine is a 3x3 matrix of float32 values for which the bottom row is implicitly always equal to [0 0 1]. Elements are indexed first by row then column, i.e. m[row][column].

func (*Affine) Eq Uses

func (m *Affine) Eq(n *Affine, epsilon float32) bool

Eq reports whether each component of m is within epsilon of the same component in n.

func (*Affine) Identity Uses

func (m *Affine) Identity()

Identity sets m to be the identity transform.

func (*Affine) Inverse Uses

func (m *Affine) Inverse(p *Affine)

Inverse sets m to be the inverse of p.

func (*Affine) Mul Uses

func (m *Affine) Mul(p, q *Affine)

Mul sets m to be p × q.

func (*Affine) Rotate Uses

func (m *Affine) Rotate(p *Affine, radians float32)

Rotate sets m to a rotation in radians followed by p. It is equivalent to m.Mul(p, affineRotation).

func (*Affine) Scale Uses

func (m *Affine) Scale(p *Affine, x, y float32)

Scale sets m to be a scale followed by p. It is equivalent to m.Mul(p, &Affine{{x,0,0}, {0,y,0}}).

func (Affine) String Uses

func (m Affine) String() string

func (*Affine) Translate Uses

func (m *Affine) Translate(p *Affine, x, y float32)

Translate sets m to be a translation followed by p. It is equivalent to m.Mul(p, &Affine{{1,0,x}, {0,1,y}}).

type Mat3 Uses

type Mat3 [3]Vec3

A Mat3 is a 3x3 matrix of float32 values. Elements are indexed first by row then column, i.e. m[row][column].

func (*Mat3) Eq Uses

func (m *Mat3) Eq(n *Mat3, epsilon float32) bool

func (*Mat3) Identity Uses

func (m *Mat3) Identity()

func (*Mat3) Mul Uses

func (m *Mat3) Mul(a, b *Mat3)

Mul stores a × b in m.

func (Mat3) String Uses

func (m Mat3) String() string

type Mat4 Uses

type Mat4 [4]Vec4

A Mat4 is a 4x4 matrix of float32 values. Elements are indexed first by row then column, i.e. m[row][column].

func (*Mat4) Eq Uses

func (m *Mat4) Eq(n *Mat4, epsilon float32) bool

func (*Mat4) Identity Uses

func (m *Mat4) Identity()

func (*Mat4) LookAt Uses

func (m *Mat4) LookAt(eye, center, up *Vec3)

func (*Mat4) Mul Uses

func (m *Mat4) Mul(a, b *Mat4)

Mul stores a × b in m.

func (*Mat4) Perspective Uses

func (m *Mat4) Perspective(fov Radian, aspect, near, far float32)

Perspective sets m to be the GL perspective matrix.

func (*Mat4) Rotate Uses

func (m *Mat4) Rotate(p *Mat4, angle Radian, axis *Vec3)

Rotate sets m to a rotation in radians around a specified axis, followed by p. It is equivalent to m.Mul(p, affineRotation).

func (*Mat4) Scale Uses

func (m *Mat4) Scale(p *Mat4, x, y, z float32)

Scale sets m to be a scale followed by p. It is equivalent to

m.Mul(p, &Mat4{
	{x, 0, 0, 0},
	{0, y, 0, 0},
	{0, 0, z, 0},
	{0, 0, 0, 1},
}).

func (Mat4) String Uses

func (m Mat4) String() string

func (*Mat4) Translate Uses

func (m *Mat4) Translate(p *Mat4, x, y, z float32)

Translate sets m to be a translation followed by p. It is equivalent to

m.Mul(p, &Mat4{
	{1, 0, 0, x},
	{0, 1, 0, y},
	{0, 0, 1, z},
	{0, 0, 0, 1},
}).

type Radian Uses

type Radian float32

type Vec3 Uses

type Vec3 [3]float32

func (*Vec3) Add Uses

func (v *Vec3) Add(v0, v1 *Vec3)

func (*Vec3) Cross Uses

func (v *Vec3) Cross(v0, v1 *Vec3)

func (*Vec3) Dot Uses

func (v *Vec3) Dot(v1 *Vec3) float32

func (*Vec3) Mul Uses

func (v *Vec3) Mul(v0, v1 *Vec3)

func (*Vec3) Normalize Uses

func (v *Vec3) Normalize()

func (Vec3) String Uses

func (v Vec3) String() string

func (*Vec3) Sub Uses

func (v *Vec3) Sub(v0, v1 *Vec3)

type Vec4 Uses

type Vec4 [4]float32

func (*Vec4) Add Uses

func (v *Vec4) Add(v0, v1 *Vec4)

func (*Vec4) Dot Uses

func (v *Vec4) Dot(v1 *Vec4) float32

func (*Vec4) Mul Uses

func (v *Vec4) Mul(v0, v1 *Vec4)

func (*Vec4) Normalize Uses

func (v *Vec4) Normalize()

func (Vec4) String Uses

func (v Vec4) String() string

func (*Vec4) Sub Uses

func (v *Vec4) Sub(v0, v1 *Vec4)

Package f32 imports 3 packages (graph) and is imported by 39 packages. Updated 2017-10-17. Refresh now. Tools for package owners.