Easier way to change decimals

DampGoodSanta

New member
Joined
Jul 7, 2023
Messages
2
I’ve been do some geometry for a few days now, figuring out what percentage of an area of a 2d shape fits under a line at a given height% h, but when I’m making my formulas I keep running into a simplifying problem that makes them longer than what I think is necessary.
h is always between 0 and 1 as it is a % aswell.
to find some area for horizontally symmetrical shapes, e.g circle, diamond, I use the formula |[h]-h|, where the square brackets [ ] means round to the nearest integer. [h] is always 0 or 1, as h is always between the two. Subtracting h from [h] gives -h, if h<0.5, and 1-h if h>0.5. e.g if h is 0.25, the formula gives 0.25, but if h is 0.75, it also gives 0.25.
I was wondering if the was a simpler way of doing this to help simplify some of my equations.
What I would like is a way to turn 0.6 into 0.4, or 0.85 into 0.15, but also keep 0.4, and 0.2 the same for example.
Thanks
 
Ive found 0.5-|h-0.5|, so just looking for a way to do it without absolute value
they look like a triangle when graphed
 

Attachments

  • IMG_2437.png
    IMG_2437.png
    391.8 KB · Views: 1
Ive found 0.5-|h-0.5|, so just looking for a way to do it without absolute value
they look like a triangle when graphed
What do you consider simpler than absolute value? You'll obviously need some special function, since the function is not smooth!

One option, for example, is min(x, 1-x):

1688928360354.png

This is equivalent to your 1/2 - |x - 1/2|.
 
Top