# attractor point

Glenn demonstrates a common way of manipulating geometry in a point list through something called an Attractor Point.
6
This video’s titled Attractor Point. So one common way of manipulating geometry in a point list is to use something called an Attractor Point. And that’s simply a point that we create within the scene, and that we input. So here I’m inputting a point and saving it in the variable attractor point and then create my point list. And then loop through my point list. And the first thing I’m going to do is measure the distance between each point within that list as I go through the loop one at a time.
53.8
And using a function which we haven’t seen before called rs Distance, and that simply measures the distance between two points in space. So whatever my current point is in my list to the attractor point, and I’m going to save it in the variable distance and then first I’m just going to print it out. So let’s run that.
80
So, select the attractor point creates my point, matrix C.
88.2
And then I can see my printout. And the numbers go from 11 point something down to one point something is the lowest.
100.4
And so what that’s doing is it’s measuring the distance from that point to every point within the matrix C. So if you can imagine a sort of line between all of these points and this list that’s printed out of the distances and makes a lot of sense because the points that I start with here, have a higher value because I might pointless starts its generation over here. So these points are going to have a higher value and then as I get closer to this point, my attractor point, those values are going to go down.
142.3
So let’s do something with that, that distance generator.
148.6
So I could use that to let’s say, create a circle, add a circle on each, using as its origin point, the current point within the list. And then, let’s just start with the sort of, raw distance value.
168.9
And we’ll see what that generates.
178.8
Okay, so it generates a pretty crazy pattern. But if we think about it, it starts to make a lot of sense my circles which are furthest from the attractor point or largest. So their radius, which is that value there and you can see it’s going to go back and intersect the attractor point because that radius value is that distance from that point to that point. So the circumference of that circle’s is always going to touch that attractor point.
218.2
I can undo that. So if we wanted to lessen its effect like we did with the I value and the rotation, I could put a divider in here. So let’s divide it by, let’s say 20 to start with and we could also print out to see what those values are going to be.
250.6
So now, I’m getting a matrix C of circles whose size diminishes as they get closer to the attractor point. And of course this is going to change if I relocate the attractor point, it’s going to have a different effect on the matrix C.
277.6
So, attractor points are a very interesting system that we’ll continue to use in different ways throughout the rest of the course. One thing maybe to work on, to think about if you take the previous lesson which we copied the closed planar curve to the point and then we rotated them based on the eye. How could you use the distance instead to do a rotation? Or another thing might be a scale. How could you use the distance value that you’re measuring from the attractor point to the other points as a way to scale, maybe something besides a circle, that could be a really interesting exercise.
319.2
And you’ll have to like with this, you’re going to have to probably divide the distance value or create some mathematics that get it in the range that are workable. But should be fairly straightforward and would be also a good thing to do for the next assignment.

what’s in this video

In this video I demonstrate a common way of manipulating geometry using an attractor point. During the demonstration I introduce a function that we have not used before in the course—the rs.Distance function.

##### [Pause the video and take a moment to practice using attractor points]
Use the attractor point system in the Nested Loop: 2D Point Matrix code to manipulate the rotational angle of the transformed geometry.

#### tutorial code

#ATTRACTOR POINTimport rhinoscriptsyntax as rs#create an empty listptList = []#input a point to use as an attractorattrPt = rs.GetObject('select an attractor point',rs.filter.point)#incremental loop to generate pointsfor i in range(10): for j in range(10): #define x in terms of i #define y in terms of j x = i y = j z = 0  rs.AddPoint(x,y,z) #rs.AddTextDot((x,y,z), (x,y,z))   #save point values in a list ptList.append((x,y,z)) #loop through point list and print out index number and valuesfor i in range(len(ptList)):# print i, ':', ptList[i]# rs.AddTextDot(i, ptList[i])  ####CREATE TRANSFORMATION OF GEOMETRY#### #measure distance between attractor point and current point in the list distance = rs.Distance(ptList[i], attrPt) print distance/20 #create circle using distance value as radius rs.AddCircle(ptList[i], distance/20)