我正在学习metapost,我想知道如何生成像多边形数字http://en.wikipedia.org/wiki/Polygonal_number这样的图形,我得到了三角形数字,但没有六边形。
感谢您的帮助。
最佳答案
我突然想到,如果你不关心相互绘制点和线,那么这个问题就很容易了。下面的内容就像罪恶一样丑陋,主要是因为仅使用 fullcircle scaled
来定义点,但它有效:
beginfig(1); pair right, nright; u:=1cm; right:=(u,0); path p,q,dot,seg; dot:=fullcircle scaled (u/2); seg:=(0,0)-- (dot shifted right); for N=1 upto 6: p:=dot; nright:=(N*u,0); for i=1 upto N: p:=seg -- (p shifted right); endfor q:=(0,0); for j=1 upto 6: q:=p -- ((q rotated 60) shifted nright); endfor draw q; endfor endfig
此方法应该适用于所有 n 目标数。
关于layout - 如何使用metapost生成多边形数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2247053/