[Math] Finding position of point (in 3D space ) which are at x,y offset from corner of a rectangle in 3D world

3dgeometry

So I am writing a 3D graphic software. And I am stuck at mathematical problem.

Mathematically speaking:

  • There's a rectangle (plane) of finite size in 3D space. It can be of any orientation and at any position in 3D world. Not necessarily parallel to any standard planes formed by axis (ie XY plane or YZ plane or XZ plane)

  • I know the four corner point's position in 3D space(ie x,y,z co-ordinates with respect to world center 0,0,0).

  • I also know which one among four points is topleft (topleft to camera looking at rectangle), which one is top-right/bottom-left/bottom-right.

Now if we consider rectangle only in 2D (and just forget about 3D world), then take any top-left corner point A, then there can be a point B which is in plane, and is at offset x, offset y away from corner point.

Here I want the Point B's position in actual 3D space (x,y,z coordinates) at given offset-x and offset-y values.

Note :

Offset-x and offset-y aren't x,y co-ordinates of 3D space. But they are just right and bottom distance (or offset positions) from top-left corner of 2D rectangle itself. (for example if the rectangle is 500 x 500 in dimension, if we take Top-left corner point A and try to find B which is at offset-x = 250 and offset-y = 250 from corner A, then point B will be center point of rectangle.)

What I tried:

  • I tried to find line containing top-left corner point A1, and top right corner point A2. And then I could find point 'P' at given offset-x from top-left point on that line.
  • Same way I found line containing top-left corner A1 and bottom-left corner A2. And found point 'Q' at offset-y from top left corner on that line.

  • Now B which I needed to find, will be fourth point of rectangle formed by P, Q, A1.

That's all I know.

Best Answer

Hope there's nothing against 'necro'-ing, I'm quite new.

From what I understand of your question you just want the vector describing the distance from an imaginary point in your rectangle ABCD, from a corner A, with all the elements describing only the magnitude of the distance right?

In that case, find out the angle the two rectangles have between them in the x,y plane and the x,z plane, and do a compound rotation through those angles to the vector A you get from the rectangle lying in the x,y plane, then take the magnitudes of that new vector that you get.

The process is like this:

|R[about y]R[about x]A| = A', the vector you want.