# Vector Multiplication for Programming

#### WeinSim

Alright, so I want to program a Ray Tracing Rederer for which i need to do some math. Specifically, I need to check for the intersection of a sphere and line. So I looked up the wikipedia article and got the formula. However, it involves multiplying to 3d vector with one another. I've heard about the dot product / cross product of vector in 2d before, but none of those are what I want. If I remember correctly, those are only measures for how alligned two vectors are. And I've tried it with 3d vectors and it seemed to be the same thing. Now, in 2d, you can just use imaginary numbers to calculate [x1 y1]*[x2 y2] = [x1x2-y1y2 x1y2+y1x2], and I tested similar apporaches in 3d, too, but none of them seemed to work. So how exactly is one supposed to multiply two 3d vectors in a way that makes sense for the equation?
Here's an image of the wikipedia article. As you can see, in the final equatoin you have to multiply / square vectors, which, as I already said, I have no idea how to to. (Not that addition / subtraction of vector is no problem) #### Idea

multiplication is just the dot product of two 3d vectors

the square refers to the square of the magnitude of a vector which is the same as the dot product of the vector with itself