On 2016/02/18 8:34 PM, Stephan Beal wrote:
> Every calendar known to man sucks rocks in some regard or other, so 
> i'm not gonna sweat it. This is just a demo, and i've got a few hours 
> of budget left on it, so i'm working on this as the finale. (The 
> Mandelbrot CTE will be first, just to kind of blow their minds, before 
> we back way up and ease into it.)

Oh nice - nothing like some mind-blowing, and CTE is still one of my 
favourite additions to SQL. :)
May I offer this CTE from the tutorials in SQLitespeed in case you have 
a Math library linked.
(your math function names for cos(), sin() and degtorad() may differ):


with graph(gWidth, aInc, gAngle, gCos, gCosA, gSin, gSinA) AS (
     SELECT 20, 10, -90, 0, 0, 0, 0
   UNION ALL
     SELECT gWidth,aInc,gAngle+aInc,
            printf('%d',                  round( cos( degtorad( gAngle + 
aInc ) ) * gWidth + gWidth + 1 ) ),
            printf('%d', gWidth * 2 + 2 - round( cos( degtorad( gAngle + 
aInc ) ) * gWidth + gWidth + 1 ) ),
            printf('%d',                  round( sin( degtorad( gAngle + 
aInc ) ) * gWidth + gWidth + 1 ) ),
            printf('%d', gWidth * 2 + 2 - round( sin( degtorad( gAngle + 
aInc ) ) * gWidth + gWidth + 1 ) )
       FROM graph
      WHERE gAngle < 720
)
SELECT printf( '%4d', gAngle ) AS Angle,
        printf( '.%'||gCos||'s%'||gCosA||'s', '+', '.' ) AS Cosine,
        printf( '.%'||gSin||'s%'||gSinA||'s', '+', '.' ) AS Sine
   FROM graph
  WHERE gAngle >= 0;


   -- Angle | Cosine | Sine
   -- ----- | --------------------------------------------- | 
---------------------------------------------
   --   0   | .                                        +. | 
.                    +                    .
   --   10  | .                                        +. | 
.                       +                 .
   --   20  | .                                       + . | 
.                           +             .
   --   30  | .                                     +   . | 
.                              +          .
   --   40  | .                                   +     . | 
.                                 +       .
   --   50  | .                                 +       . | 
.                                   +     .
   --   60  | .                              +          . | 
.                                     +   .
   --   70  | .                           +             . | 
.                                       + .
   --   80  | .                       +                 . | 
.                                        +.
   --   90  | .                    +                    . | 
.                                        +.
   --  100  | .                 +                       . | 
.                                        +.
   --  110  | .             +                           . | 
.                                       + .
   --  120  | .          +                              . | 
.                                     +   .
   --  130  | .       +                                 . | 
.                                   +     .
   --  140  | .     +                                   . | 
.                                 +       .
   --  150  | .   +                                     . | 
.                              +          .
   --  160  | . +                                       . | 
.                           +             .
   --  170  | .+                                        . | 
.                       +                 .
   --  180  | .+                                        . | 
.                    +                    .
   --  190  | .+                                        . | 
.                 +                       .
   --  200  | . +                                       . | 
.             +                           .
   --  210  | .   +                                     . | .          
+                              .
   --  220  | .     +                                   . | .       
+                                 .
   --  230  | .       +                                 . | .     
+                                   .
   --  240  | .          +                              . | .   
+                                     .
   --  250  | .             +                           . | . 
+                                       .
   --  260  | .                 +                       . | 
.+                                        .
   --  270  | .                    +                    . | 
.+                                        .
   --  280  | .                       +                 . | 
.+                                        .
   --  290  | .                           +             . | . 
+                                       .
   --  300  | .                              +          . | .   
+                                     .
   --  310  | .                                 +       . | .     
+                                   .
   --  320  | .                                   +     . | .       
+                                 .
   --  330  | .                                     +   . | .          
+                              .
   --  340  | .                                       + . | 
.             +                           .
   --  350  | .                                        +. | 
.                 +                       .
   --  360  | .                                        +. | 
.                    +                    .
   --  370  | .                                        +. | 
.                       +                 .
   --  380  | .                                       + . | 
.                           +             .
   --  390  | .                                     +   . | 
.                              +          .
   --  400  | .                                   +     . | 
.                                 +       .
   --  410  | .                                 +       . | 
.                                   +     .
   --  420  | .                              +          . | 
.                                     +   .
   --  430  | .                           +             . | 
.                                       + .
   --  440  | .                       +                 . | 
.                                        +.
   --  450  | .                    +                    . | 
.                                        +.
   --  460  | .                 +                       . | 
.                                        +.
   --  470  | .             +                           . | 
.                                       + .
   --  480  | .          +                              . | 
.                                     +   .
   --  490  | .       +                                 . | 
.                                   +     .
   --  500  | .     +                                   . | 
.                                 +       .
   --  510  | .   +                                     . | 
.                              +          .
   --  520  | . +                                       . | 
.                           +             .
   --  530  | .+                                        . | 
.                       +                 .
   --  540  | .+                                        . | 
.                    +                    .
   --  550  | .+                                        . | 
.                 +                       .
   --  560  | . +                                       . | 
.             +                           .
   --  570  | .   +                                     . | .          
+                              .
   --  580  | .     +                                   . | .       
+                                 .
   --  590  | .       +                                 . | .     
+                                   .
   --  600  | .          +                              . | .   
+                                     .
   --  610  | .             +                           . | . 
+                                       .
   --  620  | .                 +                       . | 
.+                                        .
   --  630  | .                    +                    . | 
.+                                        .
   --  640  | .                       +                 . | 
.+                                        .
   --  650  | .                           +             . | . 
+                                       .
   --  660  | .                              +          . | .   
+                                     .
   --  670  | .                                 +       . | .     
+                                   .
   --  680  | .                                   +     . | .       
+                                 .
   --  690  | .                                     +   . | .          
+                              .
   --  700  | .                                       + . | 
.             +                           .
   --  710  | .                                        +. | 
.                 +                       .
   --  720  | .                                        +. | 
.                    +                    .



The first CTE sets up some parameters in the first 3 fields used to draw 
the graph - play with those parameters for fun.
(I hope the mail system don't mess up the format too much...)

Cheers!
Ryan

Reply via email to