Page 1 of 1

360° = 0° ?

Posted: Sun Jan 31, 2021 10:34 pm
by TheAutomator
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? :)

Re: 360° = 0° ?

Posted: Sun Jan 31, 2021 11:09 pm
by skywalk
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.

Re: 360° = 0° ?

Posted: Sun Jan 31, 2021 11:16 pm
by TheAutomator
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.
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?

repeat
rotation number + 1
if rotation number = 360 then rotation number = 0
rotate sprite(rotation number)
draw sprite
forever


correct?

Re: 360° = 0° ?

Posted: Sun Jan 31, 2021 11:39 pm
by SPH

Code: Select all

angle=360

Debug "Angle : "+Str(angle)+"° ("+Str(angle%360)+"°)"


Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 12:16 am
by TheAutomator
Okay, skip the '360', thanks guys!

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 3:46 am
by Olli
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.

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 4:35 am
by AZJIO

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° ?

Posted: Mon Feb 01, 2021 8:17 am
by oreopa
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)

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 10:40 am
by djes
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 ( :wink: ).
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.

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 12:05 pm
by Michael Vogel
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 :wink:

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 1:52 pm
by TheAutomator
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.

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 2:06 pm
by Olli
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

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
Now -1.0° = 359.0° !
(and -0.1° = 359.9°...)

Code: Select all

Debug OddMod(-0.1, 360) ; will display 359.9...

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 5:47 pm
by TheAutomator
Olli 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
hah, you didn't need to do that but thanks for showing :D

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 6:22 pm
by Olli
Uh... Imagine you have any very large pieces to rotate : one degree could be too much !

Re: 360° = 0° ?

Posted: Mon Feb 01, 2021 9:19 pm
by TheAutomator
Olli wrote:Uh... Imagine you have any very large pieces to rotate : one degree could be too much !
That's why i was talking about floats somewhere in my previous answer :)