Newsgroups: comp.graphics
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!viusys!uxui!unislc!ttobler
From: ttobler@unislc.uucp (Trent Tobler)
Subject: Re: How do I draw a perspective view?
References: <9106010027.AA01356@bruny.cc.utas.edu.au>
Message-ID: <1991Jun4.192251.14879@unislc.uucp>
Organization: unisys
Date: Tue, 4 Jun 91 19:22:51 GMT

From article <9106010027.AA01356@bruny.cc.utas.edu.au>, by u906400@BRUNY.CC.UTAS.EDU.AU (Roger Scott):
> Could somebody please explain to me how to take a point (x,y,z) in space and
> map it onto a screen as a single point perspective view in (x,y)?  I've had
> a look through the books, but I can't follow what's happening.  It is for an
> assignment and so far I can get it to draw a cube properly, but when I throw
> anything more difficult at the program  the lines seem to go everywhere. I
> am currently using
> 	xp = (x/((z/d)+1)) & yp = (y/((z/d)+1)) where d is the distance between
> 						the point and the origin.

Well, I assume you only want to look one direction (adequete if you can do
rotation.)

If that is the case, then the point will be (x/z,y/z), or xp = x/z and yp = y/z.
If z is negative, then the point is behind you, and you should therefore
consider it a virtual point (point at infinite).  These points are the most
difficult to draw lines with.  Example:
________________________
|                      |
|      p-------p       | no points are behind you.
|                      |
|      v       p-------| one point is behind you.
|                      |
|------p       v       | one point is behind you.
|                      |
|      v       v       | both points are behind you. (no line)
|                      |
|                      |
|______________________|

As you can see, virtual points cause the line to head AWAY from it, starting
from the second point (which must be a real point, otherwise the line is
behind you as well).

Other than that, there is not much more to perspective.


--
  Trent Tobler - ttobler@csulx.weber.edu
