Kevin Song
I'm a student at UT (that's the one in Austin) who studies things.
We can use the lerp()
function to smoothly interpolation motion between endpoints.
Interpolation can also be applied to many different types of values.
The variable is traditionally called "time," but a better name for it might be "control," since it controls what blend of the endpoints you see.
lerp(x, y, 0) = x
lerp(x, y, 1) = y
How important is it to know the equations for interpolation/splining/easing?
Not important at all, at least for this class.
Apart from sines, what other functions can be used for non-linear motion?
Pretty much anything.
But we're still trying to draw 2D images!
Suddenly, we're going to have many more choices about how to make pictures.
Cameras can project in two ways: orthographic or perspective
Orthographic
Perspective
There are many more choices in 3D: camera position, direction, lighting, even other choices within perspectives!
By default, Processing assumes you want to work in 2 dimensions. We'll need to tell it we want to work in 3D.
size(width, height, P3D);
Note: there is also a P2D renderer. P2D and P3D work in OpenGL, making them faster with more effects.
Now that we're in 3D, rect()
and ellipse()
calls won't cut it anymore!
Instead, we can use box()
and sphere()
to create boxes and spheres, respectively. More complex shapes can be made with beginShape()
and vertex()
We can use fill()
and stroke()
on these primitives, but cannot set positions---must use affine transforms to do this.
Just like with SVGs, we can load meshes into PShape objects.
PShape object = loadShape("filename.obj");
Note: we need to be in 3D rendering mode in order to load .obj files!
shape(object, 0, 0, object.width, object.height);
In 2D, we had access to three basic transformations:
In 3D, we're going to have access to the same set of transformations. In fact, their mathematical notation looks similar too!
Okay, so it turns out that rotations in 3D can get a little tricky...
Translate and scale function basically the same as their 2D counterparts, but with an additional function argument.
Rotate is replaced by three functions which each take a parameter.
translate(x, y, z)
scale(x, y,z)
rotateX(θ)
rotateY(θ)
rotateZ(θ)
Most coordinate systems are "right-handed". Processing uses a left-handed coordinate system.
The concepts are the same, just be sure you have the right picture in your head before trying things!
Where is the camera?
Where is the camera looking?
What direction is the camera turned?
camera(eyeX,
eyeY, eyeZ, centerX,centerY, centerZ, upX, upY,
upZ)
;
Example for changing the height of the camera based on mouse movement:
camera(200.0, mouseY, 120.0,
0.0, 0.0, 0.0,
0.0, 1.0, 0.0);
P3D
into size()
to get a 3D environment!The same way it does to a computer-initiated adjustment.
Different from kernel: creates new pixels and fills them in!
By Kevin Song
I'm a student at UT (that's the one in Austin) who studies things.