diff options
| author | AntoNainRatio <120639162+AntoNainRatio@users.noreply.github.com> | 2024-04-02 14:37:42 +0300 |
|---|---|---|
| committer | AntoNainRatio <120639162+AntoNainRatio@users.noreply.github.com> | 2024-04-02 14:37:42 +0300 |
| commit | 40e1f17920fc453149379495bf47a8d12a50a43e (patch) | |
| tree | 73894e2dab81efadb5514b408068602cd2f318c0 /robot.js | |
| parent | 36e299381ad106fc5eeb6b6b0b87aed396188175 (diff) | |
opti angle 1
Diffstat (limited to 'robot.js')
| -rw-r--r-- | robot.js | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -34,6 +34,14 @@ async function moveTo(x,y) var dist = Math.sqrt(x * x + y * y) console.log('dist is '+dist) var angle = (Math.atan2(y,x))*180/Math.PI + if(angle>180) + { + angle-=180 + } + else if(angle<-180) + { + angle+=180 + } console.log(angle.toString()) var str = 'T'+(Math.floor(angle)-90).toString() client.publish('move',str) |
