3-D Points to a 2-D computer screenDate: 07/25/97 at 17:00:28 From: Lee Savage Subject: 3-D Points to a 2-D computer screen Hello Dr. Math, I am trying to write a 3-D graphics engine which (at least right now) takes 8 points with their own (X,Y,Z) coordinates to plot a CUBE in 3-D space. The problem I am running in to is that no one, no books, no sites (actually your site came close in some of the linear algebra questions you've already answered) I have searched have had the answer to this question: for a point in 3-D space, how do I offset X and Y with the Z value, so that the proper depth for each point appears in 3-D on a 2-D space (computer screen). I have everything programmed except for the function that takes the X,Y,Z values and uses them to calculate X and Y so it can plot the point on the screen. Example : Point 1 X = -10 Point 2 X = -10 Y = 10 Y = 10 Z = 10 Z = 20 Obviously, even though Point1 and Point2 have the same X,Y values their Z values are different. To get the 3-D display, I know I must use the Z in some formula to offset X and Y (I'm guessing towards the origin X and Y) resulting in a final 3-D point. Please help! Thanks very much, -Lee Savage Date: 08/04/97 at 13:26:33 From: Doctor Bernard Subject: Re: 3-D Points to a 2-D computer screen I too struggled with this problem about 20 years ago. Conceptually a 3-d image shown on a computer screen must be looked at as the intersection of a ray from your eye to each point and a plane. The ratio of the distance from your eye to the plane and the plane to the object determines the size of the image. The angle of the plane relative to the ray from you eye to the center of the object determines perspective type distortions. So how do we do this. First you need to choose some coordinate system in x,y,z to describe your 3-d object. I recommend using the center of the object a (0,0,0). This makes the calculations easier. Next you need a 2-d coordinate system for the plane. Choose a point in 3 space for your eye. The ray from your eye to the center of the object should intersect your plane at (0,0). Now you need to choose you scale factor by find the 3-d equation of the plane. This will take a bit of imagination. Look at the plane, which is really your computer screen or paper, as a pane of glass. For the purposes of this problem, assume your eye is just a single point, infinitely small. If the plane is right up against your eye, the image on the plane will also be infinately small. If the plane is right up against your object, then the image will be approximately the size of the object. You can also put the plane behind the object, in which case, the further away you move it, the larger the image. I hope this explains the concept of scaling the image sufficiently. Once you have the equation of the plane, you need only find the intersection of each ray from your eye to a point on the plane and plot that point using 2-d coordinates. I know the explanation is kind of simplistic, but if you work out the equations on your own, you will understand this much better. If you are programming this problem, use variables whenever possible. This will enable you to quickly scale or distort the image by changing the variables. Another issue, of which I did not speak, is the more complicated issue of hidden line removal. That becomes very complex, involving finite and solid modeling. If you want to address that issue, we can do so in a subsequent communication. Hope this helps. -Doctor Bernard, The Math Forum Check out our web site! http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. Math^{TM}
© 1994-2015 The Math Forum
http://mathforum.org/dr.math/