Skip main navigation

attractor point

Glenn demonstrates a common way of manipulating geometry in a point list through something called an Attractor Point.
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.
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.
So, select the attractor point creates my point, matrix C.
And then I can see my printout. And the numbers go from 11 point something down to one point something is the lowest.
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.
So let’s do something with that, that distance generator.
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.
And we’ll see what that generates.
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.
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.
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.
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.
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.

check your knowledge

[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

import rhinoscriptsyntax as rs

#create an empty list
ptList = []

#input a point to use as an attractor
attrPt = rs.GetObject('select an attractor point',rs.filter.point)

#incremental loop to generate points
for 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.AddTextDot((x,y,z), (x,y,z))

#save point values in a list

#loop through point list and print out index number and values
for i in range(len(ptList)):
# print i, ':', ptList[i]
# rs.AddTextDot(i, ptList[i])

#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)

This article is from the free online

Design Computing: 3D Modeling in Rhinoceros with Python Rhinoscript

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education