mersenneforum.org convert 3d into 2d
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

 2007-08-03, 17:22 #1 nuggetprime     Mar 2007 Austria 4568 Posts convert 3d into 2d I have a question about 3d point rendering. You have a 3d point P1 with cartesian coordinates x1,y1,z1.You also have the azimuth a and the elevation b(angles). Now I like to know the x and y coordinates of if seen in 2d. I know it's not very clear but I can't tell it clearer so please post if you don't understand. Last fiddled with by nuggetprime on 2007-08-03 at 17:22
 2007-08-03, 17:59 #2 ewmayer ∂2ω=0     Sep 2002 República de California 5·17·137 Posts Uh, the x and y-coordinates are the same in 2D as they are in 3D - just the z-coordinate gets lost.
 2007-08-04, 03:53 #3 philmoore     "Phil" Sep 2002 Tracktown, U.S.A. 3×373 Posts It sounds like you are asking for the x and y coordinates in a projection, given a specific azimuth a and elevation b. Sounds like an elementary problem, if you don't get an answer within the next day or two, I will work it out. Should be a good exercise for the next time I teach trigonometry.
 2007-08-05, 02:32 #4 dsouza123     Sep 2002 2×331 Posts Some code changed from basic to pascal mixed with assembly then rearranged to show the order of execution. Code:  rho := 10; theta := 0.7; { 0.7 0.9 1.1 rotate clockwise about z axis} phi := 1.3; d := 500; { 500 700 900 increase size on screen} th := theta; { angles in radians } ph := phi; s1 := sin(th); c1 := cos(th); s2 := sin(ph); c2 := cos(ph); cx := 256; { x center offset 0..512 x left to right } cy := 256; { y center offset 0..512 y bottom to top after flip } { first 5 points of 11 using values of 0 or 1 } data[0,0] := 1; data[1,0] := 1; data[2,0] := 0; { point 0 } data[0,1] := 1; data[1,1] := 1; data[2,1] := 1; { point 1 } data[0,2] := 0; data[1,2] := 1; data[2,2] := 1; { point 2 } data[0,3] := 0; data[1,3] := 1; data[2,3] := 1; { point 3 } data[0,4] := 1; data[1,4] := 1; data[2,4] := 0; { point 4 } for n := 0 to 4 do begin x := data[0,n]; { do for each point } y := data[1,n]; z := data[2,n]; { begin Transform } xe := -x * s1 + y * c1; ye := -x * c1 * c2 - y * s1 * c2 + z * s2; ze := -x * s2 * c1 - y * s2 * s1 - z * c2 + rho; sx := d * xe / ze + cx; sy := cy - d * ye / ze; { screen coordinates are 0..512 x, left to right } { 0..512 y, top to bottom } { the screen y is flipped to 0 on bottom, 512 on top } { 0,0 translated to screen center 256, 256 } { end Transform } x := sx; y := sy; { then use the result for either MoveToEx or LineTo } writeln(' invoke MoveToEx,hDC,',x:3,',',y:3,',NULL'); writeln(' invoke LineTo, hDC,',x:3,',',y:3); end; { full 11 points produce visible faces of a cube } { invoke MoveToEx,hDC,262,277,NULL invoke LineTo, hDC,263,220 invoke LineTo, hDC,297,212 invoke LineTo, hDC,296,265 invoke LineTo, hDC,262,277 invoke LineTo, hDC,221,267 invoke LineTo, hDC,220,213 invoke LineTo, hDC,256,206 invoke LineTo, hDC,297,212 invoke MoveToEx,hDC,220,213,NULL invoke LineTo, hDC,263,220 } Last fiddled with by dsouza123 on 2007-08-05 at 02:34
 2007-08-16, 17:12 #5 davieddy     "Lucan" Dec 2006 England 2×3×13×83 Posts How do you say this in Spanish
2007-08-16, 17:14   #6
ewmayer
2ω=0

Sep 2002
República de California

5·17·137 Posts

Quote:
 Originally Posted by davieddy ¿Cómo se dice esto en español?
I think you already did.

 2007-09-22, 08:35 #7 dingofunk   3×5×557 Posts I could nt understand the middle part of the code.

 Similar Threads Thread Thread Starter Forum Replies Last Post Rincewind PrimeNet 9 2014-11-01 11:47 Stargate38 Software 12 2012-02-07 21:19 ixfd64 mersennewiki 5 2006-04-06 00:00 tinhnho Miscellaneous Math 8 2005-09-18 15:14 OmbooHankvald Linux 8 2005-08-13 23:50

All times are UTC. The time now is 11:31.

Sun Jul 25 11:31:42 UTC 2021 up 2 days, 6 hrs, 0 users, load averages: 1.92, 2.24, 2.35