I'm trying to determine what coordinates are in one space when given a point in another space.
For example, I've got a Matrix4x4 that I can use to convert a point in unity's world space to a skewed space defined by that matrix.
The inverse of this matrix returns me to the original world space.
private float HALF_SQRT_3 = Mathf.Sqrt(3) / 2;
private Matrix4x4 mWorldToSkewGrid = new Matrix4x4(
new Vector4(HALF_SQRT_3, 0, 0, 0),
new Vector4(0, 1, 0, 0),
new Vector4(Mathf.Cos(Mathf.PI / 3) * HALF_SQRT_3, 0, Mathf.Sin(Mathf.PI / 3) * HALF_SQRT_3, 0),
new Vector4(0, 0, 0, 1)
);
private Matrix4x4 mSkewGridToWorld = mWorldToSkewGrid.inverse;
I'm attempting to figure out how I can go about getting the coordinates of the skewed space AT the default world space rather than transforming a point in default space to the skewed space.
I assumed it was something similar to how unity converts a screen point into a world point. Something like this:
Vector4 p = mSkewGridToWorld * new Vector4(defaultWorldPos.x, defaultWorldPos.y, defaultWorldPos.z, 1.0f);
p.w = 1.0f / p.w;
p.x *= p.w;
p.y *= p.w;
p.z *= p.w;
Where p
is intended to hold the position of defaultWorldPos
but in the skewed coordinates where it would overlap in the skewed space.
Edit: Below is an example of the "default world space" in green being transformed into the "skewed space" in red, represented by a 10x10 grid. Rather than transforming say the grid cell 5x5 to the other space resulting in the point moving and being still at 5x5 in the skewed space, I want to know what skewed point is under 5x5, in this example it would be something like 2x6 in the skewed space.