10.014 CTD
  • Overview
  • Schedule
  • Administrative
    • Accessing Rhino remotely
    • Rhino for Mac
  • ASSIGNMENTS
    • Dates and rubrics
    • Generative design
      • Generative design
    • Parametric design
      • Parametric design
    • Simulated design
      • Simulated design
      • Simulated design
  • SESSION 1B
    • Computer Aided Design
    • Ranges and expressions 1
      • Ranges and expressions 2
      • Ranges and expressions 3
      • Ranges and expressions 4
      • Ranges and expressions 5
      • Ranges and expressions 6
  • SESSION 2A
    • Visual programming 1
      • Visual programming 2
      • Visual programming 3
      • Visual programming 4
    • Associative modelling 1
      • Associative modelling 2
      • Associative modelling 3
  • SESSION 2B
    • Logical Patterns 1
      • Logical patterns 2
      • Logical patterns 3
  • SESSION 3A
    • Spatial geometry 1
      • Spatial geometry 2
      • Spatial geometry 3
      • Spatial geometry 4
      • Spatial geometry 5
      • Spatial geometry 6
      • Spatial geometry 7
    • Curve geometry 1
      • Curve geometry 2
      • Curve geometry 3
      • Curve geometry 4
  • SESSION 3B
    • Surface geometry
    • Parametric modelling 1
      • Parametric modelling 2
      • Parametric modelling 3
      • Parametric modelling 4
  • SESSION 4A
    • Information nesting 1
      • Information nesting 2
      • Information nesting 3
    • Data landscapes 1
      • Data landscapes 2
      • Data Landscapes 3
      • Data landscapes 4
  • SESSION 4B
    • Mesh geometry 1
      • Mesh geometry 2
      • Mesh geometry 3
  • SESSION 5A
    • Space and time 1
      • Space and time 2
    • Modelling entities 1
      • Modelling entities 2
      • Modelling entities 3
  • SESSION 5B
    • Multibody dynamics 1
      • Multibody dynamics 2
    • Material elasticity 1
      • Material elasticity 2
      • Material elasticity 3
  • SESSION 6A
    • Form-finding 1
      • Form-finding 2
      • Form-finding 3
      • Form-finding 4
  • SESSION 6B
    • AI Image generation 1
      • AI Image generation 2
      • AI Image generation 3
  • APPENDIX
    • Spirograph 1
      • Spirograph 2
    • Curves
    • Swarm Intelligence 1
      • Swarm Intelligence 2
    • Hybrid programming 1
      • Hybrid programming 2
Powered by GitBook
On this page
  1. SESSION 3A
  2. Spatial geometry 1

Spatial geometry 4

PreviousSpatial geometry 3NextSpatial geometry 5

Last updated 8 months ago

Spatial Operations

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.

Dot Product

The dot product between two vectors u=[xu,yu,zu]u = [x_u, y_u, z_u]u=[xu​,yu​,zu​] and v=[xv,yv,zv]v = [x_v, y_v, z_v]v=[xv​,yv​,zv​] is defined in pre-university education as

u⋅v=∣u∣∣v∣cos(a)u \cdot v= |u| |v| cos(a)u⋅v=∣u∣∣v∣cos(a)

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

u⋅v=xu∗xv+yu∗yv+zu∗zvu \cdot v = x_u * x_v + y_u * y_v + z_u * z_vu⋅v=xu​∗xv​+yu​∗yv​+zu​∗zv​

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

u⋅u=xu2+yu2+zu2=∣u∣2u \cdot u = x_u^2 + y_u^2 + z_u^2 = |u|^2u⋅u=xu2​+yu2​+zu2​=∣u∣2.

In this sense, the dot product conveys something about lengths, but squared!?

Trigonometry

Combining the above equations gives us the ability to compute the angle between two vectors using

a=cos−1(u⋅v/∣u∣∣v∣)=cos−1(u^⋅v^)a = cos^{-1} (u \cdot v / |u| |v|) = cos^{-1}(\hat{u} \cdot \hat{v})a=cos−1(u⋅v/∣u∣∣v∣)=cos−1(u^⋅v^)

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.

Projection

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 uuu becomes u^\hat{u}u^

The dot product represents “the projected length of a vector upon a unit vector”. In the figure below, we project vector vvv on the unit vector u^\hat{u}u^ and note the projected length with sss. From trigonometry we express the cosine as: cos(a)=s/∣v∣cos(a) = s / |v|cos(a)=s/∣v∣ i.e. the adjacent over the hypotenuse. With a bit of rearrangement s=∣v∣cos(a)s = |v| cos(a)s=∣v∣cos(a)

Then we sneak in a unit such that s=1∗∣v∣cos(a)s = 1*|v|cos(a)s=1∗∣v∣cos(a) and note that ∣u^∣=1|\hat{u}| = 1∣u^∣=1

Thus we rewrite this as s=∣u^∣∣v∣cos(a)s = |\hat{u}||v|cos(a)s=∣u^∣∣v∣cos(a). Finally, this is just s=u^⋅vs = \hat{u}\cdot vs=u^⋅v

Therefore, the dot product of a vector vvv onto unit vector u^\hat{u}u^ equals the projected length sss, 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 u^∗s\hat{u} * su^∗s is the projected image of the vector vvv in the direction of uuu. We may expand this to u^∗(v⋅u^)\hat{u} *(v \cdot\hat{u})u^∗(v⋅u^). This “sandwich” product is characteristic of projections. Finally, we can also rewrite this as u∗(v⋅u)/(u⋅u)u * (v \cdot u)/ (u \cdot u)u∗(v⋅u)/(u⋅u) by expanding the normalization of uuu twice.

We can also compute the perpendicular vector www with length equal to the height of the triangle as w=v−u^∗(v⋅u^)w = v - \hat{u} * (v \cdot \hat{u})w=v−u^∗(v⋅u^). So if we have two vectors, as long as they are not parallel, we can create an orthogonal and unit length pair of vectors, u^\hat{u}u^ and w^\hat{w}w^, 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.

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!

Closest Point to Line

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”.

First we compute the line segment vector u=Q–Pu = Q – Pu=Q–P, then we define the vector from the start point of the line to the external point v=G–Pv = G – Pv=G–P. Now we can use the dot product to find the distance from “P” along “u” where the projection point is situated B=P+u^∗(v⋅u^)B = P + û * ( v · û )B=P+u^∗(v⋅u^). This is a straight forward application of the dot product!

Inverse of Linear Interpolation

We also computed t=(v⋅u)/(u⋅u)t = (v \cdot u)/(u \cdot u)t=(v⋅u)/(u⋅u) in a roundabout way, and displayed it in the text box. What is interesting about this ttt value is that is captures the ratio of mixture discussed in the linear interpolation section earlier.

The value ttt answers the question: How much of PPP and QQQ is present in BBB in the sense of mixing ratios? Well, 1−t1 - t1−t and ttt respectively.

Directionality and Containment

In addition, we can answer questions such as: Is a point “B” ahead or behind point “P” along the line segment? Well, if ttt 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 ppp and qqq? Well, if ttt 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.

Geometric Sliders

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 ttt for our expressions. In earlier forms of visual programming we used to create sliders using this technique.

27KB
3A_2_LineClosestPt.gh
Dot product projection
Drawing
Drawing