Domain percentage

Hi;

I’m trying to get the value inside a domain using a slider as a percentage of that domain.
I think I should use remap numbers component but I have no clue on how to do it. In fact I do not understant 100% how this component works.
In the definition here attached I created a domain that goes from -0.45 to 0.45, so what I’m trying to do is as instance try to find the 50% of that domain that is 0, or the 25 % should be -22.5.
Any idea on how could I get this ?

thanks

Joan
domain percentage.gh (5.4 KB)

domain percentage2.gh (11.8 KB)

1 Like

Hi,

you can do it like this…

2 Likes

Default sliders go from 0 to 1 (0% to 100%), which is also the default for ReMap ‘S’ (Source) and ‘T’ (Target) inputs. So typically (not always!) you define a target domain and leave the source alone.

domain%20percentage_2019Oct4a
domain percentage_2019Oct4a.gh (9.6 KB)

P.S. Minor point, I didn’t notice this and obviously it works either way, but more often than not, the ‘A’ input of Construct Domain is the lower bound and ‘B’ is the upper bound, so that as the ‘V’ slider for ReMap goes from 0.0 to 1.0, the result (‘R’) output goes from minimum to maximum.

domain%20percentage_2019Oct4b
domain percentage_2019Oct4b.gh (9.4 KB)

2 Likes

If you want a component check Pufferfish Slide Through Domain component. Also Rhinocommon has a method for that here: https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Interval_ParameterAt.htm
or use components as shown above. You got many good options :grinning:

That is a disingenuous statement @Michael_Pryor. Component count was not the issue here. If it were, @Jakinta’s example can be simplified using expressions of “-x/2” and “x/2” on the Dom inputs, as follows:

domain%20percentage_2019Oct4c
domain percentage_2019Oct4c.gh (5.0 KB)

Care to show us a screen shot of a Pufferfish version with fewer components?

Advocating a plugin (again!) for another trivial piece of code is getting to be a bad habit with you. It is a disservice to those trying to learn Grasshopper, bordering on harassment.

and also if you are just interested in remap math in general check here: http://james-ramsden.com/map-a-value-from-one-number-scale-to-another-formula-and-c-code/

remapping logic is quite interesting

Hi Joseph,

I liked your solution and missed it when I commented, hence my edit, no need to be an ass. Good job. I was advocating the general idea of knowledge. Get over it man, there are many ways to do things. It is not a disservice when the method literally comes from McNeel with Interval.ParameterAt. You just existing in this forum borders on harassment, as many many other users have commented to you.

2 Likes

I’ve had it with you. On ignore.

1 Like