Thread: 3D to 2D

  1. #1
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683

    3D to 2D

    I am presently working on a small pet project.. Rendering a 3D pyramid on the screen and the user can rotate zoom etc..


    The pyramid has 4 points.. Now how do i convert the 3D point x,y and X axis to plain 2D x and y Axis on the screen.. I know the basic and even approximated.. but the transition does not seem natural.......... While turning the pyramid the 3rd point some times stretches etc etc...


    so is there some kind of formulae by which i can calculate the X and Y axis(to give the user a 3d effect on 2d screen) of a point by takin X , Y and Z..


    Learning this will help me code a game which involved 3d space... At lease experiment with it...


    Thanx in Advance

  2. #2
    supermutt
    Guest
    Given that the origin is at the center of the screen (usually isnt, but extemely easy to compromise) divide both the X and Y by the Z.

    NewX=X/Z;
    NewY=Y/Z;

    The rotation is just trig

  3. #3
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    The rotation is done by multiplying matrixes together... if you go to the tutorials section on this site and read the stuff by Denthor of Asphyxia, you'll learn how to do it. The stuff is really outdated when it comes to displaying on the screen and using lookup tables, but the math for rotating and lighting is still the same.
    Away.

  4. #4
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    ok thank you...

    well i think i will build a small library after learning this to plot Z axis (represented in X and Y)...



    thanx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I would like to Produce 2d and 3d plots
    By BobInNJ in forum Windows Programming
    Replies: 2
    Last Post: 03-04-2009, 10:16 PM
  2. Wiki FAQ
    By dwks in forum A Brief History of Cprogramming.com
    Replies: 192
    Last Post: 04-29-2008, 01:17 PM
  3. 3D to 2D coords....
    By ellis in forum Game Programming
    Replies: 10
    Last Post: 10-18-2006, 11:18 AM
  4. 2d to 3d: Image processing
    By arjunajay in forum C++ Programming
    Replies: 2
    Last Post: 07-19-2006, 09:39 PM
  5. Initialising 2D and 3D arrays
    By fry in forum C++ Programming
    Replies: 5
    Last Post: 08-01-2002, 04:34 AM