Posted: 17th Feb 2023 20:17
A quick, economical way to replace DBP's old WRAPVALUE command for rotation angles with just a few lines.

This is only raw lines of code... you can craft your own custom function or subroutine based on this formula.
If you find a mathematical error I'll try to fix it based on suggestions, but it should work for any value you input.

+ Code Snippet
myValue#=1020 `<< change only this value to test the code
v#=myValue#/360.0:vINT=v#
vWrap#=(v#-vINT)*360.0
if vWrap#<0 then vWrap#=(360.0+vWrap#) `optionally flips the result from negative to positive while keeping the correct angle

do
print (vWrap#)
sync()
loop
Posted: 18th Feb 2023 16:55
+ Code Snippet
Function WrapAngle( Angle As Float )
	Angle = Angle / 360.0 
	Angle = 360.0 + ( 360.0 * ( Angle - Trunc( Angle ) ) )
EndFunction Angle


Just as a simple, but a little different approach and as a Function
Posted: 19th Feb 2023 15:00
Awesome! I hadn't noticed that TRUNC command before... very convenient!