MCPcopy
hub / github.com/g3n/engine / ApplyProjection

Method ApplyProjection

math32/vector3.go:479–489  ·  view source on GitHub ↗

ApplyProjection applies the projection matrix m to this vector Returns the pointer to this updated vector.

(m *Matrix4)

Source from the content-addressed store, hash-verified

477// ApplyProjection applies the projection matrix m to this vector
478// Returns the pointer to this updated vector.
479func (v *Vector3) ApplyProjection(m *Matrix4) *Vector3 {
480
481 x := v.X
482 y := v.Y
483 z := v.Z
484 d := 1 / (m[3]*x + m[7]*y + m[11]*z + m[15]) // perspective divide
485 v.X = (m[0]*x + m[4]*y + m[8]*z + m[12]) * d
486 v.Y = (m[1]*x + m[5]*y + m[9]*z + m[13]) * d
487 v.Z = (m[2]*x + m[6]*y + m[10]*z + m[14]) * d
488 return v
489}
490
491// ApplyQuaternion transforms this vector by multiplying it by
492// the specified quaternion and then by the quaternion inverse.

Callers 2

ProjectMethod · 0.80
UnprojectMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected