Last active
June 23, 2018 06:12
-
-
Save justinmeiners/6568753eb12714390c2a010cee48e0cf to your computer and use it in GitHub Desktop.
Difference between MultiplyPoint and MultiplyPoint3x4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See my SO answer https://stackoverflow.com/questions/35208476/unity3d-difference-between-multiplypoint-and-multiplypoint3x4 | |
// https://github.com/jameslinden/unity-decompiled/blob/master/UnityEngine/UnityEngine/Matrix4x4.cs | |
public Vector3 MultiplyPoint(Vector3 v) | |
{ | |
Vector3 vector3; | |
vector3.x = ( m00 * v.x + m01 * v.y + m02 * v.z) + m03; | |
vector3.y = ( m10 * v.x + m11 * v.y + m12 * v.z) + m13; | |
vector3.z = ( m20 * v.x + m21 * v.y + m22 * v.z) + m23; | |
float num = 1f / ( ( m30 * v.x + m31 * v.y + m32 * v.z) + m33); | |
vector3.x *= num; | |
vector3.y *= num; | |
vector3.z *= num; | |
return vector3; | |
} | |
public Vector3 MultiplyPoint3x4(Vector3 v) | |
{ | |
Vector3 vector3; | |
vector3.x = ( m00 * v.x + m01 * v.y + m02 * v.z) + m03; | |
vector3.y = ( m10 * v.x + m11 * v.y + m12 * v.z) + m13; | |
vector3.z = ( m20 * v.x + m21 * v.y + m22 * v.z) + m23; | |
return vector3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment