mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2007-08-03, 17:22   #1
nuggetprime
 
nuggetprime's Avatar
 
Mar 2007
Austria

2·151 Posts
Question 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
nuggetprime is offline   Reply With Quote
Old 2007-08-03, 17:59   #2
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

2·5,693 Posts
Default

Uh, the x and y-coordinates are the same in 2D as they are in 3D - just the z-coordinate gets lost.
ewmayer is offline   Reply With Quote
Old 2007-08-04, 03:53   #3
philmoore
 
philmoore's Avatar
 
"Phil"
Sep 2002
Tracktown, U.S.A.

1,117 Posts
Default

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.
philmoore is offline   Reply With Quote
Old 2007-08-05, 02:32   #4
dsouza123
 
dsouza123's Avatar
 
Sep 2002

2·331 Posts
Default

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
dsouza123 is offline   Reply With Quote
Old 2007-08-16, 17:12   #5
davieddy
 
davieddy's Avatar
 
"Lucan"
Dec 2006
England

647410 Posts
Default

How do you say this in Spanish
davieddy is offline   Reply With Quote
Old 2007-08-16, 17:14   #6
ewmayer
2ω=0
 
ewmayer's Avatar
 
Sep 2002
República de California

2·5,693 Posts
Default

Quote:
Originally Posted by davieddy View Post
¿Cómo se dice esto en español?
I think you already did.
ewmayer is offline   Reply With Quote
Old 2007-09-22, 08:35   #7
dingofunk
 

23×197 Posts
Default

I could nt understand the middle part of the code.
  Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert files from srsieve/srfile into worktodo.txt Rincewind PrimeNet 9 2014-11-01 11:47
How to convert 5495-bit binary number to decimal? Stargate38 Software 12 2012-02-07 21:19
convert to standard ASCII text when possible? ixfd64 mersennewiki 5 2006-04-06 00:00
Convert Binary to BCD code tinhnho Miscellaneous Math 8 2005-09-18 15:14
Linux! Convert me! OmbooHankvald Linux 8 2005-08-13 23:50

All times are UTC. The time now is 02:09.

Wed Aug 5 02:09:45 UTC 2020 up 18 days, 21:56, 1 user, load averages: 1.40, 1.70, 1.66

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.