Difficulty |
2 |
Reading material |
|
def material(color)
{
Materials.uniform( [ "ambient": color * 0.1,
"diffuse": color * 0.8,
"specular": Colors.white() * 0.8,
"specular_exponent": 100,
"reflectivity": 0.1 ] )
}
def scene_at(now)
{
var camera = Cameras.perspective( [ "eye": pos(0,5,15),
"look_at": pos(0,0,0) ] )
var pos1 = Animations.lissajous( [ "x_phase": degrees(90),
"duration": seconds(5) ] )
var pos2 = Animations.lissajous( [ "z_amplitude": 0,
"x_frequency": 2,
"y_frequency": 3,
"x_phase": degrees(180),
"duration": seconds(5) ] )
var pos3 = Animations.lissajous( [ "z_amplitude": 3,
"x_frequency": 7,
"y_frequency": 5,
"z_frequency": 3,
"duration": seconds(5) ] )
var wall_material = Materials.uniform( [ "ambient": Colors.white() * 0.1,
"diffuse": Colors.white() * 0.5,
"reflectivity": 0.1 ] )
var back_wall = translate(vec(0,0,-5), decorate(wall_material, xy_plane()))
var floor = translate(vec(0,-5,0), decorate(wall_material, xz_plane()))
var root = union([ translate(vec(-5,0,0) + pos1[now] - pos(0,0,0), decorate( material(Colors.red()), sphere())),
translate(pos2[now] - pos(0,0,0), decorate( material(Colors.red()), sphere())),
translate(vec(5,0,0) + pos3[now] - pos(0,0,0), decorate( material(Colors.red()), sphere())),
back_wall,
floor])
var lights = [ Lights.omnidirectional( pos(0,5,5), Colors.white() ) ]
create_scene(camera, root, lights)
}
var raytracer = Raytracers.v6()
var renderer = Renderers.standard( [ "width": 500,
"height": 500,
"sampler": Samplers.multijittered(2),
"ray_tracer": raytracer ] )
pipeline( scene_animation(scene_at, seconds(5)),
[ Pipeline.animation(30),
Pipeline.renderer(renderer),
Pipeline.studio() ] )
1. Implementation
To simplify things, we generalize the formula from the background information even further:
\[\begin{array}{rcl}
x(t) & = & A_\mathrm{x} \cdot \sin(B_\mathrm{x} \cdot 2\pi \cdot t - C_\mathrm{x}) \\
y(t) & = & A_\mathrm{y} \cdot \sin(B_\mathrm{y} \cdot 2\pi \cdot t - C_\mathrm{y}) \\
z(t) & = & A_\mathrm{z} \cdot \sin(B_\mathrm{z} \cdot 2\pi \cdot t - C_\mathrm{z}) \\
\end{array}\]
We give the parameters the more descriptive names:
Math | Code | Default |
---|---|---|
\(A_\mathrm{x}\) |
|
1 |
\(A_\mathrm{y}\) |
|
1 |
\(A_\mathrm{z}\) |
|
1 |
\(B_\mathrm{x}\) |
|
1 |
\(B_\mathrm{y}\) |
|
1 |
\(B_\mathrm{z}\) |
|
1 |
\(C_\mathrm{x}\) |
|
\(0^\circ\) |
\(C_\mathrm{y}\) |
|
\(0^\circ\) |
\(C_\mathrm{z}\) |
|
\(0^\circ\) |
Implement the Lissajous animation so that we can use it as
where all parameters except
|
2. Evaluation
Render the scene below.
|