Spatial geometry 4
Last updated
Last updated
Beyond basic arithmetic, in higher dimensions we define two very useful vector operations, namely the dot and cross products. The geometric idea of both is related to the notion of projection ie. dropping and raising perpendiculars, respectively.
The dot product between two vectors and is defined in pre-university education as
i.e. the product of both vector lengths times the cosine of the angle spanned between them.
From the right hand side we can conclude that the result of this operation is a scalar, because vector lengths and the cosine are merely numbers.
A more common way to compute the dot product, without trigonometry, is to use the vectors’ components directly
i.e. the sum of pairwise component products. Again we can observe that the result is a scalar.
Do note from the above expression that the dot product of a vector with itself equals its length squared
In this sense, the dot product conveys something about lengths, but squared!?
Combining the above equations gives us the ability to compute the angle between two vectors using
i.e. first we normalize the two vectors, then we compute their dot product, using their components, and finally take the inverse cosine. The “angle” component is exactly a wrapper of this logic.
If two unit vectors are parallel their dot product is one, because the cosine of zero is one. If they are square their dot product is zero, because the cosine of 90 degrees is zero. If the dot product is positive, then the two vectors point ±90 about one another, we may say they are “kind of aligned”, while beyond they point “kind of against one another”. These are observation derived by examining the cosine function and interpreting the values in the trigonometric equation of the dot product.
Projections are so important in geometry, and algebra, that this worth remembering if nothing else. An interesting result of getting familiar with the dot product is that their use gets rid of trigonometry i.e. there is no need to consider transcendental functions such as the cosine, but only additions and multiplications!
Let’s now use the dot product’s sense of projection. Assume we have a line segment defined by points “P” and “Q” as well as a third point “G”, anywhere in space. We aim to compute the projection of point “G” on the line; let’s call it “B”.
Inverse of Linear Interpolation
Directionality and Containment
Geometric Sliders
.
Consider for a second the units of the dot product. Well it feels like area doesn’t it? To make the dot product more geometrically intuitive I suggest we consider one of the two vectors involved as being a unit vector, say becomes
The dot product represents “the projected length of a vector upon a unit vector”. In the figure below, we project vector on the unit vector and note the projected length with . From trigonometry we express the cosine as: i.e. the adjacent over the hypotenuse. With a bit of rearrangement
Then we sneak in a unit such that and note that
Thus we rewrite this as . Finally, this is just
Therefore, the dot product of a vector onto unit vector equals the projected length , also known as the “signed distance”, because it can be either positive or negative. It is easier to understand where the sign comes from if you consider the trigonometric form of the dot product, where the vector lengths are by definition positive but the cosine can be either way.
Moreover, the vector is the projected image of the vector in the direction of . We may expand this to . This “sandwich” product is characteristic of projections. Finally, we can also rewrite this as by expanding the normalization of twice.
We can also compute the perpendicular vector with length equal to the height of the triangle as . So if we have two vectors, as long as they are not parallel, we can create an orthogonal and unit length pair of vectors, and , that describe a plane in 3D. We call those orthonormal basis vectors. Just like the need of a spatial metric is kind of optional, orthogonality is also an type of optional structure we apply to geometric operations just because of convenience.
First we compute the line segment vector , then we define the vector from the start point of the line to the external point . Now we can use the dot product to find the distance from “P” along “u” where the projection point is situated . This is a straight forward application of the dot product!
We also computed in a roundabout way, and displayed it in the text box. What is interesting about this value is that is captures the ratio of mixture discussed in the linear interpolation section earlier.
The value answers the question: How much of and is present in in the sense of mixing ratios? Well, and respectively.
In addition, we can answer questions such as: Is a point “B” ahead or behind point “P” along the line segment? Well, if is positive then we are ahead; if negative we are behind. We can also answer the question: Is point “B” contained with the line segment spanned by and ? Well, if is within the unit [0, 1] range then yes, otherwise it is outside the segment. This demonstrates the idea of the “signed distance” and its uses i.e. inferring magnitude but also directionality.
Another way to think about this construction is as a geometric “slider” component; one that lives in the viewport as opposed to the visual programming interface. Point “G” becomes the handle of the slider and we can use the output value for our expressions. In earlier forms of visual programming we used to create sliders using this technique.