Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Angle, Vector, Radian, and Distance Library
#4
Interesting!  Thanks.

You could replace a few 6-statement sequences with 1 statement.
It's kind of like a remainder, except the divisor can be non-integer.
I hope the commented code explains it.

Code: (Select All)
'---- The statements below
'  While x >= d ' x can be no bigger than d
'  x = x - d
'  Wend
'  While x < 0 ' x can be no less than 0
'    x = x + d
'  Wend
'---- Can be replaced by
'  x = x - int(x / d) * d

' for x = 1.3 and d = .5
Print 1.3 - Int(1.3 / .5) * .5 ' = .3 because int(1.3/.5) = 2 and .3 = 1.3 - 2 * .5

' for x = -.7 and d = .5
Print -.7 - Int(-.7 / .5) * .5 ' = .3 because int(-.7/.5) = -2 and .3 = -.7 - (-2) * .5
___________________________________________________________________________________
I am mostly grateful for the people who came before me.  Will the people after me be grateful for me?
Reply


Messages In This Thread
RE: Angle, Vector, Radian, and Distance Library - by dcromley - 08-27-2022, 03:26 AM



Users browsing this thread: 1 Guest(s)