home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / 3d / irit / scripts / loffset2.irt < prev    next >
Encoding:
Text File  |  1994-09-18  |  4.6 KB  |  142 lines

  1. #
  2. # Some comparison tests with L/A/OFFSET.
  3. #
  4. #            Gershon Elber, OCtober 1994.
  5. #
  6.  
  7. #
  8. # If false - just computes the offsets and save in file. If true do full
  9. # testing of four methods (about 2 hours on a 150Mhz R4400...).
  10. #
  11. do_offset_compare = false;
  12.  
  13. ComputeError = procedure( Crv, Dist, OCrv ):Dst:DstSqr:FFMin:FFMax:
  14.     Dst = symbdiff( Crv, OCrv ):
  15.     DstSqr = symbdprod( Dst, Dst ):
  16.     FFMin = max( coord( ffextreme( DstSqr, true ), 1 ), 0 ):
  17.     FFMax = max( coord( ffextreme( DstSqr, false ), 1 ), 0 ):
  18.     printf("%1.0lf %lf",
  19.            list(sizeof(OCrv),
  20.                 max( abs( sqrt( FFMin ) - Dist ),
  21.                      abs( sqrt( FFMax ) - Dist ) ) ) );
  22.                 
  23. CmpOffAllTols = procedure( Crv, FName, Dist, Tol, Steps ):c:i:
  24.     if (do_offset_compare,
  25.     logfile( FName + "_" + "offset" ):
  26.     logfile( on ):
  27.     T = Tol:
  28.     printf( "# OFFSET (%s)", list( FName ) ):
  29.     for (i = 0, 1, Steps,
  30.          c = offset( Crv, Dist, T, off ):
  31.          ComputeError( Crv, abs( Dist ), c ):
  32.          T = T * sqrt( 0.1 ) ):
  33.     logfile( FName + "_" + "offseti" ):
  34.     logfile( on ):
  35.     T = Tol:
  36.     printf( "# OFFSETI (%s)", list( FName ) ):
  37.     for (i = 0, 1, Steps,
  38.          c = offset( Crv, Dist, T, on ):
  39.          ComputeError( Crv, abs( Dist ), c ):
  40.          T = T * sqrt( 0.1 ) ):
  41.     T = Tol:
  42.     printf( "# AOFFSET (%s)", list( FName ) ):
  43.     logfile( FName + "_" + "aoffset" ):
  44.     logfile( on ):
  45.     for (i = 0, 1, Steps,
  46.          c = aoffset( Crv, Dist, T, false, off ):
  47.          ComputeError( Crv, abs( Dist ), c ):
  48.          T = T * sqrt( 0.1 ) ):
  49.     T = Tol:
  50.     printf( "# LOFFSET (%s)", list( FName ) ):
  51.     logfile( FName + "_" + "loffset" ):
  52.     logfile( on ):
  53.     for (i = 0, 1, Steps,
  54.          c = offset( Crv, Dist, T, on ):
  55.          c = loffset( Crv, Dist, 300, sizeof( c ), 4 ):
  56.          ComputeError( Crv, abs( Dist ), c ):
  57.          T = T * sqrt( 0.1 ) ):
  58.     logfile( off ));
  59.  
  60. #############################################################################
  61.  
  62. bez = cbezier( list( ctlpt( E2, -0.95, 0.7 ),
  63.              ctlpt( E2, -0.3,  0.5 ),
  64.              ctlpt( E2,  0.3, -2.5 ),
  65.              ctlpt( E2,  0.9, -0.2 ) ) );
  66.  
  67. bez_off = loffset( bez, 0.5, 300, 64, 4 );
  68. attrib( bez_off, "width", 0.02 );
  69. save( "bez_0.4_off", list( bez, bez_off ) );
  70. CmpOffAllTols( bez, "bez_0.4", 0.4, 1.0, 6 );
  71.  
  72. cpawn = cbspline( 4,
  73.     list( ctlpt( E2, 0.95, 0.05 ),
  74.           ctlpt( E2, 0.95, 0.76 ),
  75.           ctlpt( E2, 0.30, 1.52 ),
  76.           ctlpt( E2, 0.30, 1.90 ),
  77.           ctlpt( E2, 0.50, 2.09 ),
  78.           ctlpt( E2, 0.72, 2.24 ),
  79.           ctlpt( E2, 0.72, 2.32 ),
  80.           ctlpt( E2, 0.38, 2.50 ),
  81.           ctlpt( E2, 0.42, 2.70 ),
  82.           ctlpt( E2, 0.57, 2.81 ),
  83.           ctlpt( E2, 0.57, 3.42 ),
  84.           ctlpt( E2, 0.19, 3.57 ),
  85.           ctlpt( E2, 0.00, 3.57 ) ),
  86.      list( KV_OPEN ) );
  87.  
  88. cpawn_off = loffset( cpawn, 0.5, 300, 78, 4 );
  89. attrib( cpawn_off, "width", 0.04 );
  90. save( "cpawn_0.5_off", list( cpawn, cpawn_off ) );
  91. CmpOffAllTols( cpawn, "cpawn_0.5", 0.5, 1.0, 4 );
  92.  
  93. cpawn_off = loffset( cpawn, 1.5, 300, 57, 4 );
  94. attrib( cpawn_off, "width", 0.04 );
  95. save( "cpawn_1.5_off", list( cpawn, cpawn_off ) );
  96. CmpOffAllTols( cpawn, "cpawn_1.5", 1.5, 1.0, 3 );
  97.  
  98. cross = cbspline( 4,
  99.                   list( ctlpt( E2,  0.5,  0.5 ),
  100.                         ctlpt( E2,  0.5, -0.5 ),
  101.                         ctlpt( E2, -0.5, -0.5 ),
  102.                         ctlpt( E2, -0.5,  0.5 ) ),
  103.                   list( KV_PERIODIC ) );
  104. cross = coerce( cross, kv_open );
  105.  
  106. cross_off = loffset( cross, 0.3, 300, 97, 4 );
  107. attrib( cross_off, "width", 0.02 );
  108. save( "cross_0.3_off", list( cross, cross_off ) );
  109. CmpOffAllTols( cross, "cross_0.3", 0.3, 0.1, 4 );
  110.  
  111. circ = circle( vector(0, 0, 0), 1 );
  112.  
  113. circ_off = loffset( circ, 0.5, 300, 33, 4 );
  114. attrib( circ_off, "width", 0.02 );
  115. save( "circ_0.5_off", list( circ, circ_off ) );
  116. CmpOffAllTols( circ, "circ_0.5", 0.5, 0.1, 4 );
  117.  
  118. circ_off = loffset( circ, -0.6, 300, 65, 4 );
  119. attrib( circ_off, "width", 0.025 );
  120. save( "circ-0.6_off", list( circ, circ_off ) );
  121. CmpOffAllTols( circ, "circ-0.6", -0.6, 0.1, 4 );
  122.  
  123. Crv = cbspline( 3,
  124.                 list( ctlpt( E2, 0.7, 0.0 ),
  125.                       ctlpt( E2, 0.7, 0.06 ),
  126.                       ctlpt( E2, 0.1, 0.1 ),
  127.                       ctlpt( E2, 0.1, 0.6 ),
  128.                       ctlpt( E2, 0.6, 0.6 ),
  129.                       ctlpt( E2, 0.8, 0.8 ),
  130.                       ctlpt( E2, 0.8, 1.4 ),
  131.                       ctlpt( E2, 0.6, 1.6 ) ), list( KV_OPEN ) );
  132.  
  133. doc_crv_off = loffset( Crv, 0.4, 300, 49, 4 );
  134. attrib( doc_crv_off, "width", 0.02 );
  135. save( "doc_crv_0.4_off", list( Crv, doc_crv_off ) );
  136. CmpOffAllTols( Crv, "doc_crv_0.4", 0.4, 0.1, 3 );
  137.  
  138. doc_crv_off = loffset( Crv, -0.8, 300, 53, 4 );
  139. attrib( doc_crv_off, "width", 0.02 );
  140. save( "doc_crv-0.8_off", list( Crv, doc_crv_off ) );
  141. CmpOffAllTols( Crv, "doc_crv-0.8", -0.8, 0.1, 3 );
  142.