TITLE: Shell
NAME: Wong Chee Fah
COUNTRY: Malaysia
EMAIL: wongcf@cyberway.com.sg
TOPIC: Physics & Math
COPYRIGHT: I SUBMIT TO THE STANDARD RAYTRACING COMPETITION COPYRIGHT.
JPGFILE: shell01a.jpg
RENDERER USED:
POV-Ray 3.01 for Windows 95
TOOLS USED:
Adobe Photoshop 4 - for image compression, Home-made smooth
triangle mesh utility
RENDER TIME:
Approximately 1 day and 16 hours
HARDWARE USED:
Pentium 133MHz, 64MB EDO, S3 Virge 4MB EDO
IMAGE DESCRIPTION:
Visualization of parametric equations defining a shell-shape surface
DESCRIPTION OF HOW THIS IMAGE WAS CREATED:
This image is a demonstration of the use of POV-Ray as a visualization tool.
Mathematical functions are better understood if they can be visually presented.
The wealth of mathematical functions available in POV-Ray makes it suitable as
a tool for this purpose.
The parametric equations defining the shell-shape surface are as follows :-
x = U*(cos(V)^2)*cos(U)
y = U*(cos(V)^2)*sin(U)
z = U*cos(V)*sin(V)
The shell is bounded by U from 0 to 4pi and by V from 0 to pi. The mesh is
created using a smooth triangle utility program I wrote with Delphi 2. As
mentioned in the POV_Ray help documentation, it is prohibitively difficult to
calculate the surface normals necessary for the smooth triangles. The lack of
arrays in POV-Ray makes it difficult and inefficient to implement the code in
POV-Ray itself. The utility basically calculates the points and the average
normal vectors and stores them in arrays. Using the arrays, it then extracts
the appropriate points and its associated normal for the corners of each
triangle. The compiled triangles are written into a file which is then
incorporated into the scene using the #include statement. The texture is 50%
transparent so that the internal structure of the shell can be seen. The
purpose of this image is to better visualize the shell surface demonstrated by
shell01.pov. The parameters, camera and light setting are exactly the same as
in shell01.pov so that a direct comparison can be made. The source file is not
included because it is identical to shell01.pov except that some parameters are
not required and the shell calculation has been replaced by an include
statement.
For those interested in the details of the calculations, the utility first
calculates the coordinates of a point and 8 other points around it and stores
them in an array. The arrangment of the points is illustrated below :-
V+dV
Pt8 Pt1 Pt2
|-------|-------|
|\ | /|
| \ |A /B |
| \ | / |
| \|/ U,V |
U-dU Pt7 |------Pt0------| Pt3 U+dU
| /|\ |
| / | \ |
| / | \ |
|/ | \|
|-------|-------|
Pt6 Pt5 Pt4
V-dV
It then calculates vector A from Pt0 to Pt1 and vector B from Pt0 to Pt2. A
cross product operation is then performed on the two vectors to obtain a normal
vector for the triangle Pt0-Pt1-Pt2. This operation is repeated for triangles
Pt0-Pt2-Pt3, Pt0-Pt3-Pt4 and so on using the surrounding points. The eight
normal vectors are converted to unit vectors and then averaged to obtain an
average vector for Pt0. The coordinates for Pt0 and its averaged normal is then
stored in an array.
To output the triangle mesh, the following triangle arrangement scheme is used.
U0,V2 U1,V2 U2,V2
|-------|-------|
| /| /|
| / | / |
| / | / |
|/ |/ |
U0,V1 |-----U1,V1-----| U2,V1
| /| /|
| / | / |
| / | / |
|/ |/ |
|-------|-------|
U0,V0 U1,V0 U2,V0
The coordinates and normal vector for each corner of each triangle is extracted
and formatted into smooth triangle declarations. The triangles are then written
to a text file named shell.inc. By the way the include file used for this scene
contains 180000 triangles and is about 72 MB in size (Yes, an overkill - I
wanted test the speed of my system in handling large arrays of floating point
values).