home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk12 / linefrac / lfxform.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-20  |  5.3 KB  |  239 lines

  1. /************************************************************************
  2. *
  3. *   lfxform.c -- Built-in similarity transforms.
  4. *
  5. *   Created by Microsoft Corporation, 1989
  6. *
  7. ************************************************************************/
  8.  
  9. #define INCL_GPI
  10. #include <os2.h>
  11. #include "linefrac.h"
  12.  
  13.  
  14.  
  15.  
  16. #define SQRT_2    1.4142136
  17. #define SQRT_3    1.7320508
  18.  
  19.  
  20.  
  21.  
  22. /************************************************************************
  23. *
  24. *   SharkTooth
  25. *
  26. *   Set up the similarity transform for the following linefractal,
  27. *   which looks roughly like:
  28. *
  29. *
  30. *                 *
  31. *             ===>      *   *
  32. *                 *         *
  33. *   ***************       *           *
  34. *
  35. ************************************************************************/
  36.  
  37. LINEFRAC SharkTooth[] =
  38. {
  39.     &SharkTooth[1],  PI / 6.0, (1.0/SQRT_3), FALSE,
  40.     EOLIST,        -PI / 3.0, (1.0/SQRT_3), FALSE
  41. };
  42.  
  43.  
  44.  
  45.  
  46. /************************************************************************
  47. *
  48. *   SawTooth
  49. *
  50. *   Set up the similarity transform for the following linefractal,
  51. *   which looks roughly like:
  52. *
  53. *
  54. *
  55. *             ===>      *
  56. *                 *     *
  57. *   ***************       *       *       *
  58. *                     *     *
  59. *                       *
  60. *
  61. ************************************************************************/
  62.  
  63. LINEFRAC SawTooth[] =
  64. {
  65.     &SawTooth[1],  PI / 4.0, (0.5 / SQRT_2), FALSE,
  66.     &SawTooth[2], -PI / 2.0, (1.0 / SQRT_2), FALSE,
  67.     EOLIST,       PI / 2.0, (0.5 / SQRT_2), FALSE
  68. };
  69.  
  70.  
  71.  
  72.  
  73. /************************************************************************
  74. *
  75. *   KochIsland
  76. *
  77. *   Set up the similarity transform for the following linefractal,
  78. *   which looks roughly like:
  79. *
  80. *   This is known as the Koch, or snowflake, transform.
  81. *
  82. *
  83. *                      *
  84. *             ===>        * *
  85. *                    *   *
  86. *   ***************       *****     *****
  87. *
  88. ************************************************************************/
  89.  
  90. LINEFRAC Koch[] =
  91. {
  92.      &Koch[1],         0.0, 1.0 / 3.0, FALSE,
  93.      &Koch[2],        PI / 3.0, 1.0 / 3.0, FALSE,
  94.      &Koch[3], -2 * PI / 3.0, 1.0 / 3.0, FALSE,
  95.      EOLIST,        PI / 3.0, 1.0 / 3.0, FALSE
  96. };
  97.  
  98.  
  99.  
  100.  
  101. /************************************************************************
  102. *
  103. *   SpaceFiller
  104. *
  105. *   Set up the similarity transform for the following linefractal,
  106. *   which looks roughly like:
  107. *
  108. *
  109. *               ***B******C***
  110. *               *        *
  111. *               A        D
  112. *   **************   ===>  *        *
  113. *
  114. *
  115. *   where sides A and D are reflections.
  116. *
  117. *
  118. *
  119. ************************************************************************/
  120.  
  121. LINEFRAC SpaceFiller[] =
  122. {
  123.     &SpaceFiller[1],  PI / 2.0, 0.5, TRUE,
  124.     &SpaceFiller[2], -PI / 2.0, 0.5, FALSE,
  125.     &SpaceFiller[3],       0.0, 0.5, FALSE,
  126.     EOLIST,         -PI / 2.0, 0.5, TRUE
  127. };
  128.  
  129.  
  130.  
  131.  
  132. /************************************************************************
  133. *
  134. *   StovePipe
  135. *
  136. *   Set up the similarity transform for the following linefractal,
  137. *   which looks roughly like:
  138. *
  139. *   This is sometimes known as the stovepipe transform.
  140. *
  141. *
  142. *                   ******
  143. *                   *    *
  144. *             ===>      *    *
  145. *                   *    *
  146. *   **************       *****    *****
  147. *
  148. ************************************************************************/
  149.  
  150. LINEFRAC StovePipe[] =
  151. {
  152.     &StovePipe[1],     0.0, 1.0 / 3.0, FALSE,
  153.     &StovePipe[2],  PI / 2.0, 1.0 / 3.0, FALSE,
  154.     &StovePipe[3], -PI / 2.0, 1.0 / 3.0, FALSE,
  155.     &StovePipe[4], -PI / 2.0, 1.0 / 3.0, FALSE,
  156.     EOLIST,        PI / 2.0, 1.0 / 3.0, FALSE
  157. };
  158.  
  159.  
  160.  
  161.  
  162. /************************************************************************
  163. *
  164. *   SquareWave
  165. *
  166. *   Set up the similarity transform for the following linefractal,
  167. *   which looks roughly like:
  168. *
  169. *
  170. *               ******
  171. *               *    *
  172. *   **************   ===>  *    *    *
  173. *                *    *
  174. *                ******
  175. *
  176. ************************************************************************/
  177.  
  178. LINEFRAC SquareWave[] =
  179. {
  180.     &SquareWave[1],  PI / 2.0, 0.25, FALSE,
  181.     &SquareWave[2], -PI / 2.0, 0.5,  FALSE,
  182.     &SquareWave[3], -PI / 2.0, 0.5,  FALSE,
  183.     &SquareWave[4],  PI / 2.0, 0.5,  FALSE,
  184.     EOLIST,         PI / 2.0, 0.25, FALSE
  185. };
  186.  
  187.  
  188.  
  189.  
  190. /************************************************************************
  191. *
  192. *   HourGlass
  193. *
  194. *   Set up the similarity transform for the following linefractal,
  195. *   which looks roughly like:
  196. *
  197. *
  198. *                  * * * * *
  199. *                *   *
  200. *                  *
  201. *             ===>    *   *
  202. *                  *       *
  203. *   **************        *        *
  204. *
  205. ************************************************************************/
  206.  
  207. #define HOURGLASSANGLE    0.463648
  208. #define HOURGLASSLEN    0.83852549
  209.  
  210. LINEFRAC HourGlass[] =
  211. {
  212.     &HourGlass[1],     HOURGLASSANGLE, HOURGLASSLEN, FALSE,
  213.     &HourGlass[2],  PI-HOURGLASSANGLE, 0.5,         FALSE,
  214.     EOLIST,       -PI-HOURGLASSANGLE, HOURGLASSLEN, FALSE
  215. };
  216.  
  217.  
  218.  
  219.  
  220. /************************************************************************
  221. *
  222. *   aXform
  223. *
  224. *   This lists all the built-in transforms available, with their default
  225. *   coordinate offsets and scale factors.
  226. *
  227. ************************************************************************/
  228.  
  229. XFORMDATA aXform[] =
  230. {
  231.     SharkTooth,  0.200,  0.200,  0.60, 0.60, 3,
  232.     SawTooth,     0.125,  0.125,  0.75, 0.75, 3,
  233.     Koch,     0.125,  0.125,  0.75, 0.75, 3,
  234.     SpaceFiller, 0.000, -0.500,  1.00, 1.00, 1,
  235.     StovePipe,     0.125,  0.125,  0.75, 0.75, 4,
  236.     SquareWave,  0.200,  0.200,  0.60, 0.60, 5,
  237.     HourGlass,     0.250,  0.250,  0.50, 0.50, 2
  238. };
  239.