Algorithmic Image Generator
MAT299 - Independent Study, advised by George Legrady
Introduction
The project's goal was to implement a visualization and experimentation tool for 2D trigonometric functions, which can be used to produce animated image sequences and export three-dimensional data. In addition, it was to use a compatible mathematical syntax with Macromedia Director for use in prototyping interactive media installations. By allowing the user to dynamically modify mathematical expressions and preview the results, it bypasses the tedious process of having to stop, modify source code, and recompile/restart an application in order to view changes, which speeds workflow and promotes experimentation.
Figure 1 - User interface (click to enlarge)
Features
- Director-compatible mathematical syntax, for use as interactive media prototyping tool.
- Project export as:
- Image sequence (PNG format)
- XML, for compact storage
- MathML, for use in mathematics or simulation applications
- Three-dimensional data (STL format), for use in 3D rendering applications and machine lithography
- Random function generator, as an aid in experimentation
For example, using the project's software, the function:
f(x,y,z) = y/cos(sin(sin(y*y+x)/(y/pi*y)-(z/0.875))*x/cos(log(pi-z)*z))
was developed and exported to the following formats:
Image
(PNG format)
XML (XML-encoded
JavaBean)
MathML
3D (STL format)
allowing it to be used in a wide variety of applications. Further examples can be seen below.
Animation Examples
(requires quicktime 6)
![]() zoneplate.mov (2MB) |
![]() bacteria.mp4 (1.9MB) |
![]() turtle.mp4 (2.5MB) |
![]() recede.mp4 (1.1MB) |
![]() sailing.mp4 (0.7MB) |
![]() inca.mp4 (2.8MB) |
3d Output Examples
![]()

Figure 2 - 2D and 3D representations of cos((cos(y)-sin(x)/pi)*sqrt(y+abs(y-(x)+pi))*pi)/2+1/2

Figure 3 - 2D and 3D representations of sin((sin(x))*(sin(y)*2*pi))/2+1/2

Figure 4 - 2D and 3D representations of sin(x+sin(x))*sin(y+sin(y))/2+1/2

Figure 5 - 2D and 3D representations of sin(x*sin(x)/y*cos(y)*x*sin(2*y))/3
other examples

Figure 6 - MathML export viewed in popular equation editor
Implementation Notes
This project was implemented in the Java programming language, with a Director-based portion implemented using the Lingo scripting language.
The Director-compatible syntax was implemented using the JeksParser library, which is an extensible framework for parsing and computing mathematical expressions.
One difficulty encountered was that it was impossible to easily predict the possible range of values an inputted function might produce. This caused problems when attempting to map a function's numeric values to appropriate color values, and would frequently result in all black or all white images. To alleviate this, alternate out-of-bounds color behaviors were implemented. In addition to a standard limiting behavior (f < min, f = min; f > max, f = max), out-of-bounds values can alternately be reflected (even cycle, f=|value%(max-min)|+2min; odd cycle, f=max-|value%(max-min)|+min), or wrapped (f =|value%(max-min)|+min). (See figure 7 below).

Figure 7 - Out-of-bounds coloring behavior (limit, reflect, and wrap)





