Blog

Viewing posts by christian

Depicting a torus as an SVG image

SVG may not be the most obvious choice for depicting a 3-D object, but with some care over the perspective and ordering of the plotted points, it can be done.

Generating an SVG clock face

This is a simple Python function to generate a clock face indicating a specified time. It can be used in the script below to generate 1, 2, 4 or 6 faces indicating random times to teach children how to tell the time. Run this script from the command line as

Truchet Tiles

Truchet Tiles are decorated squares which can tile a plane to create a pattern. For example, the four tiles:

Reaching Orbit

The following code illustrates the effect of the initial velocity on the dynamics of an object released in a gravitational field. A very simple numerical integration of the equation of motion gives the trajectory, which is plotted below for four different initial speeds for a rocket released at 200 km altitude parallel to the Earth's surface. At this altitude the speed needed for a circular orbit is about 7.8 km/s.

The bounding box of a rotated object

The following code plots a two-dimensional object and its bounding box for several rotations about an arbitrary point. Three types of bounding box are considered: (1) the original bounding box, rotated by the same amount as the object, (2) the bounding box to that bounding box (such that its sides remain parallel to the axes), and (3) the bounding box to the rotated object with sides parallel to the axes).