Hi,
I am just brushing up on Grasshopper. Basically, I want to subdivide a surface, and then work my way inward to make various things, like often building windows and whatnot are made, BUT, the trick of it is: I want to be able to measure in by real world dimensions.
Say, I want it to be say, 2mm or 2 meters in from the edge–instead of doing trial and error trying to using a domain multiplied by various values, using 0 to 1.
For a lack of a better way, I have been using and moving vertexes along vectors to accomplish a similar thing, which seems silly. In a way, I want to zero it, and Remap it, in real-world units.
So, another words, if the top surface is 50x200, I want to be able to measure in 5mm from the top and bottom, and then 15mm from each side. So, the result is Reparameterized from 0 to 170 for x, and 0 to 190 for y.
What is the best or at least an easy way to do this?
This is the problem example. I solved it, but it was pretty complicated. What I wanted to do was to reference the top surface, and then using a border that was measured from the sides 5mm in from the top and bottom, and then I wanted to leave a 12mm gap from the bottom. All of this was done with vextexes, some dispatch, and some deconstructing vertexes and then modifying the values, and reconstructing them to make surface planes.
(The surfaces are lifted a bit so you can see them.)
If Reparameteized Domains can only take from 0 to 1, I had idea…
I often mess with Arduinos, and they use have a map statement which, is a simple one-liner, which scales variables. It would seem that a remapped domain thing could be made in such a fashion, for scaled variables. In other words, a function could be made to map the real world units–back into the Reparamatized domain. Something like that. Though, the actual size of the Domain would need to be measured to plug in the values.
[The small bit of code is there, it’s so handy, I have both integer versions for speed, and floating point versions for more accuracy, well, on the Teensy 4,1, anyway. LOL!]
Please ignore the original code.
long map(long x, long in_min, long in_max, long out_min, long out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
[The components solution I used solve for 5mm in from top and bottom, 15mm in from sides, 12mm for the bar between rectangle surfaces–and however many surfaces I want, but it’s inelegant, to state the least.]