3d to 2d Projection

Howdy,

I'm looking for a "hands-on" (not necessarily in programming) way to project the coordinates of a 3d point onto a 2d "screen". I've tried google to avail, all the results are alien to me and I need to know how to do this specific method.

Say I have:

- A 3d point we'll call [Point]

- A 3d plane to use as the "screen" and we'll call it [Screen]. (x and y remain zero. Z is the only changing variable here)

- And another 3d point that is our viewpoint (our eyes) we'll call [View]

Using those three elements, how can I find the 2d projection coordinates of the 3d point [Point] onto the plane [Screen]?

(I remember we have to use some kind of fractional distance formula using Z or something?)

Cast a ray from [View] to [Point]. The intersection point of ray and [Screen] gives you the 2D projection.

At least, that's how I remember it from building various ray-caster engines.

I meant with pen and paper. Not programming...and without casting rays.

Hold up a pencil so the [Point] is where you want it. Hold up a pencil vertically in front of your face. It may be easier to do this with a transparency. Look through the paper/transparency and, with a second marking instrument, mark where the dot would appear on your held-up paper. The point may change depending on how high your eye is relative to the paper, so make sure your head is always in the same place.

Repeat for all 2,000 other points you want to test.

Explain what you're wanting? Some mathematical equation to do this?

x/z and y/z should be all you need. 'z' is the depth of the object into the view. When 'z' is 1.0 everywhere, you're drawing directly onto the plane. When 'z' is large, it modifies both your 'x' and 'y' coordinates.

And make sure (0, 0) is at the center of your view plane, so a negative 'x' will move to the left and a positive 'x' will move to the right.

Ok, first things first.

Orthogonal projection on the x-y plane.

This is rather easy - you already know x and y, just ignore z. So you get (x, y).

Perspective projection on the x-y plane.

I've tried to derive this rigorously, and I've also never looked into this seriously. So I'll just repeat what I remember seeing everyone else do: you divide the x and y coordinates (that you already have) by the z coordinate. So you get (x/z, y/z).

Projection onto an arbitrary plane through the origin.

Now suppose you have a plane tilted at some arbitrary angle to the coordinate axes. This is where you'll want to look into some linear algebra, but again, this is not very difficult once you know how to do rotations in a vector space.

The essence is this: you need to find the angles (there are two of them) that you need to rotate the plane by so that it is aligned with the coordinate axis. Conceptually, you can find one of these by aligning the plane's normal to the z axis (use the dot product) and the other one by subsequently aligning the plane's "horizontal" direction with the x-axis (again use the dot product; make sure you tilt the plane so it is parallel to the x-y plane first). You now have your plane aligned with the x-y plane, and you can do the projection as described above (what you'd normally do is use this knowledge to transform the different points you want to project so that they are in the plane's coordinate system rather than the other way around, but mathematically it comes down to the same thing).

Projection on an arbitrary plane.

Translate the plane so it's origin is at the origin of your coordinate system (or alternatively, shift everything else in the opposite direction).

So, to sum up:

1. Shift the plane on which you want to project everything so that it passes through the origin of your coordinate system (or shift your coordinate system in the opposite way; it's the same thing but you may want to treat the plane as "the" coordinate system that your geometry should adjust to).

2. Rotate the plane so that it aligns with the coordinate axes (or rotate the other coordinate system so that it aligns with the plane).

3. Project points onto the plane by chopping off their z coordinate.

4. Optionally scale the x y coordinates based on the z coordinate to do perspective projection.

Hope that helps!

EDIT: rereading your post, it looks like you want something a little more complicated, but it's essentially the same as above (only applied twice).

First project the "point" onto the "screen" as described above. Then transform that "projected point" to the "view" frame.

I got a C in Linear Algebra, but I KNOW there is a method for projecting points in 3d space onto a 2d plane using linear algebra. Sorry, that's not much help. But hopefully that will help with your google search.

By projecting a vector v to a plane what you want are its coordinates in the base that describes the plane, so if your plane is defined by two vectors e1 and e2 (lets assume they are normalised), you want to know how "long" the vector is on the e1 axis and how long it is on the e2 axis, which is v*e1 and v*e2. If you want the vector v to describe a point relative to your plane, you must subtract the centre point of the plane from v.

That is how you project a point on a 3d plane (since a 3d plane is described by two vectors.)

(v*e1 = v1*e11 + v2*e12 + v3*e13 in the 3d case)

This definition is the mathematical definition (in "light" terms)

In case of drawing to paper try http://en.wikipedia.org/wiki/Perspective_(graphical)#Types_of_perspective

decepto said:

I got a C in Linear Algebra, but I KNOW there is a method for projecting points in 3d space onto a 2d plane using linear algebra.

What'd you think all of the mathematics in my post were?

Projecting the point onto a plane through the origin is easy, all you have to do is subtract the component perpendicular to the plane from the coordinates of the point, that is, is **p** is your point and **n** is the plane's normal vector, then **p** - **nn**.**p** is the projection of the point on the plane.

Then all you need to do is find the coordinates of that point relative to the plane's horizontal and vertical directions, which is a rotation in the plane.

Ok, maybe that explanation is a little bit easier than the one I gave before.