[comp.graphics] 3-d -----> 2-d

wozniak@utkux1.utk.edu (Bryon Lape) (09/30/89)

	Does anyone know of an algorithm for translating 3-d to 2-d so
that I can plot on my IBM-PC?  I wish to display all axises at a
rotation
suitable to view everything.

-bryon-

bill@hpcvlx.cv.hp.com (Bill Frolik) (10/03/89)

| 	Does anyone know of an algorithm for translating 3-d to 2-d so
| that I can plot on my IBM-PC?  I wish to display all axises at a

The easiest way to map [x,y,z] into [x',y'] without perspective:

			x' = x
			y' = y

The easiest way to map [x,y,z] into [x',y'] with perspective:

			x' = (x*d)/(z+d)
			y' = (y*d)/(z+d)

		where d, a constant, the distance from the
		viewer's eye to the screen, determines the
		amount of perspective.

For derivation of these equations you examine a couple of triangles.
The screen glass is at z=0, with increasing z going deeper into the
screen; the center of the screen is at x=y=0; the viewer is distance d
from the screen.  In the diagram, the ratio of the lengths of side VA
to VB will be the same as side Ap1 to Bp2.

	len(VA)   len(Ap1)           d     x'
	------- = --------    ==    --- = ---   (and similar for y')
	len(VB)   len(Bp2)          d+z    x

			     	B---------*p2
			     	|        /(x,y,z)
				|       /
		    ------------A------*p1---  <--screen (z=0)
			     |	|     /(x',y')
			     |	|    /
			     d	|   /
			     |	|  /
			     |	| /
			     |	|/
			        V  <-- viewer

A good value for d might be to set it equal to the width of the screen.
(If your screen is 1024 units wide, i.e. screen X runs from something
like -512..+511, set d=1024.)  
________________________________________

Bill Frolik	Hewlett-Packard Co.
hp-pcd!bill	Corvallis, Oregon

kennedy@sunshine4.DAB.GE.COM (Woody Kennedy) (10/10/89)

In article <1133@utkcs2.cs.utk.edu> wozniak@utkux1.utk.edu (Bryon Lape) writes:
>
>	Does anyone know of an algorithm for translating 3-d to 2-d so
>that I can plot on my IBM-PC?  I wish to display all axises at a
>rotation
>suitable to view everything.
>
>-bryon-

According to the authoritative volume "Principles of Hyperactive
Computer Graphics", available from Acme publishing:

   The proper attainment of 3-d to 2-d transformation can be
   achieved by the party in question (Eatamus Roadrunnerus)
   obtaining one Anvilus Blackamus.  A priori to the arrival
   of the object to be transformed (Runnimus Fastimus), the AB
   is elevated to a signicant altitude by means of a mechanical
   hoist or local mountinous prominitory.  When the RF reaches
   the loci of descendance of the AB, the AB shall be released
   by the ER.  Barring any unforseen collapse of the hoist or
   prominitory (which is almost guaranteed due to the nature
   of the problem) the RF shall be reduced from 3-d to 2-d,
   though it may sprout legs and walk away.

 


--
Woody Kennedy, Software Engineer, Special Effects   |  Pay no attention to the
General Electric Simulation & Control Systems Dept. |  man behind the keyboard!
kennedy@sunny.ge.com  or          +-----------------+--------------------------
(backbone)!ge-dab.ge.com!kennedy  |  Wanna' see something neat?  Watch this...

wozniak@utkux1.utk.edu (Bryon Lape) (10/17/89)

	Although my original post was very serious, I loved the reply!!
Good ol' Buggs Bunny, Road Runner stuf!!!!!!!!



-bryon-

mcooper@s.cs.uiuc.edu (10/20/89)

/* ---------- "Re: 3-d -----> 2-d" ---------- */
In article <1133@utkcs2.cs.utk.edu> wozniak@utkux1.utk.edu (Bryon Lape) writes:
>
>	Does anyone know of an algorithm for translating 3-d to 2-d so
>that I can plot on my IBM-PC?  I wish to display all axises at a
>rotation
>suitable to view everything.
>
>-bryon-

I hope I'm not being simplistic here, but it seems the easiest way to convert 
any 3D object into 2D is (assuming the object is made of polygons) sort the
polygons by depth (z value) using a simple depth sort (or the painters' 
algorithm.  Effective, but S-L-O-W) and then plot each polygon according
to its x,y coords.  

Or are you asking something else?

					-Marc Cooper
"When the going gets weird,		 mcooper@cs.uiuc.edu
 the weird turn pro."
		-Hunter S. Thompson	 University of Illinios, C-U

wozniak@utkux1.utk.edu (Bryon Lape) (10/21/89)

	Since I posted the request for 3d--->2d conversion, I have
received many different answers.  Some good, so stupid, and so bad.
What I want to do is the follows:


	Type in a function in 3 variables and plot them just like they
are in my Calculus 3 book.


-bryon-