• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to convert a float input into a stepped value of choice?

Participant ,
Dec 04, 2024 Dec 04, 2024

Copy link to clipboard

Copied

In super short, I want to do this ↓

Calculator

And I've tried these:

LINK 1 

LINK 2


I want to give user a float slider (to move something in X and Y) but the result should be a multiple of 1/32 (let's say).

 

The approaches I tried are not giving me the 'Stepped' result but smooth continous values.

 

Happy holidays to the US folks! 

Thanks!

TOPICS
General , How to , Substance Graph

Views

79

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 04, 2024 Dec 04, 2024

Hey Ayush,

Great task, I'll give you an outline of how this would work.

Lets say you want a float to be a multiple of 1/32

1. Multiply the float with 32, so you have a floating point value between 0 and 32

2. Use the floor function on the result or round the result to the nearest integer value (depending on what you want to achieve)

3. Divide the rounded value by 32 to get a stepped value between 0 and 1 with a distance of 1/32

 

If you have any arbitrary value which is not expressable by a frac

...

Votes

Translate

Translate
Community Expert ,
Dec 04, 2024 Dec 04, 2024

Copy link to clipboard

Copied

Hey Ayush,

Great task, I'll give you an outline of how this would work.

Lets say you want a float to be a multiple of 1/32

1. Multiply the float with 32, so you have a floating point value between 0 and 32

2. Use the floor function on the result or round the result to the nearest integer value (depending on what you want to achieve)

3. Divide the rounded value by 32 to get a stepped value between 0 and 1 with a distance of 1/32

 

If you have any arbitrary value which is not expressable by a fraction, let's say you want values to be a multiple of 0.0317 then just divide the input float by this value this gives you a range between 0 and 1/0.0317 floor or round the result and multiply it by 0.0317 and you have a stepped value with multiples of 0.0317.

 

I hope this helps, stay healthy and creative Marco 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 04, 2024 Dec 04, 2024

Copy link to clipboard

Copied

LATEST

That worked. Thanks! Guess I was overcomplicating stuff 😛

One pet peeve with the Safe Transform node though, for some reason it's giving wonky result at (0,0).
For now I'll just add 0.01 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines