360° = 0° ?
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
360° = 0° ?
Is the number 360 actually needed if we would code a constantly rotating object?
Or should we stop and turn to '0' when we reach '359' and we add '+1' to it to get a seamless loop?
Simple question that is driving me nuts..
If we talk about 24-h time we also stop at 23:59 before we jump to 00:00 right? :)
Or should we stop and turn to '0' when we reach '359' and we add '+1' to it to get a seamless loop?
Simple question that is driving me nuts..
If we talk about 24-h time we also stop at 23:59 before we jump to 00:00 right? :)
Re: 360° = 0° ?
There are 360° total to traverse a circle. So you increment from 0-359. 360 = 0.
In transmission lines, a frequency(fixed wavelength) can require many wavelengths to complete its journey. Here, the sum of phase travel is important.
In transmission lines, a frequency(fixed wavelength) can require many wavelengths to complete its journey. Here, the sum of phase travel is important.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: 360° = 0° ?
So in other words, use values 0 to 359, (if we do +1 per frame) and skip 360 because the sprite will be aligned to that angle twice?skywalk wrote:There are 360° total to traverse a circle. So you increment from 0-359. 360 = 0.
In transmission lines, a frequency(fixed wavelength) can require many wavelengths to complete its journey. Here, the sum of phase travel is important.
repeat
rotation number + 1
if rotation number = 360 then rotation number = 0
rotate sprite(rotation number)
draw sprite
forever
correct?
Re: 360° = 0° ?
Code: Select all
angle=360
Debug "Angle : "+Str(angle)+"° ("+Str(angle%360)+"°)"
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: 360° = 0° ?
Okay, skip the '360', thanks guys!
Re: 360° = 0° ?
360° = 0°
To ease the brain mechanism, if you see a zero digit in the number '360', then you are on 0°.
this difficulty is seen everywhere between theory and apply :
on one hand, the positions where 0° = 360° = 360° × N = 720° = -360° etc... All these equivalent have an even parity.
on the other hand, the domain which excludes at the end if it includes at start : from 0° to 359°.
Positions and domains are two different logics, the position logic depends of the context : mathematical versus physical.
A math position has no 'thickness' : the cursor thickness is null.
But a physical position has a 'thickness'. In example, if you cut a circular surface with a saw : the saw has a thickness, and a security must consider a danger occurs before the 360° are reached.
A domain is a total (here 360°) which starts and finishs, with the idea of a succeding of any same domains. In this way, there are a zero-based defining or a one-based defining.
0-based domain : between 0 included and 360 excluded (=359°)
1-based domain : between 0 excluded and 360 included (very rare using)
Synthesis :
1.a) mathematical position is from 0 to 360
1.b) physical position is from 0 to (360-toolSize)
2.a) 0-based domain is from 0 to 359
2.b) 1-based domain is from 1 to 360
Conclusion : we work usually on the mathematical position logic (from 0° to 360°) and there is 2 functions to modulate :
1) a % b ; integer variables
2) x = mod(x, y) ; floating numbers
/!\ Mod() function is a 'even' math function (and also non-derivable). What it does not interest us in this subject. I add below a small code (procedure OddMod() ) to replace it with a useful function. And I thank the several answers to do the remark. /!\
Note : sum rule
(E = number with even parity
O = number with odd parity)
E + E = E
E + O = O
O + E = O
O + O = E
Parity logic in the sums seems like the sign logic in the products, which causes sometimes confusions.
To ease the brain mechanism, if you see a zero digit in the number '360', then you are on 0°.
this difficulty is seen everywhere between theory and apply :
on one hand, the positions where 0° = 360° = 360° × N = 720° = -360° etc... All these equivalent have an even parity.
on the other hand, the domain which excludes at the end if it includes at start : from 0° to 359°.
Positions and domains are two different logics, the position logic depends of the context : mathematical versus physical.
A math position has no 'thickness' : the cursor thickness is null.
But a physical position has a 'thickness'. In example, if you cut a circular surface with a saw : the saw has a thickness, and a security must consider a danger occurs before the 360° are reached.
A domain is a total (here 360°) which starts and finishs, with the idea of a succeding of any same domains. In this way, there are a zero-based defining or a one-based defining.
0-based domain : between 0 included and 360 excluded (=359°)
1-based domain : between 0 excluded and 360 included (very rare using)
Synthesis :
1.a) mathematical position is from 0 to 360
1.b) physical position is from 0 to (360-toolSize)
2.a) 0-based domain is from 0 to 359
2.b) 1-based domain is from 1 to 360
Conclusion : we work usually on the mathematical position logic (from 0° to 360°) and there is 2 functions to modulate :
1) a % b ; integer variables
2) x = mod(x, y) ; floating numbers
/!\ Mod() function is a 'even' math function (and also non-derivable). What it does not interest us in this subject. I add below a small code (procedure OddMod() ) to replace it with a useful function. And I thank the several answers to do the remark. /!\
Note : sum rule
(E = number with even parity
O = number with odd parity)
E + E = E
E + O = O
O + E = O
O + O = E
Parity logic in the sums seems like the sign logic in the products, which causes sometimes confusions.
Last edited by Olli on Mon Feb 01, 2021 4:14 pm, edited 2 times in total.
Re: 360° = 0° ?
Code: Select all
f = 0
a = 720
If a >= 360
f = 1
EndIf
While a >= 360
a - 360
Wend
Debug "is the circle filled?"
Debug f
Debug "current angle"
Debug a
Re: 360° = 0° ?
tl;dr 
Zero is a DISCREET VALUE. Unique. I like the confusion on faces when I explain that more fully to my non computing friends. It's a very simple concept that a lot of ppl seem to have trouble with
(not directed at the OP)

