1
$\begingroup$

I'm not sure this is the right place to ask this question, if not I do apologies and I will move on. I am asking this question as a programmer, however it seemed entirely maths based.

Image one is sitting still and holds in front of their face a sheet of graph paper with grid lines. This piece of paper represents a 2D plane, however although it exists inside of another 3D environment, it can be move about such that it's axis may not line up in any meaningful way.

Given 3 points where both the real world X,Y,Z values are known and the relative X,Y coordinates of their position within the paper drawn grid and given that two of these points share the same virtual 2D Y value but differ on X and the third point shares neither the same X nor Y value but does indeed exist on the same virtual 2D plane.

How can I then transform any given coordinate of one set to the other. Say I want to know where square (12,20) on the graph paper exists in the real world and vice versa.

Also, say I have a set of real world coordinates that is not on my 2D plane but directly above it. Is there a way and if so, how would i: traverse "downwards" through 3D space perpendicular to the find the 2D point directly below.

$\endgroup$
5
  • $\begingroup$ How is your plane defined? You can't know what you want without some sort of description of this plane. $\endgroup$ Commented Aug 4, 2015 at 7:44
  • $\begingroup$ Let's say I have an arena or perhaps an enclosed box. The box is 1,000cm on all sides. There is also a 100x100cm piece of paper with 1cm grid lines drawn on it. Therefor this sheet of paper represents a 2D plane that we define by the 1cm grid. This sheet of paper may be arbitraliy oriented within the box. I know of only 3 points on the box according to the criteria in the question. For example lets say the grid square (50,50)(45,60),(55,60) have known coordinates within the 3D box/arena. Is there a generlised way I can then derive the 3D coords of any given 2D coord on the sheet? $\endgroup$ Commented Aug 4, 2015 at 8:00
  • $\begingroup$ Not unless you can tell us how the plane is given. How do you define its orientation and position in 3D space, for example? $\endgroup$ Commented Aug 4, 2015 at 9:23
  • $\begingroup$ For example, if the position of your sheet of "paper" is given as two opposite points of a rectangle, you can use those to compute the parametric equations of a plane, which give you what you want; or you can compute its Cartesian equation, which immediately gives you what you want because it is of the form $a X + b Y + c Z = d$. Still, this plane must be defined somehow, because otherwise you couldn't draw it... $\endgroup$ Commented Aug 4, 2015 at 10:09
  • $\begingroup$ Edit: Thank you for your responses and time :) If I know the global X,Y,Z coordinates of 5 points on the 2D plan where the points form two lines parallel the x,y axis of the 2D plane. For example 2D grid coordinates (10,10)(-10,0),(0,0)(10,0)(0,-10) (imagine they form a plus sign shape on the center of the grid) have known 3D coordinates can I then use that to define the plane and derive 3D coordinates from arbitrarily given 2D coordinates. $\endgroup$ Commented Aug 5, 2015 at 4:20

2 Answers 2

1
$\begingroup$

To get this done we need three points on the paper that we know the location of in 3d space. Ideally, these are the locations of $(0,0)$, $(1,0)$, and $(0,1)$ but I'm going to assume we don't have those.

What we need is the starting point and the vectors that move you $1$ unit along the paper in each direction. This is an affine transformation, which is like a linear transformation but doesn't insist that the origin sits still. In this sort of work we use homogeneous coordinates, which means that locations will have a spare coordinate glommed on for the translation, set automatically to $1$. We'll call our start points $a$, $b$, and $c$ and the three dimensional spots $a'$ etc. Let's put our goodies in a big ol' augmented matrix:

$$\left[\begin{array}{ccc|cccc} a_x & a_y & 1 & a'_x & a'_y & a'_z & 1 \\ b_x & b_y & 1 & b'_x & b'_y & b'_z & 1 \\ c_x & c_y & 1 & c'_x & c'_y & c'_z & 1 \\ \end{array}\right]$$

We'll then reduce this to RREF using Gaussian elimination, but before we get there we should notice something interesting: we have some matching columns. They'll turn out the same in the end, and what we're left with is a point (signified by the $1$ in the final component) and two magnitudes (with $0$s), corresponding to the origin of the paper in 3d space and the directions of 1 unit along and across the paper. Now, we'll take the right half of that augmented matrix, and transpose it, and we have our first result matrix, which I'll call $A$, which we can multiply by a point on the paper (homogenized) and get a point in 3d space.

Now time for the other way around: given a point in 3d space, where is it on the paper? Well, that's easy, we'll just inve-- oh. We can't invert this matrix, it's not square! Okay that's a problem, what do we do about it?

Well, we can take the cross product of our two magnitude vectors in 3d space; this gives a vector perpendicular to both - it's going to be either positive from the front of the paper or the back, depending on the handedness of your coordinate systems. We can then scale this however we'd like - something that's the magnitude of the original two vectors would be ideal. Then we can just stuff it in as the third column, and invert that. Then if you want to project the world onto the paper, just zero out the third row, which tells you how far you are from the paper.

$\endgroup$
1
  • $\begingroup$ I'm not super happy with this but it should do in a pinch. Needs examples and stuff. This is one of those core mathematical devices for 3d graphics and it deserves better treatment than an hour or three of sleep-deprived me. $\endgroup$ Commented Jul 21, 2021 at 18:12
0
$\begingroup$

For simplicity, suppose you know the coordinates in 3D space $(x_1,y_1,z_1)$ and $(x_2,y_2,z_2)$ of (the image of) $(1,0)$ and $(0,1)$, respectively. Then every point $(a,b)$ in 2D space can be written as $$ (a,b) = a(1,0) + b(0,1) $$ and the corresponding point in 3D space has coordinates $$ a(x_1,y_1,z_1) + b(x_2,y_2,z_2) = (ax_1 + bx_2, ay_1 + b y_2, az_2 + bz_2) $$ If instead you know the 3D coordinates of, say, $(10,0)$ and $(0,10)$, then you can use the same trick after writing $$ (a,b) = \frac{a}{10}(10,0) + \frac{b}{10}(0,10) $$

$\endgroup$
1
  • $\begingroup$ I think this answer assumes that the origin of the 2D coordinate system coincides with the origin of the 3D coordinate system, whereas the question seems to be about a more general situation. $\endgroup$ Commented Sep 13, 2022 at 2:25

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.