<- previous    index    next ->

Lecture 9b, more complex objects

This lecture shows how to create a .dat  file for a solid cube
with three square holes and digitize to get a .dat file

A crude 3D view is:


A wire frame view is:

2B 
box_end.txt explanation of vertex numbering
box_end.txt describes a cube pierced with three square holes.
            the cube has outer vertices x, y, z at 0.0 and 1.0
            the holes have inner vertices x, y, z at 0.333 and 0.666 
box_end.dat   data file defining vertices and surfaces
              all sections of surface are 4 point polygons
              there are 40 vertices and 48 polygons
box_endw.png  graphic of wire frame showing all edges
box_ends.png  graphic of cube with square holes
volume_dat_box_end.out  computation of volume and area
                        volume of material = 0.889558 
                        total surface area = 8.0


vertex numbering looking at 3D view
outer vertices            vertex 11 at x=1.0, y=1.0, z=1.0
                  12              11
                   *---------------*
                  /|              /|
             Y   / |             / |
             ^  /  |            /  |
             | /   |   Z       /   |
             |/    |  /       /    |  
            4*-- ------------*3    | 
             |     |/        |     |
             |    9*---------|-----*10
             |    /          |    /
             |   /           |   /
             |  /            |  /
             | /             | /
             |/              |/
             *---------------*   --> X
             1               2
vertex 1 at x=0.0, y=0.0, z=0.0
no material outside these boundaries


looking from outside the cube
front face vertices z=0     back face vertices z=1
  4               3         11              12
  *-- ------------*          *-- ------------*       
  |    8     7    |          |   15    16    |        
  |    *-----*    |          |    *-----*    |        
  |    |     |    |          |    |     |    |        
  |    |     |    |          |    |     |    |        
  |    *-----*    |          |    *-----*    |        
  |    5     6    |          |   14    13    |        
  |               |          |               |        
  *---------------*          *---------------*
  1               2         10               9        

left face vertices x=0      right face vertices x=1
 12               4          3              11
  *-- ------------*          *-- ------------*       
  |   19    18    |          |   22    23    |        
  |    *-----*    |          |    *-----*    |        
  |    |     |    |          |    |     |    |        
  |    |     |    |          |    |     |    |        
  |    *-----*    |          |    *-----*    |        
  |   20    17    |          |   21    24    |        
  |               |          |               |        
  *---------------*          *---------------*
  9               1          2              10        

bottom face vertices y=0    top face vertices y=1
  1               2         12              11
  *-- ------------*          *-- ------------*       
  |   25    26    |          |   32    31    |        
  |    *-----*    |          |    *-----*    |        
  |    |     |    |          |    |     |    |        
  |    |     |    |          |    |     |    |        
  |    *-----*    |          |    *-----*    |        
  |   28    27    |          |   29    30    |        
  |               |          |               |        
  *---------------*   --> X  *---------------*
  9              10          4               3        
      

looking at 3D view
inner vertices       vertex 39 at x=.666, y=.666, z=.666
center         40*-----------*39
                /|          /|
               / |         / |
              /  |        /  |
           36*-----------*35 |
             |   |       |   |
             | 37*-------|---*38
             |  /        |  /
             | /         | /
             |/          |/
           33*-----------*34
            
vertex 33 at x=.333, y=.333, z=.333
no material inside these boundaries
none of these are surfaces


   inner vertices front z=0         inner vertices back z=1
         36*-----------*35              16*-----------*15
          /|          /|                 /|          /|
         / |         / |                / |         / |
        /  |        /  |               /  |        /  |
      8*-----------*7  |            40*-----------*39 |
       |   |       |   |              |   |       |   |
       | 33*-------|---*34            | 13*-------|---*14
       |  /        |  /               |  /        |  /
       | /         | /                | /         | /
       |/          |/                 |/          |/
      5*-----------*6               37*-----------*38
            
vertex 5 at x=.333, y=.333, z=0.0  vertex 13 at x=.333, y=.333, z=1.0
vertex 7 at x=.666, y=.666, z=0.0  vertex 15 at x=.666, y=.666, z=1.0  
no material inside these boundaries
no surface  5, 6, 7, 8 and 33,34,35,36
no surface 37,38,39,40 and 13,14,15,16

   inner vertices left x=0         inner vertices right x=1
         19*-----------*40              39*-----------*23
          /|          /|                 /|          /|
         / |         / |                / |         / |
        /  |        /  |               /  |        /  |
     18*-----------*36 |            35*-----------*22 |
       |   |       |   |              |   |       |   |
       | 20*-------|---*37            | 38*-------|---*24
       |  /        |  /               |  /        |  /
       | /         | /                | /         | /
       |/          |/                 |/          |/
     17*-----------*33              34*-----------*21
            
