Grasshopper

algorithmic modeling for Rhino

Affecting A Grid With An Attractor Curve But To One Side Only

Hello All,

We are strategizing how to come up with a definition we can use to affect a grid with an attractor curve. However we only want to affect one side of the curve and not the other. The question we would like to ask is are there any components you (the community) might suggest to help us out. We have tried googling it for tips but to no success. Any tips out there?

Views: 1991

Attachments:

Replies to This Discussion

The standard approach is to find out for each point in the grid whether it is to the left or the right of the line. There are several ways to do this:

  • In 2D or 3D, if the line is vertical, simply check to see whether the point.X is less than or greater than the line.X
  • In 3D, if the line has an arbitrary orientation, project the point onto the line, solve the cross product for the projection and the line tangent. If the cross product points 'up', you're on one side, if it points 'down' you're on the other.

Another solution would be to use a rectangle instead of a line, in which case you can test for rectangle inclusion. The rectangle simply needs to be big enough to encompass all points to the left of the boundary.

--

David Rutten

david@mcneel.com

--

David Rutten

david@mcneel.com

Attachments:

Let P be the test point and Pc the point on the Curve closest to P

Now let's define two vectors:

A = P ->Pc

B = tangent to Curve at Pc

IF you take the cross product of these two (A x B), you'll get a vector C, which you can decompose on the plane of the drawing (I'm assuming it's a planar case) test the Z coordinate:

- if positive - P lies on one side of the curve

- if negative - P lies on the other side of the curve

David was faster ;-)

So basically what I wrote above is an elaboration on David's second point.

Cp points "down" so P is one side of the curve

Cr points "up" so R is on the other

I just added a component which automates this (no icon yet):

Inputs are:

  • C = Curve
  • P = Point
  • Pl = Optional Plane. If omitted, the curve plane is used

Outputs are:

  • S = Integer (-1=Left, 0=Coincident, +1=Right)
  • L = Boolean, point is to the left of the curve
  • R = Boolean, point is to the right of the curve

The outputs are slightly superfluous, but this makes it easier to use the answer in whatever way you want.

--

David Rutten

david@mcneel.com

WOw

Idk why my message was not fully posted, but can we download this component somewhere or can we expect it in a future release? Also, thank you to Jacek and David for your help and great work.

It will be available in the next release. Until then you'll have to use the workaround I posted higher up.

--

David Rutten

david@mcneel.com

I am interested how it would work with multiple curves. My partner and I came up with a very inefficient way of doing it manually. The problem is that it is losing the parametric relationship that it should have.

Attachments:

You'd generate one left/right boolean for each point/curve combination, then you have to somehow combine these booleans. You can either use logic gate components for this such as OR and AND, or you can treat the booleans as integers and use Mass Addition. 

--

David Rutten

david@mcneel.com

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service