<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
 (ns uk.co.fatvat.ifs
-  (:import [javax.swing JFrame JPanel])
+  (:import [javax.swing JFrame JPanel JSpinner SpinnerNumberModel])
   (:import [java.awt Color Polygon])
   (:import [java.awt.image BufferedImage])
   (:import [javax.swing.event MouseInputAdapter])
@@ -17,12 +17,27 @@
 
 (defstruct transform :function :prob)
 
+(defn magnitude [x y] (Math/sqrt (+ (* x x) (* y y))))
+
+(defn theta [x y] (Math/atan (/ x y)))
+
+(defn phi [x y] (Math/atan (/ y x)))
+
 (defn affine-transform
   &quot;Perform an affine transform&quot;
   [[a b c d e f] [x y]]
   [(+ (* a x) (* b y) e)
    (+ (* c x) (* d y) f)])
 
+(defn sinusoidal
+  [[a b c d e f] [x y]]
+  (affine-transform (Math/sin x) (Math/sin y)))
+
+(defn spherical
+  [[a b c d e f] [x y]]
+  (let [mag (/ 1 (+ (* x x) (* y y)))]
+    (affine-transform (* mag x) (* mag y))))
+
 (defn mk-linear-transform
   [[a b c d e f] prob]
   (struct transform (partial affine-transform [a b c d e f]) prob))
@@ -38,9 +53,15 @@
 (defvar sierpinski-transform
   (list
    (mk-linear-transform [0.5 0.0 0 0.5 0 0] 0.33)
-   (mk-linear-transform [0.5 0.0 0 0.5  0.25 (* 0.5 (/ (Math/sqrt 3) 2))] 0.66)
+   (mk-linear-transform [0.5 0.0 0 0.5 0.25 (* 0.5 (/ (Math/sqrt 3) 2))] 0.66)
    (mk-linear-transform [0.5 0.0 0 0.5 0 0.5 0 ] 1.00))
   &quot;The sierpinski transform&quot;)
+
+(defvar random-transform
+  (list
+   (mk-linear-transform [0.5 0.0 0 0.5 0 0] 0.4)
+   (mk-linear-transform [0.5 0.0 0 0.5 0.25 (* 0.5 (/ (Math/sqrt 3) 2))] 0.8)
+   (mk-linear-transform [0.5 0.0 0 0.5 0 0.5 0 ] 1.00)))
    
 (defn calculate-point
   &quot;Calculate the next point to render based on the previous&quot;
@@ -75,7 +96,8 @@
              (fn [_] @running)
              (iterate (partial calculate-point transform) [0 0]))]
       (let [[sx sy] (scale [px py] bounds)]
-        (.setRGB source sx sy (rand Integer/MAX_VALUE))
+        (when (and (&gt;= sx 0) (&lt;= sx width) (&gt;= sy 0) (&lt;= sy height))
+          (.setRGB source sx sy (rand Integer/MAX_VALUE)))
         (.repaint panel)))))
 
 (defn launch-ui</diff>
      <filename>misc/uk/co/fatvat/ifs.clj</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>41b483c51baad7036184101bab3db25a1e103a06</id>
    </parent>
  </parents>
  <author>
    <name>Jeff Foster</name>
    <email>jeff.foster@acm.org</email>
  </author>
  <url>http://github.com/fffej/ClojureProjects/commit/aef50c9b87de9f78aec36f7922c5eca8b2501cd8</url>
  <id>aef50c9b87de9f78aec36f7922c5eca8b2501cd8</id>
  <committed-date>2009-08-02T23:44:13-07:00</committed-date>
  <authored-date>2009-08-02T23:44:13-07:00</authored-date>
  <message>only draw if within bounds.</message>
  <tree>33ded5c50d8eb841949a69c19b67537d888b1365</tree>
  <committer>
    <name>Jeff Foster</name>
    <email>jeff.foster@acm.org</email>
  </committer>
</commit>
