Scalar Point Vector
Scalar Point Vector
Force has a direction.
Scalar Point Vector
Scalar Point Vector
Velocity has a direction; speed does not.
u + v = (–1, 0, 1) + (0,–1,–2) = ([–1]+0, 0+1, 1+2) = (–1, 1, 3).
3u = 3(–1, 0, 1) = (3·[–1], 3·0, 3·1) = (–3, 0, 3).
u · v = (–1, 0, 1) · (0,–1,–2) = [-1]·0 + 0·1 + 1·2 = 0 + 0 + 2 = 2.
Remember that the dot product of two vectors is a scalar.
|u| = |(–1, 0, 1)| = sqrt[(–1)2 + 02 + 12] = sqrt[1 + 0 + 1] = sqrt[2].
Remember that the length of a vectors is a scalar.
In the previous part, we found |u| = sqrt[2]. So now we multiply 1/sqrt[2] by u:
[1/sqrt[2]] u = [1/sqrt[2]] (–1, 0, 1) = ([1/sqrt[2]]·[–1], [1/sqrt[2]]·0, [1/sqrt[2]]·1) = (–1/sqrt[2], 0, 1/sqrt[2]).
An easy check: a correct answer must have length 1.
We add a 4th coordinate equal to 1: (1, 2, 3, 1).
Homogeneous form allows us to express all the usual transformations in the same format: as a 4×4 matrix, where a transformation is applied using 4-D matrix-vector multiplication, and the final answer is determined using a 4th-coordinate division.
The transformation is represented as a 4×4 matrix. The matrix stored will be the current matrix multiplied by the following.
(
1 0 0 2 0 1 0 3 0 0 1 4 0 0 0 1 )
glPushMatrix(); glColor3d(1., 0., 0.); // red; this can go anywhere BEFORE the drawobject call glTranslated(3., 4., 5.); // Comes BEFORE rotate & scale glRotated(20., 0., 0., 1.); // Last 3 params can be anything but 0, 0, 0 glScaled(3., 3., 3.); drawobject(); glPopMatrix();
Immersion means filling the senses with the output of the VR environment. Generally, we refer primarily to the visual sense, in which case immersion means filling the user’s vision with the visual output from the VR display, so that essentially nothing of the “real world” can be seen.This is generally done either by surrounding the user with large screens or using a head-mounted display that blocks the real world.
Presence is the users’ feeling that they are inside the virtual environment. Immersion helps create this by blocking external stimuli that would remind users where they actually are.
In selection mode, OpenGL does no rendering; rather, names are inserted into the pipeline along with primitives, and OpenGL creates a list of the names of those primitives that were not discarded during clipping.To do picking via selection mode, set the clipping region to be a very small rectangle around the pointing-device location. Give each object a name, and send this name through the pipeline with each primitive making up the object. Then the list returned by OpenGL is the list of all objects that are at the mouse position. The closest such, if any, is the object picked.
Selection-mode picking works well regardless of how complex the shapes of objects are. Thus, it is more suitable than extent testing when dealing with complex shapes and 3-D objects, whose extents may be difficult to describe.
( |
|
) | ( |
|
) | . |
(
1 0 0 0 0 1 0 0 0 0 1 0 0 0 k 0 ) (
x y z 1 ) = (
1·x + 0·y + 0·z + 0·1 0·x + 1·y + 0·z + 0·1 0·x + 0·y + 1·z + 0·1 0·x + 0·y + k·z + 0·1 ) = (
x y z kz ) .
What will emerge is a 3-D vector. We compute this from the above homogeneous form using a 4th-coordinate division.
(
x y z kz ) → (
x / kz y / kz z / kz ) = (
x / kz y / kz 1 / k ) .
One reason this might a problem is if a widget is copied during the time it is handling a mouse click. For example, for a button, what happens if it is copied while it is depressed? Are there now two depressed buttons?Other answers are possible.
The solution that I used was to disable the copy constructor (and, for the same reason, copy assignment). This is done by declaring the copy constructor private, and then not defining (implementing) it.Note: Strictly speaking, it is enough simply to declare the copy constructor private, whether or not we write the function body. Then nothing except for class members and friends can use it; if these do not use it, then it never gets used. However, since we do not want to use it at all, it is safer to do both: declare private and do not define. This way, it definitely never gets used, even accidentally by our own code. And, in any case, there is no point in writing the function body if we never want to call the function.
Create a widget base class, with virtual member functions for each action that every type of widget should be able to do: draw itself, handle a mouse click, etc. Then actual widget classes will all be derived from this base class. This method allows one to deal with a widget, without knowing what type of widget it is.
If the above scheme is used, then a widget manager can deal with every widget as if it were an instance of the base class. The widget manager does not need to know anything about the properties of the various types of widgets, and new types of widgets can be added without altering the manager.
The transformations occur in what I have named the “vertex processing” phase.
- Model/view
- Used to place objects (and the camera and lights) in the world.
- Projection
- Used to project the scene onto a 2-D plane, usually while maintaining depth information.
- Viewport
- Used to map the projected image into the frame buffer.
glTranslated(0., 0., -3.);This call should occur just before the object is drawn.
glTranslated(0., 0., 3.); // Positive!This call should occur at the beginning of the transformation-setting code.
- View the world
- In interfaces in this category, the action takes place at the location being viewed. Thus, the translation moving all objects out to where they can be seen belongs permanently at the beginning of the transformation-setting code, and so should generally not be included in a saved viewing matrix.
- Move in the world
- In interfaces in this category, the action takes place at the camera location. Thus, the translation moving all objects out to where they can be seen belongs with the other camera motions, and so should generally be included in a saved viewing matrix.
One way to think of a shadow is as the projection of the shape of an object onto another object. Thus, if we generate the appropriate projection, and include it as part of the model/view transformation, then we can use the code that draws the object to draw its shadow as well.That is the basic idea. There are other issues to deal with, of course: coloring the shadow properly, depth-buffering errors, how to project onto a non-planar object, how to clip the shadow so it lies within the boundaries of the object it is projected on, etc.