First, the basics. A vector in 3D space is a piece of line. It's defined by 3 numbers, let's call them dx,dy,dz. dx its length along X axis, dx - along Y, dz - along Z. It's important to understand that a vector doesn't have a fixed location in space, but its slope and lengths are fixed. | ![]() |
Lines: A line can be defined by a point and a vector. The vector would define the slope of the line and the point - its location in space - its "starting" point. Geometrically, if you put the end of the vector in the starting point, the vector will lie on the line. The line equation can be written as P = X1,Y1,Z1+N*LV Or, in expanded form P.x = X1+N*LV.dx P.y = Y1+N*LV.dy P.z = Z1+N*LV.dz Are you starting to get the hang of these short form equations? Where X1,Y1,Z1 is the point where the line "starts", LV is the vector that defines the line's slope and N is some number. But using different numbers for N you get different points on the line. Here's something to illustrate. Say you have an edge that begins at point X1,Y1,Z1 and ends and point X2,Y2,Z2. That piece of line will be defined by a starting point X1,Y1,Z1and vector (X2-X1,Y2-Y1,Z2-Z1). So the equation will be: P = X1,Y1,Z1+N*(X2-X1,Y2-Y1,Z2-Z1) Important thing to note is, in this case at N=0 , P will be X1,Y1,Z1(beginning of the edge). At N=1, P will be X2,Y2,Z2 (end of the edge). The values of N from 0 to 1 will give you points on the edge. | ![]() |
Planes: OK, now it's the time to introduce another vector operations - dot product. The dot product of two vectors is a number. It is: V1*V2=V1.dx*V2.dx+V1.dy*V2.dy+V1.dz*V2.dz It has this property: V1*V2 = |V1| * |V2| * cos (angle between V1 and V2) I.e. it's the cosine of the angle between two vectors multiplied by the length of both. Now back to the planes. the plane can be defined by a vector and a point as well. Like in case of the line the vector defines the slope of the plane and point - it's position, but it's a bit different than in case of the line. Geometrically, the vector is PERPENDICULAR to the plane. The plane equation in this case is (X-X1,Y-Y1,Z-Z1)*NV=0 Where X1,Y1,Z1 is the point that defines the plane and NV is the vector that defines the plane. X, Y and Z are the points on the plane. This equation can also be written as (X,Y,Z)*NV=D Where D is D=(X1,Y1,Z1)*NV The vector NV is typically normalized (has a length of 1) and called plane's NORMAL. It's used in just about every operation involving planes. | ![]() |
Now, one more vector operation (the last one), called cross product. It's defined as V1 x V2 = (V1.dy*V2.dz-V2.dy*V1.dz, V2.dx*V1.dz-V1.dx*V2.dz, V1.dx*V2.dy-V2.dx*V1.dy) Or, a in a bit clearer form: V.dx=V1.dy*V2.dz-V2.dy*V1.dz V.dy=V2.dx*V1.dz-V1.dx*V2.dz V.dz:=V1.dx*V2.dy-V2.dx*V1.dy The cross product of two vectors is a vector. Geometrically it is a vector, perpendicular to both of the starting vectors and oriented in such a way that three vectors V1, V2 and V1XV2 have "right" orientation. "Right" means- if you make a fist with your right hand and then straighten thumb, index and middle finger, if thumb, index and middle fingers were vectors, they would have "right" orientation. This term also applies for a coordinate systems. The "right" coordinate system is such system in which X x Y = Z. That's the coordinate system used everywhere. | ![]() |
Or, for instance, you need to find the shortest distance from a given point to a plane (surface). Defined by a point PP and a normal NV. That'll be a distance from P to P' (on the picture), where P-P' is perpendicular to the plane. Obviously, it's equal to the distance PP-P''. From the triangle P-P''-PP: Dist=cos(angle between PP-P and PP-P'')*length(P-PP) The angle between PP-P and PP-P'' is equal to angle between PP-P and NV (as normal is perpendicular to the surface by definition, thus it lies on PP-P''). Now let's see, the dot product between NV and vector PP-P will be (note that you get the vector P-PP by subtracting of PP from P. So it's P-PP where - is a minus) NV*(P-PP)=|NV|*|P-PP|*cos(angle between P-PP and NV) |P-PP| is the length of the P-PP. |NV| is 1 (since it's a normal). Now look at the previous expression. It turns out to be exactly it. So the distance will be: Dist=NV*(P-PP) Actually, even better. This dot product will be positive if the point is "in front" of the plane (on the side where normal points), negative if it's on the back of the plane and 0 if the point lies on the plane. | ![]() |