Skip main navigation

New offer! Get 30% off your first 2 months of Unlimited Monthly. Start your subscription for just £29.99 £19.99. New subscribers only. T&Cs apply

Find out more

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

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now