Interaction between Vectors and Vector Addition – Example 6.3

In the previous examples 6.1 and 6.2 we looked at some simple vector fields. The first had only one set of vectors, while the second had multiple controls for the vectors, but the vectors did not interact with each other. To create truly dynamic geometry and also to prepare ourselves for some later examples where our objects are moving, it is important to understand how vectors can interact with each other to create dynamic and potentially surprising systems.

In this example, I will have two general kinds of vectors. The first will be a general vector direction that will be applied to the whole field. We can adjust the overall direction and strength of this, or set the strength to zero to turn it off. The second set of vectors will be vectors created by various “emitter” points. There can be any number of these points, but in this particular example they all have the same strength and direction. It would be possible to have multiple strengths and directions for different classes of points… this just would require more coding and vector addition. 🙂

Video tutorial below followed by written instructions:

Step One – Setup A Vector Field in a Single Direction

The first thing we are going to do is randomly populate a region defined by a closed curve drawn in Rhino with a variable number of points using Pop2D, and we will then flatten our list of points. Before we bring our emitter points into play, we are going to set an overall direction of the field.

To do this, we simply Move our points in the Unit X direction with an adjustable numerical input from a number slider, which will determine the “strength” of the overall field. We then use the Vector 2Points component to create a vector between the original and the moved points.

Now we want to rotate the vectors to set an initial direction for the overall force. To do this we use the Vector Rotate component (not the standard rotate…that works only for geometry). For this you input the Vector you want to rotate–the one we just drew–an axis of rotation, in this case the world “Unit Z” axis (note you don’t have to rotate the vectors around their own base point since technically they have no spatial location, only direction and speed). The last step is to input an angle, which I did in degrees, but you have to make sure to set the angle input to degrees, since Radians is the default.

To preview your vectors, you can optionally add a Vector Display component with your initial point cloud input into A as anchor points, and the vectors themselves going into the V input.

Step Two – Setup Vectors Emitted from Single Points

We are going to temporarily forget what we just did, and now concentrate only on the vectors for our emitter points. These are points we draw manually in Rhino somewhere within our point population region. We put all of our points into a point parameter container, which we must graft since we want the same set of operations to happen to each individual point in the set.

Next we define the vectors using Vector2P between the individual points and our field points (Pop 2D points). This will give the vector direction quite easily, but we want to change the Vector strength or Amplitude based on distance from each emitter point. In this particular case we want the vectors to get weaker as you get further from the emitter points, similar to the logic we employed in Example 6.2.

To do this, we measure the Distance between each emitter point and the point cloud points. Using the Bounds component I find the domain between the shortest and longest distance, after which I Remap these distances based on a variable parameter which will affect the rate at which the strength of my emitters will decay, or its ‘falloff’. I now subtract this from another Slider (my point Strength) and eliminate any negative values with the Max component set to “0”.  This number goes into my vector Amplitude.

I am now going to Flip the matrix, which will allow me to sum the vectors… but we can do this after the next step as well. Before summing I put a simple Boolean Toggle–True/False–which allows me to dispatch the numbers and Reverse the vectors, making them negative if the toggle is false, and keeping them positive if true. If you do a vector display at this point only for these vectors, it will look something like the image below, which shows variations based on three different emitter point strengths.

Notice the vectors are not yet interacting with each other, but in the first variation, there are regions where the “effect” of the points overlaps. It is here that the vectors will sum together to create a new vector. In the second variation with weak emitters, the overlap is minimal. In the last one where the vectors are strong, the overlap is substantial, and summing the vectors will totally change the pattern.

Step 3 – Sum the point vectors (Emitter Vectors)

Summing vectors in Grasshopper is quite easy. You just add them together as if they were numbers. I spent a long time looking for a Vector Addition component but this is not necessary and a normal Addition component will do to sum vectors. You can also use the Mass Addition component which allows you to sum a whole set of numbers in a single “List” This is why I added the flip matrix component in the previous step. It basically puts Item 0 of each list (the emitter points) together, which allows us to then easily sum them together. So in effect the vector associated with each of our field points is grouped together and then added. The result of a vector summation can be seen below.

 Step Four – Sum the Overall Field Vectors with Individual Emitter Vectors

Now we sum the results of the point vector summation created in Step 2 with overall field vectors created in Step 1. Just use a simple Addition component to add the vectors in a container from Step 1 with the vectors in a container from Step 2. Depending on your respective field strengths, the results will look something like below if you use the Vector Display component.

Additional Steps – That was most of the new stuff. A few additional steps could be done here to use our vectors to manipulate geometry. For this example, I used the Orient component to orient an elongated triangle that I drew in Rhino to the vectors. It really could be any shape, a rectangle, a bird… The orient command is explained in more detail in Example 5.2 but you can look at the overall image of the script below to see how this was done, using the Vector to create a Line which served as the X axis of a new plane. Once I set up triangles oriented to each local vector direction, I Extrude these triangles to create solid geometry.

One last thing I did is that I used the “vector speed” information obtained through use of the Vector Length component  to color geometry based on a color gradient from light to dark blue. I also changed the Extrude component input to vary the height of each extrusion based on the vector’s local strength. The light blue geometry is in an area with low vector speed and the dark blue has high vector speed. Below are images showing the results of nine variations in both isometric and plan view.

And finally, below is a screenshot of the overall script which will show you how all the parts are working together.

Downloads

If you would like to have the completed Grasshopper script for this definition, along with two other completed scripts (Single-Point Vector Field and Multi-Point Vectors for Line Distortion) please consider supporting this blog by purchasing the completed definition from the link below.

Comments

9 responses

  1. Verônica Avatar
    Verônica
    1. josclag Avatar
      josclag
  2. Verônica Avatar
    Verônica
    1. Shi Chen Avatar
      Shi Chen
  3. manvj Avatar
  4. jirehdagdag Avatar
    1. josclag Avatar
      josclag
  5. Megan Avatar
    1. josclag Avatar
      josclag