PurpleKingdomGames / indigo

An FP game engine for Scala.
https://indigoengine.io/
MIT License
650 stars 60 forks source link

Implement 'safe' mod operator for Point-like types #698

Closed davesmith00000 closed 9 months ago

davesmith00000 commented 9 months ago

By safe I mean a version that works with negative numbers. Applies to Point, Vertex, Vector2/3/4.

davesmith00000 commented 9 months ago

~Math.floorMod may be the thing these days, rather than the old (((-1 % 2) + 2) % 2), business.~ floorMod doesn't work with doubles.

We're back to (number % divisor + divisor) % divisor.

davesmith00000 commented 9 months ago

Implemented for Point, Radians, Size, Vertex, Vector 2/3/4.