# Difference between Transform.InverseTransformPoint(v) and Transform.worldToLocalMatrix * v

Basically, the following fragment

``````        Vector3 vertexLocal = transform.worldToLocalMatrix * vertex;
Vector3 vertexLocalTest = transform.InverseTransformPoint(vertex);
if (vertexLocal != vertexLocalTest) {
Debug.LogError("I don't get it: " + vertexLocal + " != " + vertexLocalTest);
return;
}

``````

Produces errors in console. It seems as if multiplication (vertexLocal) transforms the point not from world coordinates but from parent's coordinates. I assumed the two transformations were supposed to be identical. Aren't they?

Don't use `transform.worldToLocalMatrix * vertex`

Use `transform.worldToLocalMatrix.MultiplyPoint(vertex)`

or `transform.worldToLocalMatrix.MultiplyPoint3x4(vertex)` (more efficient)

Then you'll get identical results as expected.

Since `worldToLocalMatrix` is a 4x4 matrix and `vertex` is only a Vector3 when the two are multiplied together `vertex` is automatically converted to a Vector4 with a 4th component of 0.

So

``````transform.worldToLocalMatrix * vertex
``````

Is the same as

``````transform.worldToLocalMatrix * new Vector4(vertex.x, vertex.y, vertex.z, 0)
``````

But when that forth component is 0 the multiplication is ignoring the position of the matrix, which is why you see the wrong result.

As runevision has pointed out the following

``````transform.InverseTransformPoint(vertex)
``````

Is the same as

``````transform.worldToLocalMatrix.MultiplyPoint3x4(vertex)
``````

Which is the same as

``````transform.worldToLocalMatrix * new Vector4(vertex.x, vertex.y, vertex.z, 1)
``````