Supporting Tau

Posted: August 16, 2012 in Uncategorized

I’m proud to announce that Clisk now supports Tau.

If you care about elegance in your fundamental mathematical constants, then you should too.

In honour of Tau I’ve implemented the new “radial” effect, which can take any image and wrap it around the origin. Along with a “:repeat” keyword argument, this can create some nice patterns reminiscent of stars and flowers. The radial function itself was naturally expressed using the constant TAU:

(defn radial 
  "Wraps an image around origin in a radial fashion in the x-y plane"
   [src & {:keys [repeat] 
           :or {repeat 1.0}}]
   (warp [(vfrac (v* repeat (vdivide theta TAU))) , radius] 
         src))

Obligatory example usage:

(show (viewport [-1 -1] [1 1] 
  (clisk.effects/radial 
    vplasma
    :repeat 12)))

Image

 

 

Pi is maintained for backwards compatibility purposes.

About these ads
Comments
  1. In addition to backward-compatibility ;), it’s handy to have constants for various fractions of tau – not only pi, but pi/2 and sometimes smaller fractions. Where there are angles, there’s code like (+ theta pi/2) or (clamp theta (- pi) pi) or (sin (* (/ x period) tau)), so they save quite a bit of distracting division.

    • mikera7 says:

      Nice idea Arcane!

      It’s a shame that Clojure doesn’t allow the `pi/2` notation – since “/” is reserved as a namespace delimiter. Any ideas for a good alternative? PI-DIVIDED-BY-TWO doesn’t seem like much of a win over (/ PI 2). Maybe HALF-PI?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s