| |
|
|
|
Interested in ray tracing with Open Inventor?
Goto IVTrace to learn more.
| OpenGL |
mmmm. Krispy Kreme.
| Flat shaded sphere with uDim=20,
vDim=20
| Smooth shaded sphere with uDim=20,
vDim=20
|
Elongated torus with uDim=20,
vDim=20
|
Flat shaded torus with uDim=20,
vDim=20
| Flat shaded torus with uDim=40,
vDim=40
|
Above are screenshots taken
while running the program shape.cpp. The program generates either a torus or a
sphere depending on what the user specifies at the command line. The two
shapes are generated using parametric equations depending on both u
and v to determine the < x, y, z > point on the shape. The equations
for each shape are below.
- Torus:
- x = (R + r*cos(v)) * cos(u)
y = (R + r*cos(v)) * sin(u)
z = thickness*sin(v)
where 'R' is the major radius, 'r' the minor radius and
'thickness' is the thickness of the torus in the z
direction. u and v are in the range [0, 2pi].
- Sphere:
- x = r*cos(u)*sin(v)
y = r*sin(u)*sin(v)
z = r*cos(v)
where 'r' is the radius, u is in the range [0, 2pi] and v
is in the range [0, pi].
A Quicktime
animation
showing a torus change in size, color, and resolution is here.
Links to the code used to generate the above images are below:
|
| All code
used to create these images can be downloaded here -> hw08.tar.gz
|
|
|
|