## Interaction between Vectors – 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 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. đź™‚ **Step One –Â **The first thing we are going to do is populate a region with a random number of points, which we flatten. 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 X direction with a slider, which will determine the “strength” of the overall field. We use “Vector 2Points” 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 “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 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. **Step Two –Â **We are going to temporarily forget what we just did, and now concentrate only on the vectors for our emitter points. We put all of our points into a container, which we mustÂ *graft* since we want the same set of operations to happen to each individual point in the set. Now we find the vector between the individual points and our field pointsÂ (Pop 2D points). In this particular case we want the vectors to get weaker as you get further from a point, similar to the logic we employed inÂ Example 6.2. We measure the distances, which I am going to remap. The domain of the remap will be variable which will allow me to adjust the falloff or rate of decay of the force. 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 amplitude. I am not 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 this. notice the vectors are not yet interacting with each other, but in the first case, 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 frame 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 point 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). 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 did the flip matrix component previously. It basically puts Item 0 of each list (the emitter points) together, which allows us to sum them. 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 results of point vector summation with overall field vectors.Â Just put the results of the image above into an addition component with our overall point vectors that we drew in the first step and put on the back burner.

**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” command 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. I also put a scale component in to scale my geometry if I wanted. One last thing is I used the vector Speed information obtained through use of the “Vector Length” component Â to color geometry which I extruded,Â with the height related also to theÂ Vector Length. The light blue geometry is in an area with low vector speed and the dark blue has high vector speed.. Here are the isometrics with geometry extruded and colored based on vector length… And finally, a screenshot of the overall script…

Hello! Thank you very much for your tutorials. Very inspiring. I am trying to recreate this example and I think I am missing something… How did you split the vectors between the three anchor points without the closest point component? I can’t make it work without it.

LikeLike

Its conceptually a bit difficult, but you can think of it as each vector influences each point…we don’t divide them up between points. The points are just “test” points to see what the cumulative effect of all the vectors is at that place. (you could have 2 of these test points or 2000)

So in this example, there is one “universal” vector force, which influences each point equally. Which we set up in step one.

There are three “emitter” points where the influence is strong initially, but tapers off to zero. This zero is still accounted for and summed as a vector (albeit zero) at each of the test points. Sometimes the effects of the emmitters overlaps.

At each test point then, we sum up the influence of ALL the vectors to get the resultant vector, which is then used to draw geometry. At many of the test points, the value of some of the individual vectors will be zero.

LikeLike

Hello! Thank you very much for your tutorials. Very inspiring. I am trying to recreate this example and I think I am missing something… It looks like every anchor point will have as many vectors as you set as orientation points. Where did you pick one of the vectors for each point? Thanks

LikeLike

I don’t think he ‘picked’ one of the vectors for each point, he added all the vector into one vector in mass addition. the reason he is able to have one vector in step two (if that is your question) is because he set the maximum as 0 so other vector are appeared to be disappeared.

LikeLike