logo(小海龟作图)语言中 towards 命令如何使用变量?

2022-08-16 教育 94阅读
以下是从logo的帮助文档里复制过来的关于towards命令的说明:

TOWARDS

Syntax

TOWARDS [xcoordinate ycoordinate]

Explanation

TOWARDS outputs a number which is the heading necessary for the turtle to rotate from its present position to the new position indicated by its input
list.

SETHEADING TOWARDS [xcoordinate ycoordinate] heads the turtle in the direction of its input list.

我试了一下,这个命令就是输出一个关于方向(角度)的数,用以指明海龟从现在所在的位置点朝向下一个目标位置点的方向(角度)。如果配合使用seth命令,就可以将海龟的方向直接指向目标点。

比如,海龟现在位于[0 0],如果海龟想要“看”向目标点[30 60],该设定多少度的方向呢?
towards [30 60]的结果是26.57度,这样,只要使用seth 26.57,就可以设置海龟的方向为26.57度,海龟的头就朝向目标点[30 60]所在的方向了。

两个命令可以合起来用,就是 seth towards [30 60],意思就是“将海龟的头转向目标点[30 60]所在的方向”。
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com