Go Down

Topic: Can't understand logic in drawing robot code, seems like complete nonsense. (Read 892 times) previous topic - next topic

djdylex

Hi, i'm on task3 for the drawing robot and i've been examining the code in moveToCounts.m:

Code: [Select]
       

        % Check distance to final position and break if close enough
        countRemain = countTarget - countNew;
        countNorm = sqrt(sum((countRemain).^2));
        if countNorm <= hitRadius
            break
        end


To me, this makes no geometric sense at all. Why would squaring the two counts do anything to help you calculate the distance? I feel like i'm missing something. I could understand if we had the x, y coordinates of both the desired and current position that the method used would work, but how would using the difference in counts give us the distance? The method still works to a degree, but it's not giving us the distance surely?

Go Up