linmath

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 1 Imported by: 0

README

linmath

Based on linmath.h by Wolfgang 'datenwolf' Draxinger <code@datenwolf.net> (licensed under WTFPL).

Features and limitations

Several functions and types are provided:

  • Vec2, a 2 element vector of float64 (x,y)
  • Vec3, a 3 element vector of float64 (x,y,z)
  • Vec4, a 4 element vector of float64 (4th component used for homogenous computations)
  • Mat4x4, a 4 by 4 elements matrix (computations are done in column major order)
  • Quat, a 4 element vector of float64 (x,y,z,w)

These may be useful for computer graphics programming.

TODO

  • Add tests

General info

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Vec2Len

func Vec2Len(v Vec2) float64

func Vec2MulInner

func Vec2MulInner(a, b Vec2) (r float64)

func Vec3Len

func Vec3Len(v Vec3) float64

func Vec3MulInner

func Vec3MulInner(a, b Vec3) (r float64)

func Vec4Len

func Vec4Len(v Vec4) float64

func Vec4MulInner

func Vec4MulInner(a, b Vec4) (r float64)

Types

type Mat4x4

type Mat4x4 [4]Vec4

func (*Mat4x4) Add

func (M *Mat4x4) Add(a, b Mat4x4)

func (*Mat4x4) Col

func (M *Mat4x4) Col(i int) (r Vec4)

func (*Mat4x4) Dup

func (M *Mat4x4) Dup(N Mat4x4)

func (*Mat4x4) FromVec3MulOuter

func (M *Mat4x4) FromVec3MulOuter(a, b Vec3)

func (*Mat4x4) Frustum

func (M *Mat4x4) Frustum(l, r, b, t, n, f float64)

func (*Mat4x4) Identity

func (M *Mat4x4) Identity()

func (*Mat4x4) Invert

func (M *Mat4x4) Invert(M2 Mat4x4)

func (*Mat4x4) LookAt

func (M *Mat4x4) LookAt(eye, center, up Vec3)

func (*Mat4x4) Mul

func (M *Mat4x4) Mul(a, b Mat4x4)

func (*Mat4x4) MulQuat

func (M *Mat4x4) MulQuat(RM Mat4x4, q Quat)

func (*Mat4x4) MulVec4

func (M *Mat4x4) MulVec4(v Vec4) (r Vec4)

func (*Mat4x4) Ortho

func (M *Mat4x4) Ortho(l, r, b, t, n, f float64)

func (*Mat4x4) Orthonormalize

func (M *Mat4x4) Orthonormalize(RM Mat4x4)

func (*Mat4x4) Perspective

func (M *Mat4x4) Perspective(yFOV, aspect, n, f float64)

func (*Mat4x4) Quat

func (M *Mat4x4) Quat() (q Quat)

func (*Mat4x4) Rotate

func (M *Mat4x4) Rotate(R Mat4x4, x, y, z, angle float64)

func (*Mat4x4) RotateX

func (M *Mat4x4) RotateX(R Mat4x4, angle float64)

func (*Mat4x4) RotateY

func (M *Mat4x4) RotateY(R Mat4x4, angle float64)

func (*Mat4x4) RotateZ

func (M *Mat4x4) RotateZ(R Mat4x4, angle float64)

func (*Mat4x4) Row

func (M *Mat4x4) Row(i int) (r Vec4)

func (*Mat4x4) Scale

func (M *Mat4x4) Scale(a Mat4x4, k float64)

func (*Mat4x4) ScaleAniso

func (M *Mat4x4) ScaleAniso(a Mat4x4, x, y, z float64)

func (*Mat4x4) Sub

func (M *Mat4x4) Sub(a, b Mat4x4)

func (*Mat4x4) Translate

func (M *Mat4x4) Translate(x, y, z float64)

func (*Mat4x4) TranslateInPlace

func (M *Mat4x4) TranslateInPlace(x, y, z float64)

func (*Mat4x4) Transpose

func (M *Mat4x4) Transpose(N Mat4x4)

type Quat

type Quat [4]float64

func QuatIdentity

func QuatIdentity() (r Quat)

func QuatRotate

func QuatRotate(angle float64, axis Vec3) (r Quat)

func (Quat) Add

func (q Quat) Add(b Quat) (r Quat)

func (Quat) Conj

func (q Quat) Conj() (r Quat)

func (Quat) InnerProduct

func (q Quat) InnerProduct(b Quat) (p float64)

func (Quat) Mat4x4

func (q Quat) Mat4x4() (M Mat4x4)

func (Quat) Mul

func (q Quat) Mul(b Quat) (r Quat)

func (Quat) MulVec3

func (q Quat) MulVec3(v Vec3) (r Vec3)

func (Quat) Norm

func (q Quat) Norm() Quat

func (Quat) Scale

func (q Quat) Scale(s float64) (r Quat)

func (Quat) Sub

func (q Quat) Sub(b Quat) (r Quat)

func (Quat) Vec3

func (q Quat) Vec3() (r Vec3)

func (Quat) Vec4

func (q Quat) Vec4() (v Vec4)

type Vec2

type Vec2 [2]float64

func Vec2Add

func Vec2Add(a, b Vec2) (r Vec2)

func Vec2Max

func Vec2Max(a, b Vec2) (r Vec2)

func Vec2Min

func Vec2Min(a, b Vec2) (r Vec2)

func Vec2Norm

func Vec2Norm(v Vec2) Vec2

func Vec2Scale

func Vec2Scale(v Vec2, s float64) (r Vec2)

func Vec2Sub

func Vec2Sub(a, b Vec2) (r Vec2)

type Vec3

type Vec3 [3]float64

func Vec3Add

func Vec3Add(a, b Vec3) (r Vec3)

func Vec3Max

func Vec3Max(a, b Vec3) (r Vec3)

func Vec3Min

func Vec3Min(a, b Vec3) (r Vec3)

func Vec3MulCross

func Vec3MulCross(a, b Vec3) (r Vec3)

func Vec3Norm

func Vec3Norm(v Vec3) Vec3

func Vec3Reflect

func Vec3Reflect(v, n Vec3) (r Vec3)

func Vec3Scale

func Vec3Scale(v Vec3, s float64) (r Vec3)

func Vec3Sub

func Vec3Sub(a, b Vec3) (r Vec3)

func (Vec3) Vec4

func (v Vec3) Vec4() (r Vec4)

Vec4 creates a Vec4 from a given Vec3

type Vec4

type Vec4 [4]float64

func Vec4Add

func Vec4Add(a, b Vec4) (r Vec4)

func Vec4Max

func Vec4Max(a, b Vec4) (r Vec4)

func Vec4Min

func Vec4Min(a, b Vec4) (r Vec4)

func Vec4MulCross

func Vec4MulCross(a, b Vec4) (r Vec4)

func Vec4Norm

func Vec4Norm(v Vec4) Vec4

func Vec4Reflect

func Vec4Reflect(v, n Vec4) (r Vec4)

func Vec4Scale

func Vec4Scale(v Vec4, s float64) (r Vec4)

func Vec4Sub

func Vec4Sub(a, b Vec4) (r Vec4)

func (Vec4) Quat

func (v Vec4) Quat() (q Quat)

func (Vec4) Vec3

func (v Vec4) Vec3() (r Vec3)

Vec3 creates a Vec3 from a given Vec4

Jump to

Keyboard shortcuts

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