Grasshopper

algorithmic modeling for Rhino

a couple questions about curves and their domains:

1. i have a scenario where I am referencing points along a curve based on a domain value plus AND minus a double and for some reason this sometimes tends not to land on the curve itself. my hunch is that when I add or subtract from the domain I may end up outside it and that's what may be causing the anomaly. if that's so, is there a quick way to enforce a wrap around - if outside the domain the difference is added to the beginning or end?

2. is there a way to retrieve a portion of a curve using domain values as trim points. come to think of it now, I may have gotten this to work in vb a while ago. Is there a way to do this using the ready made components?

thanks all!

Views: 884

Replies to This Discussion

1. This is certainly a possibility. Rhino will be able to evaluate beyond the curve domain, but the component will turn Yellow with a warning when it does that. You could certainly "wrap" the domain around. Modulus division will help here... (x%z)+y where x is the parameter on the curve, y is the minimum value of the domain and z is the maximum value of the domain.

2. Use the SubCurve command, as this sounds like what you want. All of the On_XEvents that result from curve/object intersections will spit back their results with curve domain values, so that might be why in rings a bell from VB
Rather than wrap, you could clamp the domain to the end so that your trimmed sub-curve isn't flipped in the wrong direction.

If (tStart < 0) Then
tStart = 0)
End If

If (tEnd > 1) Then
tEnd = 1)
End If

This VB script deals with trims by curve domains.

Dim tDomain As New OnInterval(tStart, tEnd)
inCrv.Trim(tDomain)
thanks for both of your help. I actually don't need the subcurve just yet but will in the future. now to wrap my head around the modulus thing. I know it's confused me in the past...


thanks
Modulus is not that complex at all...you have 3 types of division, the first is plain jane, regular old division...the second is "whole number" division (I'm sure it has a technical name, but I just can't remember it) that will only give you the resulting whole number that results from any given division...modulus division will give the exact opposite, or only the fractions of numbers that result. In code they would be forward slash, back slash, and percent symbol, respectively. That's the case for VB and most other languages as well...here's a simple example...

8/3 = 2.66666
8\3 = 2
8%3 = 0.6666

HTH
% should be Mod in VB.NET (third line)

% is valid in C# (also in C++ and Java)
Integer division works a bit differently in C# and VB.NET:
http://tangiblesoftwaresolutions.com/Articles/Division%20in%20CShar...
Thanks for the corrections. That's really odd that I got mixed up with % and Mod considering I code almost exclusively in VB...the expression editor in GH will acknowledge either % or Mod.

The page on modular division in VB is useful, but honestly it kind of annoys me. Its small little idiosyncracies like that that end up in bugs later on down the line. Considering that the VB component in GH does not have Option Strict on, there's a load of potential mistakes that could be there. Good to know.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service