ApplyProjection applies the projection matrix m to this vector Returns the pointer to this updated vector.
(m *Matrix4)
| 477 | // ApplyProjection applies the projection matrix m to this vector |
| 478 | // Returns the pointer to this updated vector. |
| 479 | func (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. |