-
Notifications
You must be signed in to change notification settings - Fork 0
test: ジオデシック strut が閉じた三価ケージであることを検証 #288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 2.14.1 | ||
| 2.14.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,21 @@ struct GeodesicGeometryTests { | |
| .squareRoot() | ||
| } | ||
|
|
||
| private struct QuantizedVertex: Hashable { | ||
| let x, y, z: Int | ||
| } | ||
|
|
||
| /// Quantized coordinate key so the same centroid (reused by value across | ||
| /// several struts) collapses to one identity. The 80 centroids are ~0.36 | ||
| /// apart on the unit sphere, far above the 1e-6 rounding floor, so distinct | ||
| /// vertices never collide. | ||
| private func key(_ v: Vertex3D) -> QuantizedVertex { | ||
| QuantizedVertex( | ||
| x: Int((v.x * 1_000_000).rounded()), | ||
| y: Int((v.y * 1_000_000).rounded()), | ||
| z: Int((v.z * 1_000_000).rounded())) | ||
| } | ||
|
|
||
| @Test("dual of the freq-2 icosphere has exactly 120 edges") | ||
| func edgeCount() { | ||
| // 80 triangles → 120 manifold edges → 120 dual struts. Any other count | ||
|
|
@@ -38,4 +53,21 @@ struct GeodesicGeometryTests { | |
| #expect(distance(a, b) > 1e-6) | ||
| } | ||
| } | ||
|
|
||
| @Test("struts form a closed trivalent cage — 80 hubs, each of degree 3") | ||
| func trivalentCage() { | ||
| // Each strut endpoint is the centroid of one of the 80 icosphere | ||
| // triangles, i.e. a vertex of the Goldberg dual. A closed manifold | ||
| // makes every triangle share all 3 of its edges, so each centroid is | ||
| // trivalent. 80 hubs × 3 / 2 = 120 struts — consistent with edgeCount. | ||
| // A broken face list or non-manifold subdivision would drop a hub or | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| // skew a degree, which a raw edge count alone can miss. | ||
| let degree = GeodesicGeometry.edges | ||
| .reduce(into: [QuantizedVertex: Int]()) { counts, edge in | ||
| counts[key(edge.0), default: 0] += 1 | ||
| counts[key(edge.1), default: 0] += 1 | ||
| } | ||
| #expect(degree.count == 80) | ||
| #expect(degree.values.allSatisfy { $0 == 3 }) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辞書のキーとして
[Int]を使用する代わりに、専用のHashableなstructを定義することを検討してください。これにより、意図が明確になり、配列の動的確保(ヒープ割り当て)も避けられます。There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ご提案どおり専用の
しています。ad0f3af
HashablestructQuantizedVertexに置き換えました。意図が明確になり、辺ごとの[Int]配列確保も