Zero is a DISCREET VALUE. Unique. I like the confusion on faces when I explain that more fully to my non computing friends. It's a very simple concept that a lot of ppl seem to have trouble with

Proud supporter of PB! * Musician * C64/6502 Freak
Re: 360° = 0° ?
It needs to be well understood as I've seen largely known tools having bad behaviors : Adobe flash for example.
You're talking about rotating objects.
Rotation is a transformation with a start and an end. Needs to define if you rotate your original object or your previous transformed object (1st please).
On computers, rotation is a destructive transformation (sorry). Needs to keep a copy of the original object (
).
You can rotate in clockwise direction or anti-clockwise.
Rotation can use floating or integer values (needs to define the lowest possible step).
You can rotate several times with a single operation (needs to define the maximum step).
All theses conditions can't be treated in a single operation. If you want something stable, you'll need to create a procedure to avoid problems.
You're talking about rotating objects.
Rotation is a transformation with a start and an end. Needs to define if you rotate your original object or your previous transformed object (1st please).
On computers, rotation is a destructive transformation (sorry). Needs to keep a copy of the original object (

You can rotate in clockwise direction or anti-clockwise.
Rotation can use floating or integer values (needs to define the lowest possible step).
You can rotate several times with a single operation (needs to define the maximum step).
All theses conditions can't be treated in a single operation. If you want something stable, you'll need to create a procedure to avoid problems.
- Michael Vogel
- Addict
- Posts: 2797
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: 360° = 0° ?
Just one note for decrementing angle values: I'd prefer constructs like (angle+359)%360 instead of (angle-1)%360 to avoid negative numbers...
...and of course we are talking about degrees all the time, not gradian or radians
...and of course we are talking about degrees all the time, not gradian or radians

- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: 360° = 0° ?
it's interesting how such simple things can be confusing sometimes, i remember programming a timer for my father as a child, scratching my head if i should add the 60'th second each time or not :p
the more I think about the 360 topic the more i see how simple it actually is: 360 would never be reached, the only thing that can be added to 359 is a float less than 1, else we go back to 0.
the more I think about the 360 topic the more i see how simple it actually is: 360 would never be reached, the only thing that can be added to 359 is a float less than 1, else we go back to 0.
Re: 360° = 0° ?
I tryed to edit my message above, but if I did it, a dated notification of that message would appear. Then I would not be discreet anymore...
Now -1.0° = 359.0° !
(and -0.1° = 359.9°...)

Code: Select all
; DOUBLE PRECISION FLOATING POINT NUMBER MODULATED (ODD FUNCTION)
Procedure.D OddMod(x.D, y.D)
If Sign(x) > -1
ProcedureReturn Mod(x, y)
Else
ProcedureReturn y + Mod(x + 1, y) - 1
EndIf
EndProcedure
(and -0.1° = 359.9°...)
Code: Select all
Debug OddMod(-0.1, 360) ; will display 359.9...
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: 360° = 0° ?
hah, you didn't need to do that but thanks for showing :DOlli wrote:I tryed to edit my message above, but if I did it, a dated notification of that message would appear. Then I would not be discreet anymore... :D
; DOUBLE PRECISION FLOATING POINT NUMBER MODULATED (ODD FUNCTION
Re: 360° = 0° ?
Uh... Imagine you have any very large pieces to rotate : one degree could be too much !
- TheAutomator
- Enthusiast
- Posts: 112
- Joined: Tue Dec 01, 2020 8:33 pm
Re: 360° = 0° ?
That's why i was talking about floats somewhere in my previous answer :)Olli wrote:Uh... Imagine you have any very large pieces to rotate : one degree could be too much !