Page 1 of 1

Shortest rotation distance math

PostPosted: Mon Jul 23, 2018 9:48 am
by Battwell
Last steps of my tool changer code to sort.
Been racking my old brain to work out best math to work out shortest distance math with roll over.
Rotary tool rack with 6 tools
Eg tool 2 to tool 6
6-2 =4 steps
But it’s quicker to reverse direction and go 2-1-6 which is only 3 steps.

Re: Shortest rotation distance math

PostPosted: Mon Jul 23, 2018 10:33 am
by spumco
Some sort of if-then with variables?

Position X + Position Y = #A
Position X - Position Y = #B

If #A > B, then CW, else CCW

No, that won't work with rollover unless you assign a value table to each combination. Like 1 to 2 = 1, 1 to 6 = 1, 1 to 5 = 2, etc.

Hmm. Post when you get it sorted 'cause now I'm curious.

Re: Shortest rotation distance math

PostPosted: Mon Jul 23, 2018 2:41 pm
by Battwell
Me and my son brain stormed it
Working perfect
Il post the code later