## Transforming 2D point in a local space to 3D Space

### Transforming 2D point in a local space to 3D Space

Hi

I'm a newbie to all this, so I hoping someone can point in the right
direction. I have a rectangular region (R) that lies in a 3D
coordinate system.

I have the location of the upper left hand corner of R, point
P(a,b,c).
I also have six directional cosines. One set of three (dcx1,dcy1,dcy1)
pertain to one vector V1, that originates from P.  The other set of
three (dcx2, dcy2, dcz2) pertain to the vector V2, that orignates from
P and is perpendicular to V1.  V1 and V2 from the boundaries of one
corner of the region R.

V1
P-----------------|
|         X       |
V2 |                 |
|-----------------|

Given a 2D point X (x1,x2) in the local space of the region R, I want
to determine its location in the 3D global space.

I came up with the following

M =   |dcx1, dcx2,0,a  |
|dcy1, dcy2,0,b  |
|dcz1, dcz2,0,c  |

3DPoint = M * [x1,x2,0,1]

Is this correct?

Also how what would I have to do to go the other way?  That is, given
a 3D point that I know is on R, I have to determine a 2D point in the
space of the region.

Thanks!

### Transforming 2D point in a local space to 3D Space

> I also have six directional cosines. One set of three (dcx1,dcy1,dcy1)
> pertain to one vector V1, that originates from P.  The other set of
> three (dcx2, dcy2, dcz2) pertain to the vector V2, that orignates from
> P and is perpendicular to V1.

Somewhat more conventially, these triplets of directional cosines
would be called (normalized) edge direction vectors.  Because they're
unit-lenght, your region will always be a 1x1 square -- this may not
be what you want.  Use non-unit length vectors for V1 and V2, then.

Quote:> Given a 2D point X (x1,x2) in the local space of the region R, I want
> to determine its location in the 3D global space.
> I came up with the following
> M =   |dcx1, dcx2,0,a  |
>       |dcy1, dcy2,0,b  |
>       |dcz1, dcz2,0,c  |

> 3DPoint = M * [x1,x2,0,1]
> Is this correct?

For some definition of '*' and '[]': sure.  Except that there's not
terribly much point carrying around that empty third column if you're not
going to use homogeneous coordinates throughout.  A better matrix would be

M =   | dcx1, dcx2, a |
| dcy1, dcy2, b |
| dcz1, dcz2, c |
|  0     0  , 1 |

to be used with a vector [x1,x2, 1]

Quote:> Also how what would I have to do to go the other way?  That is, given
> a 3D point that I know is on R, I have to determine a 2D point in the
> space of the region.

Dot products of (point-P) with V1 and V2 give you back x1 and x2.  This
can be written as a matrix, too.  You'll find out which on your own.
--

Even if all the snow were burnt, ashes would remain.

### Transforming 2D point in a local space to 3D Space

Quote:> Hi

> I'm a newbie to all this, so I hoping someone can point in the right
> direction. I have a rectangular region (R) that lies in a 3D
> coordinate system.

> I have the location of the upper left hand corner of R, point
> P(a,b,c).
> I also have six directional cosines. One set of three (dcx1,dcy1,dcy1)
> pertain to one vector V1, that originates from P.  The other set of
> three (dcx2, dcy2, dcz2) pertain to the vector V2, that orignates from
> P and is perpendicular to V1.  V1 and V2 from the boundaries of one
> corner of the region R.

>          V1
>    P-----------------|
>    |         X       |
> V2 |                 |
>    |-----------------|

> Given a 2D point X (x1,x2) in the local space of the region R, I want
> to determine its location in the 3D global space.

> I came up with the following

> M =   |dcx1, dcx2,0,a  |
>       |dcy1, dcy2,0,b  |
>       |dcz1, dcz2,0,c  |

> 3DPoint = M * [x1,x2,0,1]

> Is this correct?

Yes assuming that x1,x2 are meant as local coordinates w.r.t V1,V2 and
the origin P.

You are using a somewhat confusing notation. The coordinates of a
vector are "numbered" by x,y,z and the coordinates of a point are
numbered by 1 and 2.

Quote:> Also how what would I have to do to go the other way?  That is, given
> a 3D point that I know is on R, I have to determine a 2D point in the
> space of the region.

|dcx1 dcy1 dcz1|      |xQ-a|
|              |  *   |yQ-b|
|dcx1 dcy1 dcz1|      |zQ-c|

This gives a result even if the point Q to be transformed is not in
the plane defined by P,V1,V2. The result are the local coordinates of
the orthogonal projection of Q onto the plane defined by P,V1,V2. This
projection is identical to Q if Q is in the plane.

Regards
Horst

Hi

This might be a simple question for some of you. I haven't done this
for years so I don't remember how you do it.

I am given a 2D point on a plane (say dx and dy). I am given also the
directional cosines for that plane, the position of the lower right
corner of that plane, plus the column and row lenght of the plane.

My problem is now trying to map the 2D point, into a 3D point in the
coordinate system where the plane resides.

Can anyone give me some points on how I should do this?