Sunday, February 28, 2010

Drawing programs

I was playing around with some "Chrome Experiments" and came across a fun drawing program. I had to implement some aspects of a drawing program at work so I can appreciate something well made:

http://www.chromeexperiments.com/detail/sketchpad/


Tuesday, February 23, 2010

LaTeX Grapher

In an effort to equip my wife with the finest tools for being a math professor I've started to tackle the seemingly (to me) gaping hole in math document creation of quality two dimensional graph generation. Quality means vector graphics. Document creation means no one-offs, but instead something that is maintainable for the lifetime of said document. These requirements lead directly to something language driven and with enough features (and ability to add features in a consistent way) to handle anything we throw at it. The initial result is this:

http://latexgrapher.codeplex.com/

It's not ready for binary releases yet, but it will get there. Right now it requires .NET 3.5 (probably SP1). It can be compiled by Visual Studio C# 2008 Express Edition (free download). I will probably make a Silverlight version eventually, then you can use your web browser (and Silverlight plugin) to make graphs from Linux, Mac, or Windows. There will also eventually be a command line version that can be integrated into your desired build process.

What can it do now you ask? Here are a few examples.







Output

Code



View (-3,-3),(5,5)

f(x) = x^3/20 + 2

Shade f,(-2,3)


View (-1,-3),(6,4)

f(x) = x^2/5          | x < 2
       3              | x == 2
       x^2/5          | x < 4
       -(x-2)^2/2 + 3 |
                      : x = 2,4

View (-1,-1),(11,11)

f(x) = NaN          | x < 0
       3            | x < 1
       3+2*floor(x) | x < 4
       10           |
                    : x = 0,1,2,3,4


View (-10,-10),(10, 10)

> r = 5
> n = 5
> x0 = 2
> y0 = 3
> a(t) = t*pi/(2*n)
> fx(t) = r*cos(a(t)) + x0
> fy(t) = r*sin(a(t)) + y0
> gx(t) = -(fx(t) - x0) + x0
> gy(t) = -(fy(t) - y0) + y0

Line    (gx(0),gy(0)),(fx(0),fy(0))
Segment (gx(1),gy(1)),(fx(1),fy(1))
Line    (gx(2),gy(2)),(fx(2),fy(2))
Segment (gx(3),gy(3)),(fx(3),fy(3))
Line    (gx(4),gy(4)),(fx(4),fy(4))
Segment (gx(5),gy(5)),(fx(5),fy(5))
Line    (gx(6),gy(6)),(fx(6),fy(6))
Segment (gx(7),gy(7)),(fx(7),fy(7))
Line    (gx(8),gy(8)),(fx(8),fy(8))
Segment (gx(9),gy(9)),(fx(9),fy(9))

g(x) = x