vertex 17 at x=0.0, y=.333, z=.333  vertex 21 at x=1.0, y=.333, z=.333
vertex 19 at x=0.0, y=.666, z=.666  vertex 23 at x=1.0, y=.666, z=.666  
no material inside these boundaries
no surface 17,18,19,20 and 33,36,40,37
no surface 21,22,23,24 and 34,35,39,38

   inner vertices bottom y=0         inner vertices top y=1
         37*-----------*38              32*-----------*31
          /|          /|                 /|          /|
         / |         / |                / |         / |
        /  |        /  |               /  |        /  |
     33*-----------*34 |            29*-----------*30 |
       |   |       |   |              |   |       |   |
       | 28*-------|---*27            | 40*-------|---*39
       |  /        |  /               |  /        |  /
       | /         | /                | /         | /
       |/          |/                 |/          |/
     25*-----------*26              36*-----------*35
            
vertex 25 at x=.333, y=0.0, z=.333  vertex 29 at x=.333, y=1.0, z=.333
vertex 27 at x=.666, y=0.0, z=.666  vertex 31 at x=.666, y=1.0, z=.666  
no material inside these boundaries
no surface 25,26,27,28 and 33,34,38,37
no surface 29,30,31,32 and 33,34,38,37


      

box_end.dat the file defining the object
40 48
0.0 0.0 0.0    #  1 z=0
1.0 0.0 0.0    #  2
1.0 1.0 0.0    #  3
0.0 1.0 0.0    #  4
.333 .333 0.0  #  5
.666 .333 0.0  #  6
.666 .666 0.0  #  7
.333 .666 0.0  #  8
0.0 0.0 1.0    #  9 z=1
1.0 0.0 1.0    # 10
1.0 1.0 1.0    # 11
0.0 1.0 1.0    # 12
.333 .333 1.0  # 13
.666 .333 1.0  # 14
.666 .666 1.0  # 15
.333 .666 1.0  # 16
0.0 .333 .333  # 17 x=0
0.0 .666 .333  # 18
0.0 .666 .666  # 19
0.0 .333 .666  # 20
1.0 .333 .333  # 21 x=1
1.0 .666 .333  # 22
1.0 .666 .666  # 23
1.0 .333 .666  # 24
.333 0.0 .333  # 25 y=0
.666 0.0 .333  # 26
.666 0.0 .666  # 27
.333 0.0 .666  # 28
.333 1.0 .333  # 29 y=1
.666 1.0 .333  # 30
.666 1.0 .666  # 31
.333 1.0 .666  # 32
.333 .333 .333 # 33 inside empty z=.333
.666 .333 .333 # 34
.666 .666 .333 # 35
.333 .666 .333 # 36
.333 .333 .666 # 37 inside empty z=.666
.666 .333 .666 # 38
.666 .666 .666 # 39
.333 .666 .666 # 40
4  1  5  6  2
4  2  6  7  3
4  3  7  8  4
4  4  8  5  1
4  9 13 14 10
4 10 14 15 11
4 11 15 16 12
4 12 16 13  9
4  1 17 18  4
4  4 18 19 12
4 12 19 20  9
4  9 20 17  1
4  2 21 22  3
4  3 22 23 11
4 11 23 24 10
4 10 24 21  2
4  1 25 26  2
4  2 26 27 10
4 10 27 28  9
4  9 28 25  1
4  4 29 30  3
4  3 30 31 11
4 11 31 32 12
4 12 32 29  4
4  5 33 34  6 # small z in 33 to 40
4  6 34 35  7
4  7 35 36  8
4  8 36 33  5
4 37 13 14 38 # big z in 33 to 40
4 38 14 15 39
4 39 15 16 40
4 40 16 13 37
4 17 33 36 18 # small x in 33 to 40
4 18 36 40 19
4 19 40 37 20
4 20 37 33 17
4 21 34 35 22 # big x in 33 to 40
4 22 35 39 23 
4 23 39 38 24
4 24 38 34 21
4 25 33 34 26 # small y in 33 to 40
4 26 34 38 27
4 27 38 37 28
4 28 37 33 25
4 29 36 35 30 # big y in 33 to 40
4 30 35 39 31
4 31 39 40 32
4 32 40 36 29

volume_dat2_box_end.out computed surface and volume
Output from:  volume_dat2 box_end.dat

volume_dat2.c reading box_end.dat 
status=0, zmax=1, points=40, polys=48 

xmin=0.000000, xmax=1.000000, ymin=0.000000, ymax=1.000000 
zmin=0.000000, zmax=1.000000 
enclosing area= 6, enclosing volume= 1 

final total area = 7.99999, total volume = 0.889558 

digitize to make a .dat file

Here is a small python program using tk graphics toll kit to demonstrate digitizing ( mouse clicking around some shape). This example program uses a simple square. The source code square.py3 when executed, records mouse click location, normalizes size of x,y to 0.0 ... 1.0 and write square_py3.dat. This source code and be used to get a graphics line around any 2D shape. OK to modify code. square.py3 source code square_py3.out output with extra information Screen shot after clicking mouse button 3, program connected digitized points. Program light_dat showing output square_py3.dat graphics. square_py3.dat standard .dat file
    <- previous    index    next ->

Other links

Many web sites on Java GUI, AWT, Swing, etc.
Many web sites on Python wx, tk, qt, etc.

Go to top