Interaction between Vectors – Example 6.3

06_02_04A 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. 🙂 06_02_step01A 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. 06_02_step02A 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. 06_02_step02C 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.

06_02_step03B 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. 06_02_step04A

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.. 06_02_variationsB Here are the isometrics with geometry extruded and colored based on vector length… 06_02_variationsA And finally, a screenshot of the overall script… 06_02_script

Click here to Download GH Script