Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
134 stars 2 forks source link

ValueMod operator does not follow actual modulo logic #406

Open antrobot1234 opened 11 months ago

antrobot1234 commented 11 months ago

Describe the bug?

the modulo operator does not work how actual modulo works in mathematics.

real modulo maps values to the sign of the "modulant": e.g. 10%-50 = -40. 10%50 = 10.

modulo in the game does not have this functionality.

To Reproduce

spawn a modValue node. input values. see result.

Expected behavior

correct: 10%100 = 10. 120%100 = 20. -10%100=90. -120%100 = 80. 10%-100 =-90 120%-100 = -80 -10%-100=10 -120%-100 = -20 incorrect: -10%100 = -10. -120%100 = 20 10%-100 = 10 120%-100 = 20

Screenshots

image

Resonite Version Number

10.20.831

What Platforms does this occur on?

Windows, Linux, Android / Quest

What headset if any do you use?

N/A

Log Files

N/A

Additional Context

if there is an issue with backwards compatability, then implement the proper functionality into a new node and map the old function to a node labeled something along the lines of 'signlessMod'

Reporters

No response

art0007i commented 11 months ago

It sounds like the functionality you are looking for is the Math>ValueRepeat node. The % Node refers to the c# % operator, because the game is written in c#.

Math>ValueRepeat examples

antrobot1234 commented 11 months ago

image @art0007i math repeat is not identical to true modulo, sadly.

art0007i commented 11 months ago

math repeat is not identical to true modulo, sadly.

for integers it's a little different 2023-10-23 18 44 46

antrobot1234 commented 11 months ago

@art0007i yes. that still means there is no correct modulo node that works as modulo works mathematically in all scenarios.

Frooxius commented 10 months ago

This is not a bug, it's just how modulo operator works in programming languages like C or C#.

I understand that it's not the same as the mathematics one, but it's not expected to be - we are not doing anything special and we will not be changing how it operates.

We could look into adding additional math nodes though. So the Repeat node does not match what you expect either? Would you be able to provide any implementation references for the modulo operation you desire?

antrobot1234 commented 10 months ago

@Frooxius I would be fine with implementing a new math node that implements modulo in the mathematical sense and not in the programmatic one.

The problem with the repeat node is that, while it functions like mathematical modulo for floats, it does not function identically for integer values.

As for implementation reference, most online calculators (such as the Google calculator) use the mathematical modulo definition.