您可以使用gnuplot做类似的事情。当然,gnuplot需要知道线的起点和终点的坐标,因此您必须以某种方式进行计算。类似于下面的代码:将坐标写入数据块中并进行绘制with vectors
,然后检查help vectors
。使用gnuplot 5.2.8创建的图形。
码:
### vector plot similar to turtle graphics
reset session
set size square
set angle degrees
x0 = 0
y0 = 0
a0 = 0
r0 = 10
set print $Data
do for [i=1:36] {
a0 = a0 - 10
do for [j=1:2] {
print sprintf("%g %g %g %g",x0,y0,x0=x0+r0*cos(a0),y0=y0+r0*sin(a0))
a0 = a0 - 90
}
}
set print
plot $Data u 1:2:($3-$1):($4-$2) w vectors nohead notitle
### end of code
结果:
加成:
顺便说一句:这个龟图形命令实际上不能简化为吗?
repeat 36 [fd 100 rt 110]
是的,正如@Friedrich所示,它可以在没有数据块的情况下完成。这是我没有模数的第一枪的修改版本%
。第五列即(x0=x0+r*cos(a),y0=y0+r*sin(a),a=a-110)
不用于绘图,而仅用于计算。
码:
### vector plot similar to turtle graphics
reset session
set size square
set angle degrees
set xrange[-2:12]
set yrange[-10:4]
r = 10
set samples 36
plot a=x0=y0=0 '+' u (x0):(y0):(r*cos(a)):(r*sin(a)): \
(x0=x0+r*cos(a),y0=y0+r*sin(a),a=a-110) w vec nohead not
### end of code
结果:(类似于上图)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句