|
![](/i/fill.gif) |
Hi there,
The answer of Fernando is (of course) completely right. On the other hand I
want to try to give a less mathematical but more "visual" explanation.
Unfortunately I don't have the time right now to trace some pictures for
explanation (and additionally my english language isn't sufficient) but I
will give it a try.
If I start with a too low level, please read it over. I don't know where to
start with the explanation so I start at the very beginning, ok?
*) Vector
As you know, a vector is defined as a set of numbers. Depending on the
dimension we want to work these would be X and Y for two dimensions or X, Y
and Z for three. You may create vectors for any dimension but since we are
talking about POVRay let's start with three.
The notation <X,Y,Z> of a vector might be misleading since every time you
see a vector visualised it is drawn as an arrow. As we know, has as arrow a
starting node and en ending node. But we have only one set of coordinates
<X,Y,Z>!
So where is the other end?
The answer is easy. A vector starts at the origin of the coordinate system
which is <0,0,0> (mostly ;-) )
Now you might say that you have already seen some vectors in mathematical
graphs which did obviously NOT start from the origin. You are right and you
are not. These diagrams are a bit misleading since they skip some
information to be "cleaner". Any vector which does NOT start from the origin
is originally only a part of a vector transformation (e.g. two vectors in a
chain). (I will continue on that in the next section). Transformations on
vectors do some mathematical operations with their coordinates. These
formulas might be proven by mathematicians (is that spelled correctly?) or
other freaks. In this text I don't want to use any formula. Just imagine
that this set of functions is well defined like the algorithmic of "1+1=2".
*) Length
The length of a vector can easily be computed. In two dimensions this would
be the legendary formula of pythagoras. The same thing, but just one
coordinate more for three dimensions. Graphically it is simply the length of
our arrow, measured ALONG the vector (not projected).
*) Translation
One of the easiest transformations is the translation. Translating a vector
has nothing to do with language ;-) but is just shifting the coordinates.
That means, that each coordinate of the end point of the vector gets some
number added or subtracted (remember: the starting point stays in the
origin). If we add or subtract two vectors we just add/subtract their
coordinates (X to X, Y to Y and Z to Z).
Now you might ask: "If I translate a vertical cylinder by <1,0,0> it moves
to the right but is still vertical. How can that be if the starting point
stays in the origin?"
The answer is: The cylinder isn't the vector itself. Imagine the cylinder as
a set of <end nodes> of many, many vectors. From all these vectors you see
just the tip. And translating the cylinder is in fact translating ALL these
vectors. So all the vectors move in the same way. No wonder that they
preserve their shape!
So whenever you see a vector NOT starting in the origin it is due to
following reason:
The vector is graphically moved for better clearance. These vectors still
start at the origin but they got graphically moved to show their relation to
other vectors. Most times it would be very confusing if all vectors are
drawn from the origin. You would get a big bundle of arrows, all starting at
the same point, pointing into various directions. It is much easier do draw
if we move the vector's graph to a place where it's relationship is more
obvious. (e.g. to show a vector added to another. This situation is often
shown as a triangle (the two vectors to be added and a third one showing the
result), although ALL vectors should start at 0/0/0).
*) Multiplication
If we multiply a vector with a number (a so-called scalar) we just multiply
all coordinates with this number. This results in a longer vector which
still has the same "orientation" within our three dimensions. Graphically
spoken it just gets longer but doesn't "move".
*) Rotation
Rotation isn't really complicated but hard to explain without any picture.
One word to the rotation in POV. Whenever you rotate an object in POV you
have to give a rotation vector. This might be misleading since it is a
shortcut for three rotations in sequence! If you rotate an object by
<10,20,30> then POV rotates the object first 10 degrees around the X axis,
then 20 around Y and finally 30 around Z. This rotation is always done
around an axis.
To imagine rotation you best use a triangle. You remember these triangles
you used/use in school? Take the long base as an axis. Take the left hand
side as the vector (starting in the lower left corder of the triangle which
is our origin). Rotate the triangle around it's base (hold the left and
right edges with your fingers) to see how you vector rotates in space.
Always keep in mind that these rotations (except some special functions in
POV) rotate around an AXIS (either X, Y or Z). So if your vector has some
abitrary angle to the axis the movement might get complex.
A small example: Imaging a man we modelled in POV. This man stands still in
the origin (of the standard POV coordinate system) and we are behind him
(like at <0,0,-3> or so) Now we rotate him about <90,90,90>. This gets fun!
1) rotation around X would clap the man onto his face since the X coordinate
is the one running from left to right. If we turn this by +90 degrees the
man falls straight forward onto his nose.
2) rotation around Y rotates the man like an helicopter to the "right".
After 90 degrees he lies in front of us (still on his nose), feet to the
left, head to the right.
3) finally, rotation around Z by 90 degrees brings our poor man again into
the upright position but facing to the right. It would have beed easier if
he just would have turned around to the right! (like rotating by <0,90,0>)
*) Vector products
As you may have already encountered there are at least two vector products.
The cross product and the dot product.
.) Cross product
Beside the mathematical definition of Fernando I will try to give a
graphical explanation so that you get a picture in your mind.
Imagine two vectors in the X/Z plane of POVRay. These vectors would "lie
flat on the floor". Since both start in the origin they share their starting
points. These two vectors "span up" a plane (not an infinite plane like the
POV primitive). Just imagine a sheet of paper lying flat on your desktop.
Imagine the lower, left corner is the origin and the lower horizontal and
left vertical edge are your vectors. This is like these vectors form a flat
area (depending on the angle between these vectors your area is more or less
rectangular).
Ok. But what is the cross product?
The cross product is a vector standing perpendicular onto these two vectors
(or in other words perpendicular onto the sheet of paper). There are only
two possible ways a vector can be perpendicular on BOTH vectors. Spoken in
words of our sheet of paper this would mean straight upward (coming out of
your desktop towards the ceiling) and downwards (going through the desktop
downwards to the floor). This would be the direction of the resultant
cross-vector product. It's length would be as long as the CONTENT of the
area defined by the two starting vectors. Again, remember your sheet of
paper. It's size is about (29cm to 31cm or so for A4). So if our starting
vectors are of length 29cm and 31cm and have an angle of 90degrees between
them (as it is given for our paper) then the resultant vector (yes the
result of the cross product is a vector) would have a length of 29*31 = 899
(damn, now I DID use a formula). Note that if the angle is not 90 degrees
these visualisation is still valid, just the content is the one of a
parallelogram.
What about its direction? ("up" or "down"). Well, this is defined by the
order of the arguments. If vector1 cross vector2 results in an upright
vector, the reverse thing vector2 cross vector1 results in a downward
directed vector. (Mathematically spoken: the angle between the first and the
second vector must be "in mathematical counting direction" (which is
counterclockwise, right, up, left) to result in an upright vector). Please
note that "up" and "down" depends on the rotation of the whole thing. This
example is spoken for vectors in the X/Z plane of POVRay. You may rotate
this "picture" in any way but the cross product is always perpendicular to
the two vectors.
.) Dot product
The dot product (also called scalar product) is not so easy to explain in a
graphical way, but it is not impossible. It also starts with two "input"
vectors, similar to the cross product example.
The main advantage of the dot product is that it includes the ANGLE between
our two starting vectors. The result of the dot product is a number (a
scalar, thus the name). This number can be seen as the length of a vector
whose direction is something we don't really care (for now!). This sounds
useless since the purpose of using a vector IS having it's direction. But I
will come to this lateron.
Mathematically spoken we get the dot product if we do the following:
1) get the length of our first vector
2) get the length of our second vector
3) multiply those lengths
4) get the angle between the vectors
5) compute the COSINE of this angle
6) multiply the cosine with the result of the length multiplication
This is not really easy, so for what do we need this?
The trick is that on vector-basis this computation is VERY easy to do!
we have the dot product. That's easier than step1 to 6 isn't it?
The BIG advantage is that we know that in the result there is somewhere the
ANGLE between our vectors. So whenever we need the angle between two vectors
(since all vectors start at the origin we always have an angle) we can
easily compute the dot product and divide it by the lengths of our vectors.
The result is then the cosine of the angle.
Another very useful thing is projection. Imagine a light source illuminates
out vectors. The light source is placed so that it is perpendicular to one
of our vectors. So all light-rays fall with an angle of 90 degrees straight
forward onto our vector. Now the other vector comes into the scene and it's
shadow drops exactly onto the illuminated vector. This is called a
projection. The vector causing the shadow is PROJECTED ONTO the other
vector. By using the dot product (since it already takes the angle into
count) we can easily figure out the LENGTH of the SHADOW. Since we know that
the shadow is ON the illuminated vector we also know the direction of the
shadow.
That's it!
I hope you can understand my english and this text helps a bit in vector
algebra.
Let's see if this kicks off a discussion ;-)
best regards
Post a reply to this message
|
![](/i/fill.gif) |