编辑:不正确的菱形替换已经修复。向已经开始研究解决方案的阿诺约尼道歉。
考虑以下替换,其中替换的菱形(Us)被放大并以红色显示:
编辑:注意创建的锚点(圆圈),每个新菱形的一个角接触替代菱形。还请注意替换的锚点(黑圈)。

..。变成..。


..。变成..。

每个替换都是由A菱形和B菱形组合而成的,在这两种菱形上可以执行相同的替换。
可以通过重复替换次数来创建平铺。
菱形的n=2替换后:
编辑:通过将菱形的锚点与替换的锚点对齐来定向替换

备注:
发布于 2016-05-05 13:17:13
import java.awt.image.BufferedImage;import static java.lang.Math.*;class J{BufferedImage o=new BufferedImage(999,999,1);java.awt.Graphics g=o.getGraphics();double v=2.5132,w=1.2566,p=PI,s=(p-v)/2,u=(p+w)/2;public static void main(String[]v){new J(Integer.parseInt(v[0]));}J(int i){d(609,391,v,p/4+s,500,i);try{javax.imageio.ImageIO.write(o,"png",new java.io.File("a.png"));}catch(Exception e){}}void d(int x,int y,double o,double q,double l,int r){int m=(int)(2*l*sin((p-o)/2)),a=(int)(x+cos(q)*l),b=(int)(y+sin(q)*l),c=(int)(x+cos(q+o/2)*m),d=(int)(y+sin(q+o/2)*m),e=(int)(x+cos(q+o)*l),f=(int)(y+sin(q+o)*l);if(r-->0){double n=l/(2*sin((v)/2));if(o>w){d(x,y,v,q-s,n,r);d(c,d,v,q+p+s,n,r);d(a,b,w,q+u,n,r);}else{d(x,y,w,q-s,n,r);d(c,d,w,q+p+s,n,r);d(e,f,w,q-p/2,n,r);d(a,b,v,q+p/2-s-s,n,r);}}else{g.drawLine(x,y,a,b);g.drawLine(a,b,c,d);g.drawLine(x,y,e,f);g.drawLine(c,d,e,f);}}}import java.awt.image.BufferedImage;
import static java.lang.Math.*;
class Q79373 {
BufferedImage image = new BufferedImage(999, 999, 1);
java.awt.Graphics graphics = image.getGraphics();
double aRad = 2.5132, bRad = 1.2566, pi = PI, aAcuteHalf = (pi - aRad) / 2, bRadHalfPi = (pi + bRad) / 2;
public static void main(String[] v) {
new Q79373(Integer.parseInt(v[0]));
}
Q79373(int i) {
draw(609, 391, aRad, pi / 4 + aAcuteHalf, 500, i);
try {
javax.imageio.ImageIO.write(image, "png", new java.io.File("a.png"));
} catch (Exception e) {
}
}
void draw(int x, int y, double rad, double rot, double length, int recDepth) {
int
height = (int) (2 * length * sin((pi - rad) / 2)),
a = (int) (x + cos(rot) * length),
b = (int) (y + sin(rot) * length),
c = (int) (x + cos(rot + rad / 2) * height),
d = (int) (y + sin(rot + rad / 2) * height),
e = (int) (x + cos(rot + rad) * length),
f = (int) (y + sin(rot + rad) * length);
if (recDepth-- > 0) {
double lengthNew = length / (2 * sin((aRad) / 2));
if (rad > bRad) {
draw(x, y, aRad, rot - aAcuteHalf, lengthNew, recDepth);
draw(c, d, aRad, rot + pi + aAcuteHalf, lengthNew, recDepth);
draw(a, b, bRad, rot + bRadHalfPi, lengthNew, recDepth);
} else {
draw(x, y, bRad, rot - aAcuteHalf, lengthNew, recDepth);
draw(c, d, bRad, rot + pi + aAcuteHalf, lengthNew, recDepth);
draw(e, f, bRad, rot - pi / 2, lengthNew, recDepth);
draw(a, b, aRad, rot + pi / 2 - aAcuteHalf - aAcuteHalf, lengthNew, recDepth);
}
} else {
graphics.drawLine(x, y, a, b);
graphics.drawLine(a, b, c, d);
graphics.drawLine(x, y, e, f);
graphics.drawLine(c, d, e, f);
}
}
}Graphics::drawLine只使用整数作为参数,我最终会得到比现在更多的整数转换。Full image filled
Recursion 1
Recursion 2
Recursion 3
https://codegolf.stackexchange.com/questions/79373
复制相似问题