Skip to content

Instantly share code, notes, and snippets.

@antoinefortin
Created December 13, 2021 06:10
Show Gist options
  • Save antoinefortin/3eeadcb04932be8d63688c1b03d42b31 to your computer and use it in GitHub Desktop.
Save antoinefortin/3eeadcb04932be8d63688c1b03d42b31 to your computer and use it in GitHub Desktop.
/*
[ 1 0 0 x ]
[ 0 1 0 y ]
[ 0 0 1 z ]
[ 0 0 0 1 ]
*/
public void TranslateTransform(
ref Vector4 inVert,
float xT,
float yT,
float zT
)
{
Matrix4x4 tm = new Matrix4x4();
// row 0
tm[0, 0] = 1.0f;
tm[0, 1] = 0.0f;
tm[0, 2] = 0.0f;
tm[0, 3] = xT;
// row 1
tm[1, 0] = 0.0f;
tm[1, 1] = 1.0f;
tm[1, 2] = 0.0f;
tm[1, 3] = yT;
// row 2
tm[2, 0] = 0.0f;
tm[2, 1] = 0.0f;
tm[2, 2] = 1.0f;
tm[2, 3] = zT;
// row 3
tm[3, 0] = 0.0f;
tm[3, 1] = 0.0f;
tm[3, 2] = 0.0f;
tm[3, 3] = 1.0f;
inVert = tm.MultiplyPoint(inVert);
Debug.Log(inVert);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment