To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 1400
1399  |  1401
Subject: 
Re: A Sphere
Newsgroups: 
lugnet.cad
Date: 
Tue, 23 Mar 1999 16:55:35 GMT
Viewed: 
1005 times
  
Rich Thompson (richone@midsouth.rr.com) wrote:

Has anyone modeled a sphere in Ldraw? I am having trouble getting an
interesting sphere effect in a tight (16-20 stud) space and could use some
ideas...

Here's some code that should help you creating a spherical LEGO model:

   ---------------------------------------------------------------------------
   --  The orientation matrix or the order the coordinates are _printed_ in
   --  needs to be fixed.

   Radius : constant Positive := 45; --  LU ( = 1/2 plates )

   Half_Width  : constant Positive := Radius / 5 + 1; --  Studs
   Half_Depth  : constant Positive := Radius / 5 + 1; --  Studs
   Half_Height : constant Positive := Radius / 2 + 1; --  Plates

   Sphere  : array (-Width .. +Width, -Depth .. +Depth, -Height .. +Height)
               of Boolean;
   X, Y, Z : Integer;

   begin
      for Z_Index in Bricks'Range (3) loop
         Z := 8 * Z_Index; --  LDraw units

         for X_Index in Bricks'Range (1) loop
            X := 20 * X_Index; --  LDraw units

            for Y_Index in Bricks'Range (2) loop
               Y := 20 * Y_Index; --  LDraw units

               if X**2 + Y**2 + Z**2 <= Radius**2 then
                  Put ("1 16 ");
                  Put (X);
                  Put (" ");
                  Put (Y);
                  Put (" ");
                  Put (Z);
                  Put_Line (" 1 0 0  0 1 0  0 0 1  1x1plate.dat");
               end if;
            end loop;
         end loop;

         Put_Line ("0 STEP");
      end loop;
   end;

   ---------------------------------------------------------------------------

Play well,

Jacob

PS: You can still get a free Ada compiler at
    <URL:http://www.gnat.com/mirrors.html>.

        --------------------------------------------
        --  E-mail:         sparre@nbi.dk         --
        --  Web...: <URL:http://hugin.risoe.dk/>  --
        --------------------------------------------

LDraw FAQ:      <URL:http://hugin.risoe.dk/JJ_Memorial/FAQ/>



Message is in Reply To:
  A Sphere
 
Has anyone modeled a sphere in Ldraw? I am having trouble getting an interesting sphere effect in a tight (16-20 stud) space and could use some ideas... Rich (URL) (26 years ago, 20-Mar-99, to lugnet.cad)

6 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR