MCPcopy
hub / github.com/fogleman/ln / LookAt

Function LookAt

ln/matrix.go:74–86  ·  view source on GitHub ↗
(eye, center, up Vector)

Source from the content-addressed store, hash-verified

72}
73
74func LookAt(eye, center, up Vector) Matrix {
75 up = up.Normalize()
76 f := center.Sub(eye).Normalize()
77 s := f.Cross(up).Normalize()
78 u := s.Cross(f).Normalize()
79 m := Matrix{
80 s.X, u.X, -f.X, eye.X,
81 s.Y, u.Y, -f.Y, eye.Y,
82 s.Z, u.Z, -f.Z, eye.Z,
83 0, 0, 0, 1,
84 }
85 return m.Inverse()
86}
87
88func (m Matrix) Translate(v Vector) Matrix {
89 return Translate(v).Mul(m)

Callers 1

RenderMethod · 0.85

Calls 4

InverseMethod · 0.95
NormalizeMethod · 0.80
SubMethod · 0.80
CrossMethod · 0.80

Tested by

no test coverage detected