This tutorial looks at the basics of creating patterns defined within a 2D polar
coordinate system. Using polar coordinates is somewhat unusual because the
majority of effects applied by shaders generally depend on the direct use of 2D 'st' texture coordinates
and/or the 3D coordinates of points, vectors and normals such as the global variables
2D Cartesian Coordinates
Locations within a 2D cartesian coordinate systems are measured relative to two axes
that are perpendicular to each other. For example, figure 1 shows the coordinates
3D Cartesian Coordinates
Figure 2 shows the coordinates (
2D Polar Coordinates
Figure 3 illustrates how the location of a point, within a polar coordinate system, is
specified by distance (
Relative to the center of the 1 x 1 polygon, shown in figure 3, the coordinates of
the hilited box are,
The School of Mathematics and Statistics at the University of St.Andrews, Scotland maintains a web site of "Famous Curves". Many of the curves are defined by formula that require the use of polar coordinates. For example, figure 4 uses the polar description of a curve called the "Trisectrix of Maclaurin"
Listing 2 provides the code for the shader that produced the pattern shown above.
Listing 2 - maclaurin.osl
© 2002- Malcolm Kesson. All rights reserved.