3Д БУМ

3Д принтеры и всё что с ними связано

The Cross (or Vector) Product

The cross product can also be useful. Calculating the cross product of two vectors yields a vector that is perpendicular to both of them. This can be used to find vectors that are normal, or perpendicular, to a surface. This is done often in 3D programming to calculate the light­ing normals. The normals used for lighting purposes are unit vectors that must be perpendicular to the surface that is being lit. The cross product comes in handy when trying to find these values.

The cross product equation expands to the following: uxv = (y1z2-z1y2)i- (x1z2-z1x2)j+(x1y2-y1x2)k where i, j, and k are the vector components for the x, y, and z axes, respectively. As you noticed, it will not work on two­dimensional vectors, so three-dimensional vectors are used instead.

Check out Figure 1.21 for an example.

uxv (1,5,2) x (2,1,3)

(5 x 3 -2 x 1)/’- (1 x 3-2 x 2)/+ (1 x1 -5×2)k =

(13,1-9)

Figure 1.21 Calculating the cross product. The resultant vector will be orthogonal (perpendicular) to both of the vectors used in its calculation. You can verify this by taking the dot product of each of the vectors by the result. You will find you get a value of 0, meaning the vectors are orthogonal, both times.

Для любых предложений по сайту: [email protected]