Suppose you have a vector called

*direction*and a point

*P*and we want to get the distance along that vector relative to the origin.

We can use the dot-product like this:

myDistanceToOrigin = DotProduct(P, direction);Now if we want to get that point back again using

*myDistanceToOrigin*and

*direction*we can do:

P = myDistanceToOrigin * direction;So in a way a dot-product behaves like the inverse of a scalar * vector operation, along a line.

We're extracting how far a point is along a specific vector.

Now suppose we decompose a point into a distances using dot-products, one each for each axis:

myDistanceX = DotProduct(P, xAxis); myDistanceY = DotProduct(P, yAxis); myDistanceZ = DotProduct(P, zAxis);At this point we're left with 3 distances, along 3 vectors.

Is there a way to reverse this? why yes.

P = (myDistanceX * xAxis) + (myDistanceY * yAxis) + (myDistanceZ * zAxis);Now imagine that instead of using the original 3 vectors, we use different vectors.

What would happen?

Well each distance is a distance traveled on a particular axis, so we'd still end up with a valid point, but it would be positioned relative to the new vectors instead of the original vectors.

It would be

*transformed*into a different position.

*You might know this as a 3x3 matrix multiplication*

Except that for the 'distances' we simply use the X,Y and Z coordinates of a point/vector instead.

Note that if the xAxis has the values (1,0,0) , the yAxis has the values (0,1,0) and the xAxis has the values (0,0,1) the distances would be equal to the original X,Y & Z coordinates.

This is the identity matrix.

What we're essentially doing is defining an imaginary cube with 3 vectors, and then deforming that imaginary cube and all the points inside it.

So what about the 4x4 matrix? Well this is a 4D version of the 3x3 matrix, and it works the same way. Except that the fourth value is a coordinate in the fourth dimension but ends up acting like a translation in 3D space.

Planes are 4D, does this mean that in a 4x4 matrix we have planes instead of vectors?

No, not really.

The 4x4 matrices work with what we call homogenous coordinates, and I'm not going into this right now, because that's a whole different rabbit hole.

However, it

*is*possible to extract the planes that form that imaginary cube I mentioned before from the matrix.

## Next time

I'll write some more posts in the future about- ray-plane intersections
- snapping, how you'd snap a point on an arbitrary grid in 3D, or along a line
- half-edges, fat planes, and how you'd split a polygon using both