- 注册时间
- 2020-11-9
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 3826
- 在线时间
- 小时
|
发表于 2020-11-27 15:35:27
|
显示全部楼层
本帖最后由 uk702 于 2020-11-27 15:46 编辑
如果照搬#113 的数据作图,mathematica 显示是有重叠的。
已经没有权限上传附件了,代码就直接附加在这里。
- (* n=27 的情况 *)
- a27 := Module[{w, h, f, a, t, esp, sqs, ra, rb, r1, r2, r3, r4, r5},
- w = 1.0; h = Sqrt[2.];
- f = Rectangle[{0, 0}, {1, h}];
- (* a=0.20492201311295878832697322513932693100; or a = 0.20497349086650882186971984463628195770? *)
- a=0.20497349086650882186971984463628195770;
- t=0.785398164;
- esp = 10.0^-10;
- total = 0.0;
- (* 各个矩形 *)
- sqs = {};
- sqs = Append[sqs, Rectangle[{0, 0}, {a, a}]];
- sqs = Append[sqs, Rectangle[{0, h-a}, {a, h}]];
- sqs = Append[sqs, Rectangle[{0, h-2*a}, {a, h-a}]];
- sqs = Append[sqs, Rectangle[{0, h-3*a}, {a, h-2*a}]];
- sqs = Append[sqs, Rectangle[{0, h-4*a}, {a, h-3*a}]]; (* 5 *)
- sqs = Append[sqs, Rectangle[{a, h-a}, {a*2, h}]];
- sqs = Append[sqs, Rectangle[{a, h-2*a}, {a*2, h-a}]];
- sqs = Append[sqs, Rectangle[{a, h-3*a}, {a*2, h-2*a}]];
- sqs = Append[sqs, Rectangle[{a*2, h-a}, {a*3, h}]];
- sqs = Append[sqs, Rectangle[{1-a, h-a}, {1, h}]];
- sqs = Append[sqs, Rectangle[{1-3*a, 0}, {1-2*a, a}]]; (* 11 *)
- sqs = Append[sqs, Rectangle[{1-2*a, 0}, {1-a, a}]];
- sqs = Append[sqs, Rectangle[{1-a, 0}, {1, a}]];
- sqs = Append[sqs, Rectangle[{1-2*a, a}, {1-a, 2*a}]]; (* 14 *)
- sqs = Append[sqs, Rectangle[{1-a, a}, {1, 2*a}]];
- sqs = Append[sqs, Rectangle[{1-2*a, 2*a}, {1-a, 3*a}]]; (* 16 *)
- sqs = Append[sqs, Rectangle[{1-a, 2*a}, {1, 3*a}]];
- sqs = Append[sqs, Rectangle[{1-a, 3*a}, {1, 4*a}]];
- ra = Rectangle[{0, 0}, {2*a, a}];
- (*
- r1 = TransformedRegion[ra, RotationTransform[-t, {0, 0}]];
- r1 = TransformedRegion[r1, TranslationTransform[{0, 0.434722}]];
- r2 = TransformedRegion[r1, TranslationTransform[{0.166293, 0.121731}]];
- *)
- (* 这些数据使用的是 #113 楼 s27.ggb 的坐标 *)
- r1 = Polygon[{{0.0051502184, 0.4047967633},
- {0.2950265091, 0.1120494726},
- {0.4399646545, 0.259858618},
- {0.1500883638, 0.5497349087}}];
-
- r2 = Polygon[{{0.1552385822, 0.5445846902},
- {0.4451148729, 0.2547083995},
- {0.5900530183, 0.4099469817},
- {0.3001767276, 0.6895228356}}];
- total += Area[RegionIntersection[r1, r2]];
- (* 验证无交叠 *)
- intersections = {};
- For [i=1, i<=Length[sqs],
- If [Area[RegionIntersection[sqs[[i]], r1]] > esp,
- (* Print["Intersection: ", i, ", r1"]; *)
- intersections = Append[intersections, sqs[[i]]];
- intersections = Append[intersections, r1];
- total += Area[RegionIntersection[sqs[[i]], r1]];
- ];
- i = i+1];
- For [i=1, i<=Length[sqs],
- If [Area[RegionIntersection[sqs[[i]], r2]] > esp,
- (* Print["Intersection: ", i, ", r2"]; *)
- intersections = Append[intersections, sqs[[i]]];
- intersections = Append[intersections, r2];
- total += Area[RegionIntersection[sqs[[i]], r2]];
- ];
- i = i+1];
- (* r3、r4 与 r1、r2 对称,其实可以不再验证了 *)
- r3 = TransformedRegion[r1, RotationTransform[180 Degree, {0.5, h/2}]];
- r4 = TransformedRegion[r2, RotationTransform[180 Degree, {0.5, h/2}]];
- total += Area[RegionIntersection[r3, r4]];
- For [i=1, i<=Length[sqs],
- If [Area[RegionIntersection[sqs[[i]], r3]] > esp,
- (* Print["Intersection: ", i, ", r3"]; *)
- intersections = Append[intersections, sqs[[i]]];
- intersections = Append[intersections, r3];
- total += Area[RegionIntersection[sqs[[i]], r3]];
- ];
- i = i+1];
- For [i=1, i<=Length[sqs],
- If [Area[RegionIntersection[sqs[[i]], r4]] > esp,
- (* Print["Intersection: ", i, ", r4"]; *)
- intersections = Append[intersections, sqs[[i]]];
- intersections = Append[intersections, r4];
- total += Area[RegionIntersection[sqs[[i]], r4]];
- ];
- i = i+1];
- rb = Rectangle[{0, 0}, {a, a}];
- r5 = TransformedRegion[rb, RotationTransform[45 Degree, {a/2, a/2}]];
- r5 = TransformedRegion[r5, TranslationTransform[{0.5 - a/2, h/2 - a/2}]];
- (* 验证无交叠 *)
- For [i=1, i<=Length[sqs],
- If [Area[RegionIntersection[sqs[[i]], r5]] > esp,
- (* Print["Intersection: ", i, ", r5"]; *)
- intersections = Append[intersections, sqs[[i]]];
- intersections = Append[intersections, r5];
- total += Area[RegionIntersection[sqs[[i]], r5]];
- ];
- i = i+1];
- total += Area[RegionIntersection[r3, r5]];
- total += Area[RegionIntersection[r4, r5]];
- Print["a = ", a, ", overlap area = ", total];
- (* 个别验证
- Print[Area[RegionIntersection[r5, r4]]];
- Print[Area[RegionIntersection[r5, r3]]];
- *)
- (* 获取每个矩形的坐标 *)
- ps = Flatten[Map[PolygonCoordinates, sqs], 1];
- (* Print[ps]; *)
- Graphics[{EdgeForm[{Thick, RGBColor["#807F7D"]}], White, f,
- EdgeForm[{Thick, RGBColor["#E79967"]}], RGBColor["#FBF0E8"],
- sqs, r1, r2, r3, r4, r5,
- Yellow, intersections,
- Red, PointSize[0.03], Point[ps]}]
- ];
-
-
复制代码 |
-
|