How to find the relative location of a 3d point on a surface transformed in 3d space [closed]

StackOverflow https://stackoverflow.com/questions/19206645

  •  30-06-2022
  •  | 
  •  

Вопрос

I have a math/vector/matrix question that I can't seem to work out.

I have 4 points in 3D space that represent the bounds of a surface.

I have written a raycast algoritum to get the intersection location of the mouse "ray" against the rectangle in the 3d scene.

The rectangle in the scene has a rotation and translation matrix applied to it so it can be moved anywhere in the scene, and my raycast system does correctly get the ray hit location on the surface.

My problem is that I need to now take the Ray Hit location that is in world space and work out where on the 2d surface of the rectangle the hit is.

I cannot work out how to do this.

Это было полезно?

Решение

Your hit point is in the world space. To get the point in the same coordinate system as the original 4 points, just calculate the inverse of the rotation and translation matrix and multiply this inverse matrix by the hit point.

The resulting point will be in the same coordinate system as the 4 points that represent the bounds of the surface.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top