From b7245821df435f3b65afc754aa855da4bca91990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20C=C3=A0llisto?= Date: Sun, 14 Jul 2024 16:40:11 +0200 Subject: [PATCH] Better patterns --- .../tessella/TilingCoordsSpec.scala | 10 +- .../tessella/TilingGrowthNodeSpec.scala | 4 +- .../tessella/TilingUniformitySpec.scala | 40 +++--- .../conversion/SVGAnimationSpec.scala | 4 +- .../tessella/conversion/SVGExtraSpec.scala | 4 +- src/main/paradox/regular.md | 16 +-- src/main/paradox/semiregular.md | 37 ++++-- src/main/paradox/svg/pattern_33434.svg | 1 + src/main/paradox/tiling-SVG.md | 2 +- .../scala_tessella/tessella/Pattern.scala | 36 +++++- .../scala_tessella/tessella/Tiling.scala | 2 +- .../tessella/TilingUniformity.scala | 12 ++ .../tessella/creation/Layered.scala | 24 ++-- .../tessella/creation/Quadratic.scala | 22 ++-- .../tessella/creation/Reticulate.scala | 83 ++++++++++-- .../tessella/creation/Uni4Hex.scala | 30 ++--- .../tessella/creation/Uni5Hex.scala | 53 ++++---- .../tessella/creation/UniHex.scala | 16 +-- .../tessella/creation/UniTriangle.scala | 8 +- .../tessella/GonalitySpec.scala | 2 +- .../tessella/GraphPolygonsSpec.scala | 10 +- .../scala_tessella/tessella/GraphSpec.scala | 2 +- .../scala_tessella/tessella/Helper.scala | 4 +- .../scala_tessella/tessella/Outliers.scala | 92 ++++++------- .../scala_tessella/tessella/PatternSpec.scala | 52 +++++++- .../tessella/TilingEqualitySpec.scala | 16 +-- .../tessella/TilingGrowthEdgeSpec.scala | 4 +- .../TilingGrowthNodePolygonSpec.scala | 2 +- .../tessella/TilingGrowthSpec.scala | 8 +- .../tessella/TilingPerimeterSpec.scala | 26 ++-- .../scala_tessella/tessella/TilingSpec.scala | 111 ++++++++-------- .../tessella/TilingValidationSpec.scala | 2 +- .../tessella/TopologySpec.scala | 4 +- .../tessella/creation/GrowthRegularSpec.scala | 26 ++-- .../creation/GrowthSemiregularSpec.scala | 56 ++++---- .../tessella/creation/QuadraticSpec.scala | 4 +- .../creation/ReticulateRegularSpec.scala | 20 +-- .../tessella/creation/ReticulateSpec.scala | 122 ++++++++++-------- .../tessella/creation/SymmetricSpec.scala | 2 +- .../tessella/creation/Uni4HexSpec.scala | 70 ++++++++++ .../tessella/creation/Uni5HexSpec.scala | 100 ++++++++++++++ .../tessella/creation/UniHexSpec.scala | 52 ++++++++ .../tessella/creation/UniTriangleSpec.scala | 34 +++++ 43 files changed, 832 insertions(+), 393 deletions(-) create mode 100644 src/main/paradox/svg/pattern_33434.svg create mode 100644 src/test/scala/io/github/scala_tessella/tessella/creation/Uni4HexSpec.scala create mode 100644 src/test/scala/io/github/scala_tessella/tessella/creation/Uni5HexSpec.scala create mode 100644 src/test/scala/io/github/scala_tessella/tessella/creation/UniHexSpec.scala create mode 100644 src/test/scala/io/github/scala_tessella/tessella/creation/UniTriangleSpec.scala diff --git a/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingCoordsSpec.scala b/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingCoordsSpec.scala index 8b1d37e..7d7bfa1 100644 --- a/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingCoordsSpec.scala +++ b/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingCoordsSpec.scala @@ -17,7 +17,7 @@ import org.scalatest.matchers.* class TilingCoordsSpec extends AnyFlatSpec with should.Matchers { "A tiling made of triangles" can "return its coords" in { - tri4x4Reticulate.coords.almostEqualsMap( + p333333_4by4_reticulate.coords.almostEqualsMap( Map( 1 -> Point(), 2 -> Point(1, 0), @@ -40,7 +40,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers { } "A tiling made of hexagons" can "return its coords" in { - hex4x4Reticulate.coords.almostEqualsMap( + p666_4by4_reticulate.coords.almostEqualsMap( Map( 1 -> Point(), 2 -> Point(1, 0), @@ -96,7 +96,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers { } it can "be rendered as SVG" in { - prettyPrinter.format(hex4x4Reticulate.toSVG()) shouldBe + prettyPrinter.format(p666_4by4_reticulate.toSVG()) shouldBe """ | | Tiling @@ -216,7 +216,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers { } "A tiling made of squares" can "return its coords" in { - sqr4x4Reticulate.coords.almostEqualsMap( + p4444_4by4_reticulate.coords.almostEqualsMap( Map( 1 -> Point(), 2 -> Point(1, 0), @@ -249,7 +249,7 @@ class TilingCoordsSpec extends AnyFlatSpec with should.Matchers { } it can "be rendered as polygons SVG" in { - sqr4x4Reticulate.withPolygons shouldBe + p4444_4by4_reticulate.withPolygons shouldBe """ | | Tiling diff --git a/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodeSpec.scala b/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodeSpec.scala index 3444d62..3653b98 100644 --- a/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodeSpec.scala +++ b/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodeSpec.scala @@ -399,7 +399,7 @@ class TilingGrowthNodeSpec extends AnyFlatSpec with Helper with should.Matchers } it can "NOT have a polygon added to a non existing node" in { - Tiling.squareNet(2, 2).unsafe.maybeGrowNode(Node(100), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe + Tiling.pattern_4444(2, 2).unsafe.maybeGrowNode(Node(100), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe Left( """Tiling can add polygons only to perimeter nodes: | found unknown node 100. @@ -448,7 +448,7 @@ class TilingGrowthNodeSpec extends AnyFlatSpec with Helper with should.Matchers } it can "NOT have a polygon added to a non perimeter node" in { - Tiling.squareNet(2, 2).unsafe.maybeGrowNode(Node(5), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe + Tiling.pattern_4444(2, 2).unsafe.maybeGrowNode(Node(5), Vertex(Polygon(4)), BEFORE_PERIMETER) shouldBe Left( """Tiling can add polygons only to perimeter nodes: | found inner node 5. diff --git a/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingUniformitySpec.scala b/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingUniformitySpec.scala index 48eb7ca..b4032f7 100644 --- a/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingUniformitySpec.scala +++ b/.jvm/src/test/scala/io/github/scala_tessella/tessella/TilingUniformitySpec.scala @@ -208,21 +208,21 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers // } "A sqr4x4Reticulate" can "return the nodes belonging to each different gonality" in { - sqr4x4Reticulate.groupGonals shouldBe + p4444_4by4_reticulate.groupGonals shouldBe Map( Vector(4, 4, 4, 4) -> List(14, 9, 13, 17, 12, 7, 18, 8, 19) ).mapKeys(_.map(Node(_))) } it can "have its nodes grouped in uniform sets" in { - sqr4x4Reticulate.groupUniforms shouldBe + p4444_4by4_reticulate.groupUniforms shouldBe Map( (Vector(4, 4, 4, 4), List()) -> Vector(14, 9, 13, 17, 12, 7, 18, 8, 19) ).mapValues2(_.map(Node(_))) } it can "have an uniformity value 1" in { - sqr4x4Reticulate.uniformity shouldBe + p4444_4by4_reticulate.uniformity shouldBe 1 } @@ -276,31 +276,31 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } "A triangleTriangleOfSide5" can "have its nodes grouped in uniform sets" in { - triangleTriangleOfSide5.groupUniforms shouldBe + p333333_triangle.groupUniforms shouldBe Map( (Vector(3, 3, 3, 3, 3, 3), List()) -> Vector(5, 14, 9, 13, 12, 8) ).mapValues2(_.map(Node(_))) } it can "have uniformity value 1" in { - triangleTriangleOfSide5.uniformity shouldBe + p333333_triangle.uniformity shouldBe 1 } "A hexTrianguloidOfSide4" can "have its nodes grouped in uniform sets" in { - hexTrianguloidOfSide4.groupUniforms shouldBe + p666_triangle.groupUniforms shouldBe Map( (Vector(6, 6, 6), List()) -> Vector(14, 13, 22, 12, 16, 23, 15, 28, 21) ).mapValues2(_.map(Node(_))) } it can "have uniformity value 1" in { - hexTrianguloidOfSide4.uniformity shouldBe + p666_triangle.uniformity shouldBe 1 } - "A uniform3gonal2" can "have its nodes grouped in uniform sets" in { - uniform3gonal2.groupUniforms shouldBe + "A tiling with pattern [2x(3₆);(3₄.6)]" can "have its nodes grouped in uniform sets" in { + p2x333333_33336.groupUniforms shouldBe Map( (Vector(3, 3, 3, 3, 3, 3), List(0)) -> Vector(51, 55, 50, 53, 56, 57, 54), (Vector(3, 3, 3, 3, 6), List()) -> Vector(14, 33, 13, 35, 15, 24, 37, 34, 17, 22, 27, 26, 23), @@ -309,12 +309,12 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } it can "have uniformity value 3" in { - uniform3gonal2.uniformity shouldBe + p2x333333_33336.uniformity shouldBe 3 } - "A 5-uniform 3-Archimedean tiling" can "have its nodes grouped in uniform sets" in { - uniform5gonal3.groupUniforms shouldBe + "A tiling with pattern [2x(3₆);2x(3₄.6);(3.3.6.6)]" can "have its nodes grouped in uniform sets" in { + p2x333333_2x33336_3366.groupUniforms shouldBe Map( (Vector(3, 3, 3, 3, 3, 3), List(0)) -> Vector(101, 106, 102, 113, 108, 104), (Vector(3, 3, 3, 3, 6), List(1)) -> Vector(37, 78, 33, 48, 23, 47, 34, 64), @@ -325,7 +325,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } it can "have uniformity value 5 and gonality value 3" in { - (uniform5gonal3.gonality, uniform5gonal3.uniformity) shouldBe + (p2x333333_2x33336_3366.gonality, p2x333333_2x33336_3366.uniformity) shouldBe (3, 5) } @@ -344,7 +344,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } "A 7 uniform tiling [(3₆);2x(3₂.6₂);4x(6₃)]" can "have its nodes grouped in uniform sets" in { - uniform7gonal3.groupUniforms shouldBe + p333333_2x3366_4x666.groupUniforms shouldBe Map( (Vector(6, 6, 6), List(1)) -> Vector(111, 159, 33, 75, 123, 69, 138, 84, 61, 137, 97, 112, 48, 83, 76, 98, 47, 62), (Vector(3, 3, 6, 6), List(1)) -> Vector(110, 92, 153, 78, 64, 49, 81, 67, 154, 139, 82, 77, 96, 63, 95), @@ -357,7 +357,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } it can "have them grouped by vertex" in { - uniform7gonal3.groupUniformsNestedComplete shouldBe + p333333_2x3366_4x666.groupUniformsNestedComplete shouldBe Map( Vector(3, 3, 6, 6) -> List( (List(0), Vector(170, 142, 52, 93, 65, 156, 169, 141, 66, 155, 108, 3, 80, 18, 51, 4, 79, 94)), @@ -376,7 +376,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } it can "have uniformity value 7 and gonality value 3" in { - (uniform7gonal3.gonality, uniform7gonal3.uniformity) shouldBe + (p333333_2x3366_4x666.gonality, p333333_2x3366_4x666.uniformity) shouldBe (3, 7) } @@ -547,14 +547,14 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers "A 3-uniform 2-Archimedean tiling [2x(3₆);(3₄.6)]" can "be described" in { val t: Tiling = - uniform3gonal2 + p2x333333_33336 (t.gonality, t.uniformity) shouldBe (2, 3) } "A 4-uniform 4-Archimedean tiling [(3₆);(3₄.6);(3₂.6₂);(6₃)]" can "be described" in { val t: Tiling = - uniform4gonal4 + p333333_33336_3366_666 (t.gonality, t.uniformity) shouldBe (4, 4) } @@ -785,7 +785,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } "Another smaller tiling [(3.4.6.4)]" can "be examined for outer polygon strips from perimeter node 22" in { - triSqrHexHexoid.outerOrderedStripFromSingle(Node(22)) shouldBe + p3464.outerOrderedStripFromSingle(Node(22)) shouldBe List( (List(6), false), (List(4), false), @@ -797,7 +797,7 @@ class TilingUniformitySpec extends AnyFlatSpec with Helper with should.Matchers } val matrix: Map[Node, List[(List[Int], Boolean)]] = - triSqrHexHexoid.outerOrderedStripFrom(triSqrHexHexoid.graphEdges.nodes.diff(triSqrHexHexoid.perimeter.toRingNodes)) + p3464.outerOrderedStripFrom(p3464.graphEdges.nodes.diff(p3464.perimeter.toRingNodes)) it can "be examined for outer polygon strips from all nodes" in { matrix shouldBe diff --git a/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGAnimationSpec.scala b/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGAnimationSpec.scala index 289c786..b07a029 100644 --- a/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGAnimationSpec.scala +++ b/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGAnimationSpec.scala @@ -1,7 +1,7 @@ package io.github.scala_tessella.tessella package conversion -import Outliers.sqr3x3Growth +import Outliers.p4444_3by3_grown import SVG.* import org.scalatest.* @@ -12,7 +12,7 @@ class SVGAnimationSpec extends AnyFlatSpec with Helper with should.Matchers { "A tiling" can "be converted to an animation showing the nodes growth" in { prettyPrinter.format( - sqr3x3Growth.toSVG( + p4444_3by3_grown.toSVG( labelledNodes = LabelledNodes.NONE, showGrowth = true ) diff --git a/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGExtraSpec.scala b/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGExtraSpec.scala index 1468d18..b7ff07d 100644 --- a/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGExtraSpec.scala +++ b/.jvm/src/test/scala/io/github/scala_tessella/tessella/conversion/SVGExtraSpec.scala @@ -3,7 +3,7 @@ package conversion import SVG.* import SVGExtra.* -import Outliers.hexTrianguloidOfSide4 +import Outliers.p666_triangle import org.scalatest.* import org.scalatest.flatspec.* @@ -13,7 +13,7 @@ class SVGExtraSpec extends AnyFlatSpec with Helper with should.Matchers { "A tiling" can "be concentric" in { prettyPrinter.format( - hexTrianguloidOfSide4.toNestedPerimetersSVG() + p666_triangle.toNestedPerimetersSVG() ) shouldBe """ | diff --git a/src/main/paradox/regular.md b/src/main/paradox/regular.md index ad1b263..613fcc8 100644 --- a/src/main/paradox/regular.md +++ b/src/main/paradox/regular.md @@ -9,7 +9,7 @@ can be created. ### Fast reticulate method ```scala -Tiling.triangleNet(4, 4) +Tiling.pattern_333333(4, 4) ``` ```raw
@@ -22,7 +22,7 @@ Tiling.triangleNet(4, 4) ``` ```scala -Tiling.triangleTriangle(4) +Tiling.pattern_333333_triangle(4) ``` ```raw
@@ -37,7 +37,7 @@ Tiling.triangleTriangle(4) ### Slow growth method ```scala -TilingGrowth.growFullVertex(FullVertex.s("(3₆)"), 60) // same as Tiling.triangularHex(3) +TilingGrowth.growFullVertex(FullVertex.s("(3₆)"), 60) // same as Tiling.pattern_333333(3) ``` ```raw
@@ -54,7 +54,7 @@ TilingGrowth.growFullVertex(FullVertex.s("(3₆)"), 60) // same as Tiling.triang ### Fast reticulate method ```scala -Tiling.squareNet(4, 4) +Tiling.pattern_4444(4, 4) ``` ```raw
@@ -69,7 +69,7 @@ Tiling.squareNet(4, 4) ### Slow growth method ```scala -TilingGrowth.growFullVertex(FullVertex.s("(4₄)"), 9) // same as Tiling.squareNet(3) +TilingGrowth.growFullVertex(FullVertex.s("(4₄)"), 9) // same as Tiling.pattern_4444(3) ``` ```raw
@@ -86,7 +86,7 @@ TilingGrowth.growFullVertex(FullVertex.s("(4₄)"), 9) // same as Tiling.squareN ### Fast reticulate methods ```scala -Tiling.hexagonNet(4, 4) +Tiling.pattern_666(4, 4) ``` ```raw
@@ -99,7 +99,7 @@ Tiling.hexagonNet(4, 4) ``` ```scala -Tiling.hexTrianguloid(4) +Tiling.pattern_666_trianguloid(4) ``` ```raw
@@ -114,7 +114,7 @@ Tiling.hexTrianguloid(4) ### Slow growth method ```scala -TilingGrowth.growFullVertex(FullVertex.s("(6₃)"), 19) // same as Tiling.hexagonalHexoid(3) +TilingGrowth.growFullVertex(FullVertex.s("(6₃)"), 19) // same as Tiling.pattern_666(3) ``` ```raw
diff --git a/src/main/paradox/semiregular.md b/src/main/paradox/semiregular.md index e36a257..07d956c 100644 --- a/src/main/paradox/semiregular.md +++ b/src/main/paradox/semiregular.md @@ -7,7 +7,7 @@ can be created. ## 1, pattern [(3₄.6)] ```scala -Tiling.triHexagonalHexoid(5) +Tiling.pattern_33336(5) ``` ```raw
@@ -24,7 +24,7 @@ Tiling.triHexagonalHexoid(5) ### Fast method ```scala -Tiling.elongatedTriangular(6, 6) +Tiling.pattern_33344(6, 6) ``` ```raw
@@ -39,7 +39,7 @@ Tiling.elongatedTriangular(6, 6) ### Slow method ```scala -Tiling.triSquareSquaroid(2) +Tiling.pattern_33344(2) ``` ```raw
@@ -53,8 +53,25 @@ Tiling.triSquareSquaroid(2) ## 3, pattern [(3₂.4.3.4)] +### Fast method + +```scala +Tiling.pattern_33434(7, 7) +``` +```raw +
+``` +| ![labels](svg/pattern_33434.svg) | +|-----------------------------------------| +| _Finite set of a **(3₂.4.3.4)** tiling_ | +```raw +
+``` + +### Slow method + ```scala -Tiling.triSquareSquaroid2(3) +Tiling.pattern_33434(3) ``` ```raw
@@ -69,7 +86,7 @@ Tiling.triSquareSquaroid2(3) ## 4, pattern [(3.4.6.4)] ```scala -Tiling.triSquareHexagonalHexoid(3) +Tiling.pattern_3464(3) ``` ```raw
@@ -86,7 +103,7 @@ Tiling.triSquareHexagonalHexoid(3) ### Fast method ```scala -Tiling.triHexagonal(6, 6) +Tiling.pattern_3636(6, 6) ``` ```raw
@@ -101,7 +118,7 @@ Tiling.triHexagonal(6, 6) ### Slow method ```scala -Tiling.triHexagonalHex(3) +Tiling.pattern_3636(3) ``` ```raw
@@ -116,7 +133,7 @@ Tiling.triHexagonalHex(3) ## 6, pattern [(3.12₂)] ```scala -Tiling.triDodecagonalHexoid(2) +Tiling.pattern_31212(2) ``` ```raw
@@ -131,7 +148,7 @@ Tiling.triDodecagonalHexoid(2) ## 7, pattern [(4.6.12)] ```scala -Tiling.squareHexDodecagonalHexoid(2) +Tiling.pattern_4612(2) ``` ```raw
@@ -146,7 +163,7 @@ Tiling.squareHexDodecagonalHexoid(2) ## 8, pattern [(4.8₂)] ```scala -Tiling.squareOctogonalSquaroid(4) +Tiling.pattern_488(4) ``` ```raw
diff --git a/src/main/paradox/svg/pattern_33434.svg b/src/main/paradox/svg/pattern_33434.svg new file mode 100644 index 0000000..53b906c --- /dev/null +++ b/src/main/paradox/svg/pattern_33434.svg @@ -0,0 +1 @@ +TilingFinite tessellation of regular polygonsEdgesSides of the regular polygonsPolygonsRegular polygonsRegular 3-gonsRegular polygons with 3 sidesRegular 4-gonsRegular polygons with 4 sidesNode labelsEach node showing its value52410564224372552142046572961166021332838953134145641732342244592712544973933548631850163111434026552385836305119471562Tessella diff --git a/src/main/paradox/tiling-SVG.md b/src/main/paradox/tiling-SVG.md index 40a003e..1c54d0b 100644 --- a/src/main/paradox/tiling-SVG.md +++ b/src/main/paradox/tiling-SVG.md @@ -7,7 +7,7 @@ describing the vector image. ```scala import io.github.scala_tessella.tessella.conversion.SVG.* -val uniform3gonal2: Tiling = Tiling.threeUniformTwoOne(4, 4).toOption.get +val uniform3gonal2: Tiling = Tiling.pattern_2x333333_33336(4, 4).toOption.get uniform3gonal2.toSVG(showPerimeter = false, labelledNodes = LabelledNodes.NONE) // returns a SVG as scala.XML.Elem ``` ```raw diff --git a/src/main/scala/io/github/scala_tessella/tessella/Pattern.scala b/src/main/scala/io/github/scala_tessella/tessella/Pattern.scala index 1ed9f85..457b5cd 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/Pattern.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/Pattern.scala @@ -1,5 +1,7 @@ package io.github.scala_tessella.tessella +import RegularPolygon.{Polygon, PolygonOrdering} +import TilingUniformity.* import utility.Utils.* import utility.UtilsOption.sequence @@ -29,9 +31,13 @@ case class Pattern(vertices: List[FullVertex]) extends Ordered[Pattern]: lazy val distinctVertices: List[FullVertex] = vertices.distinct + /** Different polygons in the pattern */ + private def distinctPolygons: List[Polygon] = + vertices.flatMap(_.vertex.toPolygons).distinct + /** Number of different polygons in the pattern */ def hedrality: Int = - vertices.flatMap(_.vertex.toPolygons).distinct.size + distinctPolygons.size /** Number of different full vertices in the pattern */ def gonality: Int = @@ -41,6 +47,34 @@ case class Pattern(vertices: List[FullVertex]) extends Ordered[Pattern]: def uniformity: Int = vertices.size + /** Checks whether the given tiling has the same polygons of the pattern */ + def hasSamePolygonsOf(tiling: Tiling): Boolean = + distinctPolygons.sorted(PolygonOrdering) == tiling.distinctPolygons.sorted(PolygonOrdering) + + /** Checks whether the polygons of the given tiling are all contained in the pattern */ + def containsAllPolygonsOf(tiling: Tiling): Boolean = + tiling.distinctPolygons.diff(distinctPolygons).isEmpty + + /** Checks whether the given tiling has the same full vertex configurations of the pattern */ + def hasSameFullVerticesOf(tiling: Tiling): Boolean = + hasSamePolygonsOf(tiling) && + distinctVertices.sorted == tiling.distinctVertices.sorted + + /** Checks whether the full vertex configurations of the given tiling are all contained in the pattern */ + def containsAllFullVerticesOf(tiling: Tiling): Boolean = + containsAllPolygonsOf(tiling) && + tiling.distinctVertices.diff(distinctVertices).isEmpty + + /** Checks whether the given tiling has the same symmetry classes of the pattern */ + def hasSameSymmetryClassesOf(tiling: Tiling): Boolean = + hasSameFullVerticesOf(tiling) && + vertices.sorted == tiling.symmetryClasses.sorted + + /** Checks whether the symmetry classes of the given tiling are all contained in the pattern */ + def containsAllSymmetryClassesOf(tiling: Tiling): Boolean = + containsAllFullVerticesOf(tiling) && + tiling.symmetryClasses.diff(vertices).isEmpty + /** Companion object for [[Pattern]] */ object Pattern: diff --git a/src/main/scala/io/github/scala_tessella/tessella/Tiling.scala b/src/main/scala/io/github/scala_tessella/tessella/Tiling.scala index 6c1b818..53f7776 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/Tiling.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/Tiling.scala @@ -486,7 +486,7 @@ class Tiling private(edges: List[Edge]) extends Graph(edges) with Ordered[Tiling orientedPolygons.map(_.toPolygonPathNodes).groupBy(_.size).mapKeys(Polygon(_)) /** Associations of polygon and count */ - private def groupHedrals: Map[Polygon, Int] = + def groupHedrals: Map[Polygon, Int] = sizedPolygons.mapValues2(_.size) /** Number of different polygons in the tiling */ diff --git a/src/main/scala/io/github/scala_tessella/tessella/TilingUniformity.scala b/src/main/scala/io/github/scala_tessella/tessella/TilingUniformity.scala index 17a1cfc..fd5000b 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/TilingUniformity.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/TilingUniformity.scala @@ -291,3 +291,15 @@ object TilingUniformity: tiling.groupUniformsComplete .groupBy({ case ((vertex, _), _) => vertex }) .mapValues2(_.toList.map({ case ((_, treeIndices), nodes) => treeIndices -> nodes })) + + /** Distinct polygons */ + def distinctPolygons: List[Polygon] = + tiling.groupHedrals.keys.toList + + /** Distinct full vertex configurations */ + def distinctVertices: List[FullVertex] = + tiling.groupGonals.keys.toList.map(vertex => FullVertex.maybe(vertex.toPolygons).toOption.get) + + /** All vertex configurations, each a distinct symmetry class */ + def symmetryClasses: List[FullVertex] = + tiling.groupUniforms.keys.toList.map((vertex, _) => FullVertex.maybe(vertex.toPolygons).toOption.get) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/Layered.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/Layered.scala index 9045dd8..c10f2cb 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/Layered.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/Layered.scala @@ -24,7 +24,7 @@ trait Layered extends Reticulate: if f(i, j) yield Node(i + topRight.toInt * j) val edges: List[Edge] = - triangleNet((l + 1) * 2, h + 1).toOption.get.graphEdges.withoutNodes(topRight :: bottomLeft :: emptyNodes.toList).compact + pattern_333333((l + 1) * 2, h + 1).toOption.get.graphEdges.withoutNodes(topRight :: bottomLeft :: emptyNodes.toList).compact (edges, Node(edges.nodes.max(NodeOrdering).toInt - l)) /** Grid of 2 * l triangles with in between a full hexagon net @@ -39,8 +39,8 @@ trait Layered extends Reticulate: triHexBase(l, h)((i, j) => (i + invertedStep + j % 3) % 3 == 0) private val fs: Map[Int, Int => (List[Edge], Node)] = Map( - 3 -> { l => (triangleNet(l * 2, 1).toOption.get.graphEdges, Node(l + 2)) }, - 4 -> { l => (squareNet(l, 1).toOption.get.graphEdges, Node(l + 2)) }, + 3 -> { l => (pattern_333333(l * 2, 1).toOption.get.graphEdges, Node(l + 2)) }, + 4 -> { l => (pattern_4444(l, 1).toOption.get.graphEdges, Node(l + 2)) }, 36 -> { triHexBase(_, 1)((i, _) => i % 2 == 1) }, 63 -> { triHexBase(_, 1)((i, _) => i % 2 == 0) }, 336 -> { triHexBase(_, 1)((i, _) => i % 3 == 1) }, @@ -72,7 +72,7 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Elongated_triangular_tiling */ - def elongatedTriangular(width: Int, height: Int): Either[String, Tiling] = + def pattern_33344(width: Int, height: Int): Either[String, Tiling] = netVariant(List(3, 4), width, height) /** @@ -80,7 +80,7 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Trihexagonal_tiling */ - def triHexagonal(width: Int, height: Int): Either[String, Tiling] = + def pattern_3636(width: Int, height: Int): Either[String, Tiling] = netVariant(List(36, 63), width, height) /** @@ -88,7 +88,7 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons#5-uniform_tilings,_2_vertex_types_(4:1)_and_(3:2) */ - def threeUniformOneOneOne7(width: Int, height: Int): Either[String, Tiling] = + def pattern_33336_33344_3446(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 363), width, height) /** @@ -96,7 +96,7 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons#3-uniform_tilings,_3_vertex_types */ - def threeUniformOneOneOne8(width: Int, height: Int): Either[String, Tiling] = + def pattern33344_3366_3446(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 3632, 4, 6332, 4, 3362), width, height) /** @@ -104,7 +104,7 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons#5-uniform_tilings,_3_vertex_types_(3:1:1)_and_(2:2:1) */ - def fiveUniformTwoTwoOne5(width: Int, height: Int): Either[String, Tiling] = + def pattern33344_2x3366_2x3446(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 6332), width, height) /** @@ -112,7 +112,7 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons#5-uniform_tilings,_2_vertex_types_(4:1)_and_(3:2) */ - def fiveUniformFourOne2(width: Int, height: Int): Either[String, Tiling] = + def pattern_3446_4x3636(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 36, 63, 36, 63), width, height) /** @@ -120,17 +120,17 @@ trait Layered extends Reticulate: * * @see https://en.wikipedia.org/wiki/Euclidean_tilings_by_convex_regular_polygons#5-uniform_tilings,_2_vertex_types_(4:1)_and_(3:2) */ - def fiveUniformFourOne3(width: Int, height: Int): Either[String, Tiling] = + def pattern_3446_4x3636_alt(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 36, 63, 36, 63, 4, 63, 36, 63, 36), width, height) /** * @see https://probabilitysports.com/tilings.html?u=0&n=5&t=195 */ - def fiveUniformIssue1(width: Int, height: Int): Either[String, Tiling] = + def pattern_2x33344_2x3446_3636(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 3, 4, 36), width, height) /** * @see https://probabilitysports.com/tilings.html?u=0&n=5&t=194 */ - def fiveUniformIssue2(width: Int, height: Int): Either[String, Tiling] = + def pattern_2x33344_2x3446_3636_alt(width: Int, height: Int): Either[String, Tiling] = netVariant(List(4, 3, 4, 36, 4, 3, 4, 36, 4, 3, 4, 63, 4, 3, 4, 63), width, height) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/Quadratic.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/Quadratic.scala index be08ad4..7447cac 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/Quadratic.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/Quadratic.scala @@ -44,7 +44,7 @@ trait Quadratic: * @note the size in polygons is 6x^2 where x = side * @param side length in units */ - def triangularHex(side: Int): Either[String, Tiling] = + def pattern_333333(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(3₆)"), side, (i: Int) => fromTerms((6, -12, 6), i + 1), standardStrategy) /** Grows a (4*4) square of given side @@ -52,7 +52,7 @@ trait Quadratic: * @note the size in polygons is x^2 where x = side * @param side length in units */ - def squareNet(side: Int): Either[String, Tiling] = + def pattern_4444(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(4₄)"), side, fromTerms((1, 0, 0), _), standardStrategy) /** Grows a (6*3) hexoid of given side @@ -60,7 +60,7 @@ trait Quadratic: * @note the size in polygons is 3x^2-3x+1 where x = side * @param side length in hexagons (approx. √3 each) */ - def hexagonalHexoid(side: Int): Either[String, Tiling] = + def pattern_666(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(6₃)"), side, fromTerms((3, -3, 1), _), standardStrategy) /** Grows a (3*4.6) hexoid of given side @@ -68,7 +68,7 @@ trait Quadratic: * @note https://www.wolframalpha.com/input?i=quadratic+fit+%7B1%2C+19%2C+37%2C+61%2C+103%2C+139%2C+193%2C+247%2C+319%2C+391%2C+469%2C+565%7D * @param side length is ??? */ - def triHexagonalHexoid(side: Int): Either[String, Tiling] = + def pattern_33336(side: Int): Either[String, Tiling] = val strategy: FullStrategy = (List(NARROWEST_ANGLE, LOWEST_ORDINAL), List(NARROWER_ANGLE, LOWER_ORDINAL), false) val sizes: List[Int] = @@ -81,7 +81,7 @@ trait Quadratic: * @note https://www.wolframalpha.com/input/?i=quadratic+fit+%7B18%2C+78%2C+180%7D * @param side length is ??? */ - def triSquareSquaroid(side: Int): Either[String, Tiling] = + def pattern_33344(side: Int): Either[String, Tiling] = val strategy: FullStrategy = (List(LOWEST_ORDINAL), List(BEFORE_PERIMETER), true) fullOfSide(FullVertex.s("(3₃.4₂)"), side, fromTerms((21, -27, 8), _), strategy) @@ -91,7 +91,7 @@ trait Quadratic: * @note the size in polygons is 18x^2-30x+13 where x = side * @param side length in hexagons (approx. ? each) */ - def triSquareHexagonalHexoid(side: Int): Either[String, Tiling] = + def pattern_3464(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(3.4.6.4)"), side, fromTerms((18, -30, 13), _), standardStrategy) /** Grows a (3.6.3.6) hexagon of given side @@ -99,7 +99,7 @@ trait Quadratic: * @note the size in polygons is 9x^2-9x+1 where x = side * @param side length in hexagons (2x-1 units) */ - def triHexagonalHex(side: Int): Either[String, Tiling] = + def pattern_3636(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(3.6.3.6)"), side, fromTerms((9, -9, 1), _), standardStrategy) /** Grows a (3.12*2) hexoid of given side @@ -107,7 +107,7 @@ trait Quadratic: * @note the size in polygons is 9x^2-9x+1 where x = side * @param side length in dodecagons (approx. ???) */ - def triDodecagonalHexoid(side: Int): Either[String, Tiling] = + def pattern_31212(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(3.12₂)"), side, fromTerms((9, -9, 1), _), standardStrategy) /** Grows a (3₂.4.3.4) squaroid of given side @@ -115,7 +115,7 @@ trait Quadratic: * @note the size in polygons is 12x^2+16x+1 where x = side * @param side length in */ - def triSquareSquaroid2(side: Int): Either[String, Tiling] = + def pattern_33434(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(3₂.4.3.4)"), side, fromTerms((12, 16, 1), _), standardStrategyFromSmaller) /** Grows a (4.6.12) hexoid of given side @@ -123,7 +123,7 @@ trait Quadratic: * @note the size in polygons is 18x^2-6x+1 where x = side * @param side length in dodecagons (approx. ???) */ - def squareHexDodecagonalHexoid(side: Int): Either[String, Tiling] = + def pattern_4612(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(4.6.12)"), side, fromTerms((18, -6, 1), _), standardStrategy) /** Grows a (4.8*2) squaroid of given side @@ -131,5 +131,5 @@ trait Quadratic: * @note the size in polygons is 4x^2-4x+1 where x = side * @param side length in squares (approx. ? each) */ - def squareOctogonalSquaroid(side: Int): Either[String, Tiling] = + def pattern_488(side: Int): Either[String, Tiling] = fullOfSide(FullVertex.s("(4.8₂)"), side, fromTerms((4, -4, 1), _), standardStrategyFromSmaller) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/Reticulate.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/Reticulate.scala index 65523dc..70258fa 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/Reticulate.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/Reticulate.scala @@ -110,7 +110,7 @@ trait Reticulate: * @param width size must be even and greater than 0 * @param height size must be greater then 0 */ - def triangleNet(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333(width: Int, height: Int): Either[String, Tiling] = rectangular(width, height, width_even_gt_zero, height_gt_zero, triangleNetEdges) /** Creates a rectangular reticulate of width by height squares @@ -118,7 +118,7 @@ trait Reticulate: * @param width size must be greater then 0 * @param height size must be greater then 0 */ - def squareNet(width: Int, height: Int): Either[String, Tiling] = + def pattern_4444(width: Int, height: Int): Either[String, Tiling] = rectangular(width, height, width_gt_zero, height_gt_zero, squareNetEdges) /** Creates a rectangular reticulate of width by height hexagons @@ -126,15 +126,15 @@ trait Reticulate: * @param width size must be greater then 0 * @param height size must be greater then 0 */ - def hexagonNet(width: Int, height: Int): Either[String, Tiling] = + def pattern_666(width: Int, height: Int): Either[String, Tiling] = rectangular(width, height, width_gt_zero, height_gt_zero, hexagonNetEdges) /** Creates a triangle of triangles of given side */ - def triangleTriangle(side: Int): Either[String, Tiling] = + def pattern_333333_triangle(side: Int): Either[String, Tiling] = triangular(side, side_gt_zero, triangleTriangleEdges) /** Creates a trianguloid of hexagons of given side */ - def hexTrianguloid(side: Int): Either[String, Tiling] = + def pattern_666_trianguloid(side: Int): Either[String, Tiling] = triangular(side, side_gt_zero, hexTrianguloidEdges) /** Builds variants of triangle grid by emptying hex according to function @@ -174,8 +174,70 @@ trait Reticulate: cutCorners(cutCorners(edges, bottomLeft, blCorners), topRight, trCorners).compact + /** Builds variants of square grid by converting square to two triangles according to function + * + * @param x number of triangles on the x-axis + * @param y number of triangles on the y-axis + * @param f function telling if given i node in a row must be converted or not + * @param g function telling if given j row must be reversed or not + */ + private def squareNetVariant(x: Int, y: Int)(f: Int => Boolean)(g: Int => Boolean): List[Edge] = + val start: List[Edge] = + squareNetEdges(x, y) + val additional: IndexedSeq[Edge] = + for + j <- 0 until y + isRowEven = g(j) + i <- 0 until x + h = i + 1 + (x + 1) * j + if f(i) ^ isRowEven + yield + if isRowEven then + Edge(Node(h), Node(h + x + 2)) + else + Edge(Node(h + 1), Node(h + x + 1)) + start ++ additional + + def pattern_33434(width: Int, height: Int): Either[String, Tiling] = + rectangular( + width, + height, + width_gt_zero, + height_gt_zero, + squareNetVariant(_, _)(_ % 2 < 1)(_ % 2 == 0) + ) + + def pattern_33344_33434(width: Int, height: Int): Either[String, Tiling] = + rectangular( + width, + height, + width_gt_zero, + height_gt_zero, + squareNetVariant(_, _)(_ % 4 < 2)(_ % 2 == 0) + ) + + /** @see https://probabilitysports.com/tilings.html?u=0&n=3&t=53 */ + def pattern_2x33344_33434(width: Int, height: Int): Either[String, Tiling] = + rectangular( + width, + height, + width_gt_zero, + height_gt_zero, + squareNetVariant(_, _)(_ % 6 < 3)(_ % 2 == 0) + ) + + /** @see https://probabilitysports.com/tilings.html?u=0&n=3&t=23 */ + def pattern_33344_33434_4444(width: Int, height: Int): Either[String, Tiling] = + rectangular( + width, + height, + width_gt_zero, + height_gt_zero, + squareNetVariant(_, _)(_ % 3 == 0)(_ % 3 == 0) + ) + /** Uniform tessellation (3.6.3.6) (t=2, e=1) */ - def uniform(width: Int, height: Int): Either[String, Tiling] = + def pattern_3636_other(width: Int, height: Int): Either[String, Tiling] = rectangular( width, height, @@ -185,7 +247,7 @@ trait Reticulate: ) /** Uniform Tessellation (3₄.6) (t=3, e=3) */ - def uniform2(width: Int, height: Int): Either[String, Tiling] = + def pattern_33336(width: Int, height: Int): Either[String, Tiling] = rectangular( width, height, @@ -194,9 +256,8 @@ trait Reticulate: triangleNetVariant(_, _)((i, j) => (i + 2 * j) % 7 == 0) ) - /** 2-uniform Tessellation (3₄.6; 3₂.6₂) (t=2, e=4) */ - def twoUniform4(width: Int, height: Int): Either[String, Tiling] = + def pattern_33336_3366(width: Int, height: Int): Either[String, Tiling] = rectangular( width, height, @@ -206,7 +267,7 @@ trait Reticulate: ) /** 2-uniform Tessellation (3.6.3.6; 3₂.6₂) (t=2, e=3) */ - def twoUniform5(width: Int, height: Int): Either[String, Tiling] = + def pattern_3636_3366(width: Int, height: Int): Either[String, Tiling] = rectangular( width, height, @@ -216,7 +277,7 @@ trait Reticulate: ) /** 3-uniform Tessellation (3₂.6₂; 3.6.3.6; 6₃) (t=4, e=5) */ - def threeUniformOneOneOne4(width: Int, height: Int): Either[String, Tiling] = + def pattern_3366_3636_666_alt(width: Int, height: Int): Either[String, Tiling] = val f: (Int, Int) => Boolean = (i, j) => j % 5 match case e if e == 2 || e == 4 => i % 5 == (e / 2 + 1) || i % 5 == (e / 2 - 1) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/Uni4Hex.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/Uni4Hex.scala index 03d4ee6..90eda96 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/Uni4Hex.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/Uni4Hex.scala @@ -4,39 +4,39 @@ package creation /** Contains fast methods to create a [[Tiling]] from an hexagonal net with uniformity 4 */ trait Uni4Hex extends Reticulate: - /** 4-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);(6₃)] */ - def fourUniformOneOneOneOne(width: Int, height: Int): Either[String, Tiling] = + /** 4-archimedean tessellation [(3₆);(3₄.6);(3₂.6₂);(6₃)] */ + def pattern_333333_33336_3366_666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 6 < 2) - /** 4-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);(6₃)] */ - def fourUniformOneOneOneOne1(width: Int, height: Int): Either[String, Tiling] = + /** 4-archimedean tessellation [(3₆);(3₄.6);(3₂.6₂);(6₃)] */ + def pattern_333333_33336_3366_666_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 5 < 2) - /** 4-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);(6₃)] */ - def fourUniformOneOneOneOne2(width: Int, height: Int): Either[String, Tiling] = + /** 4-archimedean tessellation [(3₆);(3₄.6);(3₂.6₂);(6₃)] */ + def pattern_333333_33336_3366_666_alt2(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((_, j) => j % 3 == 0) /** 4-uniform tessellation [(3₆);(3₂.6₂);2x(6₃)] */ - def fourUniformTwoOneOne(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3366_2x666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => i % 7 == (j * 4) % 7) /** 4-uniform tessellation [(3₆);(3₂.6₂);2x(6₃)] * * @see http://probabilitysports.com/tilings.html?u=0&n=4&t=1 */ - def fourUniformTwoOneOne2(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3366_2x666_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => j % 2 == 0 && i % 6 == (j * 4) % 6) /** 4-uniform tessellation [(3₆);(3₂.6₂);2x(6₃)] */ - def fourUniformTwoOneOne3(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3366_2x666_alt2(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => ((i + 2 * j) % 6 == 0 || (i + 2 * j) % 6 == 2) && j % 2 == 0) - /** 4-uniform tessellation [(3₆);(3₂.6₂);2x(6₃)] */ - def fourUniformTwoOneOne4(width: Int, height: Int): Either[String, Tiling] = + /** 4-uniform tessellation [(3₆);2x(3₂.6₂);(6₃)] */ + def pattern_333333_2x3366_666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 3 == 0 && j % 3 < 2) - /** 4-uniform tessellation [(3₆);(3₂.6₂);2x(6₃)] */ - def fourUniformTwoOneOne5(width: Int, height: Int): Either[String, Tiling] = + /** 4-uniform tessellation [(3₆);2x(3₂.6₂);(6₃)] */ + def pattern_333333_2x3366_666_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { // alternate rows between 3 and 6 val step = (j % 2 + 1) * 3 @@ -44,11 +44,11 @@ trait Uni4Hex extends Reticulate: }) /** 4-uniform tessellation [(3₆);(3₂.6₂);2x(6₃)] */ - def fourUniformTwoOneOne6(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3366_2x666_alt3(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)(_ % 3 == 0 && _ % 3 == 0) /** 4-uniform tessellation [(3₆);2x(3₄.6);(3₂.6₂)] */ - def fourUniformTwoOneOne7(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_2x33336_3366(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j if (j % 2 == 0) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/Uni5Hex.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/Uni5Hex.scala index 3a16f4f..220aaa9 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/Uni5Hex.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/Uni5Hex.scala @@ -4,8 +4,8 @@ package creation /** Contains fast methods to create a [[Tiling]] from an hexagonal net with uniformity 5 */ trait Uni5Hex extends Reticulate: - /** 5-uniform tessellation [2x(3₆);(3₄.6);(3₂.6₂;(6₃)] */ - def fiveUniformTwoOneOneOne(width: Int, height: Int): Either[String, Tiling] = + /** 5-uniform tessellation [2x(3₆);(3₄.6);(3₂.6₂);(6₃)] */ + def pattern_2x333333_33336_3366_666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j if (j % 2 == 0) @@ -15,51 +15,50 @@ trait Uni5Hex extends Reticulate: }) /** 5-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] */ - def fiveUniformTwoOneOneOne2(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_3366_2x666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 8 < 2) + + /** 5-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] */ + def pattern_333333_33336_3366_2x666_alt(width: Int, height: Int): Either[String, Tiling] = + hexagonRect(width, height)((i, j) => (i + 2 * j) % 7 < 2) + /** 5-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] */ + def pattern_333333_33336_3366_2x666_alt2(width: Int, height: Int): Either[String, Tiling] = + hexagonRect(width, height)((i, j) => (i + j) % 4 == 0) + /** 5-uniform tessellation [(3₆);(3₄.6);2x(3₂.6₂);(6₃)] */ - def fiveUniformTwoOneOneOne3(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_2x3366_666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j pos % 7 == 0 || pos % 7 == 2 }) - - /** 5-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] */ - def fiveUniformTwoOneOneOne4(width: Int, height: Int): Either[String, Tiling] = - hexagonRect(width, height)((i, j) => (i + 2 * j) % 7 < 2) - - /** 5-uniform tessellation [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] */ - def fiveUniformTwoOneOneOne5(width: Int, height: Int): Either[String, Tiling] = - hexagonRect(width, height)((i, j) => (i + j) % 4 == 0) - /** 5-uniform tessellation [(3₆);(3₄.6);2x(3₂.6₂);(6₃)] */ - def fiveUniformTwoOneOneOne6(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_2x3366_666_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j pos % 6 == 0 || pos % 6 == 2 }) /** 5-uniform tessellation [(3₆);3x(3₂.6₂);(6₃)] */ - def fiveUniformThreeOneOne(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3x3366_666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j pos % 8 == 0 || pos % 8 == 3 }) /** 5-uniform tessellation [(3₆);3x(3₂.6₂);(6₃)] */ - def fiveUniformThreeOneOne2(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3x3366_666_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j pos % 7 == 0 || pos % 7 == 3 }) - /** 5-uniform tessellation [3x(3₆);(3₂.6₂);(6₃)] */ - def fiveUniformThreeOneOne3(width: Int, height: Int): Either[String, Tiling] = + /** 5-uniform tessellation [3x(3₆);(3₄.6);(3₂.6₂)] */ + def pattern_3x333333_33336_3366(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 6 > 1) /** 5-uniform tessellation [3x(3₆);(3₂.6₂);(6₃)] */ - def fiveUniformThreeOneOne4(width: Int, height: Int): Either[String, Tiling] = + def pattern_3x333333_33336_3366_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j if (j % 2 == 0) @@ -72,24 +71,24 @@ trait Uni5Hex extends Reticulate: * * @see http://probabilitysports.com/tilings.html?u=0&n=5&t=2 */ - def fiveUniformTwoTwoOne(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_2x3366_2x666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => i % 7 == (j * 3) % 7) - /** 5-uniform tessellation [2x(3₆);(3₄.6);2x(3₂.6₂)] */ - def fiveUniformTwoTwoOne2(width: Int, height: Int): Either[String, Tiling] = - hexagonRect(width, height)((i, j) => i % 3 == j % 3 || (i % 3 == 0 && j % 3 == 1)) - /** 5-uniform tessellation [(3₆);2x(3₂.6₂);2x(6₃)] */ - def fiveUniformTwoTwoOne3(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_2x3366_2x666_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 6 == 0) + /** 5-uniform tessellation [2x(3₆);(3₄.6);2x(3₂.6₂)] */ + def pattern_2x333333_33336_2x3366(width: Int, height: Int): Either[String, Tiling] = + hexagonRect(width, height)((i, j) => i % 3 == j % 3 || (i % 3 == 0 && j % 3 == 1)) + /** 5-uniform tessellation [2x(3₆);2x(3₄.6);(3₂.6₂)] */ - def fiveUniformTwoTwoOne4(width: Int, height: Int): Either[String, Tiling] = + def pattern_2x333333_2x33336_3366(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => { val pos = i + 2 * j pos % 5 == 1 || pos % 5 > 2 }) /** 5-uniform tessellation [4x(3₆);(3₄.6)] */ - def fiveUniformFourOne(width: Int, height: Int): Either[String, Tiling] = + def pattern_4x333333_33336(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)(_ % 3 != 0 || _ % 3 != 0) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/UniHex.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/UniHex.scala index 23525e1..e315089 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/UniHex.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/UniHex.scala @@ -5,32 +5,32 @@ package creation trait UniHex extends Reticulate: /** 2-uniform tessellation [(3₆);(3₂.6₂)] (t=2, e=3) */ - def twoUniform(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_3366(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)(_ % 3 == _ % 3) /** 2-uniform tessellation [(3₆);(3₄.6)] (t=3, e=3) * * @note obtainable also with a triangleNetVariant(_, _)(_ % 3 == 0 && _ % 3 == 0) */ - def twoUniform2(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)(_ % 3 != _ % 3) - /** 3-uniform tessellation [(3₆);(3₂.6₂;(6₃)] (t=2, e=3) */ - def threeUniformOneOneOne(width: Int, height: Int): Either[String, Tiling] = + /** 3-uniform tessellation [(3₆);(3₂.6₂);(6₃)] (t=2, e=3) */ + def pattern_333333_3366_666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)(_ % 2 == 0 && _ % 2 == 0) /** 3-uniform tessellation [(3₆);(3₄.6);(3₂.6₂)] (t=5, e=8) */ - def threeUniformOneOneOne2(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_3366(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => (i + 2 * j) % 4 < 2) /** 3-uniform tessellation [(3₆);(3₄.6);(3₂.6₂)] (t=3, e=5) */ - def threeUniformOneOneOne3(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_3366_alt(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((_, j) => j % 2 == 0) /** 3-uniform tessellation [2x(3₆);(3₄.6)] (t=3, e=4) */ - def threeUniformTwoOne(width: Int, height: Int): Either[String, Tiling] = + def pattern_2x333333_33336(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)(_ % 2 == 0 || _ % 2 == 0) /** 7-uniform tessellation [(3₆);2x(3₂.6₂);4x(6₃)] */ - def sevenUniformFourTwoOne(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_2x3366_4x666(width: Int, height: Int): Either[String, Tiling] = hexagonRect(width, height)((i, j) => i % 10 == (j * 8) % 10) diff --git a/src/main/scala/io/github/scala_tessella/tessella/creation/UniTriangle.scala b/src/main/scala/io/github/scala_tessella/tessella/creation/UniTriangle.scala index a4d2d35..0d40343 100644 --- a/src/main/scala/io/github/scala_tessella/tessella/creation/UniTriangle.scala +++ b/src/main/scala/io/github/scala_tessella/tessella/creation/UniTriangle.scala @@ -5,17 +5,17 @@ package creation trait UniTriangle extends Reticulate: /** 2-uniform tessellation [(3₆);(3₄.6)] (t=5, e=7) */ - def twoUniform3(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_alt(width: Int, height: Int): Either[String, Tiling] = triangleRect(width, height)((i, j) => (i + 3 * j) % 13 == 0) /** 3-uniform tessellation [(3₂.6₂);(3.6.3.6);(6₃)] (t=2, e=4) */ - def threeUniformOneOneOne5(width: Int, height: Int): Either[String, Tiling] = + def pattern_3366_3636_666(width: Int, height: Int): Either[String, Tiling] = triangleRect(width, height)((i, j) => (i + 3 * j) % 7 == 0 || (i + 3 * j) % 7 == 2) /** 3-uniform tessellation [(3₆);(3₄.6);(3.6.3.6)] (t=5, e=6) */ - def threeUniformOneOneOne6(width: Int, height: Int): Either[String, Tiling] = + def pattern_333333_33336_3636(width: Int, height: Int): Either[String, Tiling] = triangleRect(width, height)((i, j) => (i + 4 * j) % 8 == 0) /** 4-uniform tessellation [2x(3₆);(3₄.6);(3₂.6₂)] */ - def fourUniformTwoOneOne8(width: Int, height: Int): Either[String, Tiling] = + def pattern_2x333333_33336_3366(width: Int, height: Int): Either[String, Tiling] = triangleRect(width, height)((i, j) => (i + 1 * j) % 8 == 0) diff --git a/src/test/scala/io/github/scala_tessella/tessella/GonalitySpec.scala b/src/test/scala/io/github/scala_tessella/tessella/GonalitySpec.scala index 9e4a34a..bb8da9b 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/GonalitySpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/GonalitySpec.scala @@ -12,7 +12,7 @@ import org.scalatest.matchers.* class GonalitySpec extends AnyFlatSpec with Helper with should.Matchers { "A 3 uniform tiling" can "return a map of full vertices and the nodes where they form" in { - uniform3gonal2.groupGonals shouldBe + p2x333333_33336.groupGonals shouldBe Map( Vector(3, 3, 3, 3, 6) -> List(24, 37, 14, 33, 13, 17, 34, 22, 27, 35, 26, 23, 15), Vector(3, 3, 3, 3, 3, 3) -> List(56, 25, 52, 57, 60, 53, 32, 59, 12, 54, 49, 50, 16, 55, 58, 36, 51) diff --git a/src/test/scala/io/github/scala_tessella/tessella/GraphPolygonsSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/GraphPolygonsSpec.scala index 7ee9fa8..965d9b6 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/GraphPolygonsSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/GraphPolygonsSpec.scala @@ -9,7 +9,7 @@ import org.scalatest.matchers.* class GraphPolygonsSpec extends AnyFlatSpec with Helper with should.Matchers { "A sqr4x4Reticulate" can "be divided in oriented polygons" in { - sqr4x4Reticulate.tilingOrientedPolygons shouldBe + p4444_4by4_reticulate.tilingOrientedPolygons shouldBe Option( List( Vector(17, 22, 21, 16), Vector(11, 6, 7, 12), Vector(7, 6, 1, 2), Vector(18, 23, 22, 17), @@ -21,7 +21,7 @@ class GraphPolygonsSpec extends AnyFlatSpec with Helper with should.Matchers { } "A triHexOfSide3" can "be divided in oriented polygons" in { - triHexOfSide3.tilingOrientedPolygons shouldBe + p333333_grown_hexagon.tilingOrientedPolygons shouldBe Option( List( Vector(12, 26, 27), Vector(13, 27, 28), Vector(28, 29, 13), Vector(11, 24, 25), Vector(25, 26, 11), @@ -52,7 +52,7 @@ class GraphPolygonsSpec extends AnyFlatSpec with Helper with should.Matchers { } "A hex4x4Reticulate" can "be divided in oriented polygons" in { - hex4x4Reticulate.tilingOrientedPolygons shouldBe + p666_4by4_reticulate.tilingOrientedPolygons shouldBe Option( List( Vector(37, 46, 47, 48, 39, 38), Vector(44, 45, 46, 37, 36, 35), Vector(32, 31, 40, 41, 42, 33), @@ -110,7 +110,7 @@ class GraphPolygonsSpec extends AnyFlatSpec with Helper with should.Matchers { } "A uniform7gonal3" can "be divided in oriented polygons" in { - uniform7gonal3.tilingOrientedPolygons shouldBe + p333333_2x3366_4x666.tilingOrientedPolygons shouldBe Option( List( Vector(183, 171, 172), Vector(170, 171, 183), Vector(176, 177, 178, 161, 160, 159), @@ -150,7 +150,7 @@ class GraphPolygonsSpec extends AnyFlatSpec with Helper with should.Matchers { } "A uniform3gonal2" can "be divided in oriented polygons" in { - uniform3gonal2.tilingOrientedPolygons shouldBe + p2x333333_33336.tilingOrientedPolygons shouldBe Option( List( Vector(1, 2, 49), Vector(49, 10, 1), Vector(38, 39, 48, 47, 46, 37), Vector(55, 5, 6), Vector(6, 7, 55), diff --git a/src/test/scala/io/github/scala_tessella/tessella/GraphSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/GraphSpec.scala index a3df575..4d552a2 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/GraphSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/GraphSpec.scala @@ -9,7 +9,7 @@ import org.scalatest.matchers.should class GraphSpec extends AnyFlatSpec with should.Matchers { val reticulate: Graph = - Graph(sqr4x4Reticulate.graphEdges) + Graph(p4444_4by4_reticulate.graphEdges) "A path of a graph" can "be created" in { reticulate.Path(Vector(1, 2, 3, 4, 5, 10, 15, 20, 25).map(Node(_))) shouldEqual diff --git a/src/test/scala/io/github/scala_tessella/tessella/Helper.scala b/src/test/scala/io/github/scala_tessella/tessella/Helper.scala index 71f37aa..c048062 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/Helper.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/Helper.scala @@ -40,7 +40,7 @@ trait Helper extends Accuracy: Tiling.fromPolygon(12) lazy val sixSquares: Tiling = - Tiling.squareNet(3, 2).unsafe + Tiling.pattern_4444(3, 2).unsafe extension (maybe: Either[_, Tiling]) @@ -73,7 +73,7 @@ trait Helper extends Accuracy: coords.compareElems(others)((l1, l2) => l1._1 == l2._1 && l1._2.almostEquals(l2._2, LESSER_ACCURACY)) def squareReticulate(side: Int): Tiling = - Tiling.squareNet(side, side).unsafe + Tiling.pattern_4444(side, side).unsafe private def saveFile(elem: Elem, filename: String)(extension: String): Unit = XML.save( diff --git a/src/test/scala/io/github/scala_tessella/tessella/Outliers.scala b/src/test/scala/io/github/scala_tessella/tessella/Outliers.scala index 9409512..e7c5b69 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/Outliers.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/Outliers.scala @@ -1,38 +1,38 @@ package io.github.scala_tessella.tessella import RegularPolygon.{Polygon, Vertex} -import Tiling.squareNet +import Tiling.pattern_4444 import TilingGrowth.* import Topology.* object Outliers extends Helper: - lazy val tri4x4Reticulate: Tiling = - Tiling.triangleNet(4, 4).unsafe + lazy val p333333_4by4_reticulate: Tiling = + Tiling.pattern_333333(4, 4).unsafe - lazy val triHexOfSide3: Tiling = - Tiling.triangularHex(3).unsafe + lazy val p333333_grown_hexagon: Tiling = + Tiling.pattern_333333(3).unsafe - lazy val sqr4x4Reticulate: Tiling = - Tiling.squareNet(4, 4).unsafe + lazy val p4444_4by4_reticulate: Tiling = + Tiling.pattern_4444(4, 4).unsafe - lazy val sqr3x3Growth: Tiling = - Tiling.squareNet(3).unsafe + lazy val p4444_3by3_grown: Tiling = + Tiling.pattern_4444(3).unsafe - lazy val hex4x4Reticulate: Tiling = - Tiling.hexagonNet(4, 4).unsafe + lazy val p666_4by4_reticulate: Tiling = + Tiling.pattern_666(4, 4).unsafe - lazy val hexHexOfSide3: Tiling = - Tiling.hexagonalHexoid(3).unsafe + lazy val p666_grown_hexagon: Tiling = + Tiling.pattern_666(3).unsafe - lazy val triangleTriangleOfSide5: Tiling = - Tiling.triangleTriangle(5).unsafe + lazy val p333333_triangle: Tiling = + Tiling.pattern_333333_triangle(5).unsafe - lazy val hexTrianguloidOfSide4: Tiling = - Tiling.hexTrianguloid(4).unsafe + lazy val p666_triangle: Tiling = + Tiling.pattern_666_trianguloid(4).unsafe lazy val gonExperiment: Tiling = - Tiling.maybe(sqr3x3Growth.graphEdges ++ List( + Tiling.maybe(p4444_3by3_grown.graphEdges ++ List( 8--17, 17--18, 18--19, 19--20, 20--9, 10--21, 21--11, 16--22, 22--5, 22--23, 23--5, @@ -55,41 +55,41 @@ object Outliers extends Helper: lazy val pentagonGrown: Tiling = TilingGrowth.maybePolygonGrow(Polygon(5), 10).unsafe - lazy val sqrOctSquaroid: Tiling = - Tiling.squareOctogonalSquaroid(2).unsafe + lazy val p488: Tiling = + Tiling.pattern_488(2).unsafe - lazy val sqrHexDodHexoid: Tiling = - Tiling.squareHexDodecagonalHexoid(2).unsafe + lazy val p4612: Tiling = + Tiling.pattern_4612(2).unsafe - lazy val triDodHexoid: Tiling = - Tiling.triDodecagonalHexoid(2).unsafe + lazy val p31212: Tiling = + Tiling.pattern_31212(2).unsafe - lazy val triHexHex: Tiling = - Tiling.triHexagonalHex(2).unsafe + lazy val p3636: Tiling = + Tiling.pattern_3636(2).unsafe - lazy val triSqrHexHexoid: Tiling = - Tiling.triSquareHexagonalHexoid(2).unsafe + lazy val p3464: Tiling = + Tiling.pattern_3464(2).unsafe - lazy val triSqrSquaroid: Tiling = - Tiling.triSquareSquaroid(2).unsafe + lazy val p33444: Tiling = + Tiling.pattern_33344(2).unsafe - val triSqrSquaroid2: Tiling = - Tiling.triSquareSquaroid2(2).unsafe + val p33434: Tiling = + Tiling.pattern_33434(2).unsafe - lazy val triHexHexoid: Tiling = - Tiling.triHexagonalHexoid(4).unsafe + lazy val p33336: Tiling = + Tiling.pattern_33336(4).unsafe - lazy val uniform3gonal2: Tiling = - Tiling.threeUniformTwoOne(4, 4).unsafe + lazy val p2x333333_33336: Tiling = + Tiling.pattern_2x333333_33336(4, 4).unsafe - lazy val uniform7gonal3: Tiling = - Tiling.sevenUniformFourTwoOne(8, 9).unsafe + lazy val p333333_2x3366_4x666: Tiling = + Tiling.pattern_333333_2x3366_4x666(8, 9).unsafe - val uniform5gonal3: Tiling = - Tiling.fiveUniformTwoTwoOne4(6, 6).unsafe + val p2x333333_2x33336_3366: Tiling = + Tiling.pattern_2x333333_2x33336_3366(6, 6).unsafe - val uniform4gonal4: Tiling = - Tiling.fourUniformOneOneOneOne(6, 6).unsafe + val p333333_33336_3366_666: Tiling = + Tiling.pattern_333333_33336_3366_666(6, 6).unsafe val uniform6: Tiling = Tiling.maybe( @@ -179,10 +179,10 @@ object Outliers extends Helper: ).unsafe val uniform5v1: Tiling = - Tiling.fiveUniformIssue1(18, 12).unsafe + Tiling.pattern_2x33344_2x3446_3636(18, 12).unsafe val uniform5v2: Tiling = - Tiling.fiveUniformIssue2(18, 12).unsafe + Tiling.pattern_2x33344_2x3446_3636_alt(18, 12).unsafe private val triangleEdges = triangle.graphEdges @@ -443,10 +443,10 @@ object Outliers extends Helper: Tiling.fromVertex(Vertex(3, 3, 3, 3, 3)) lazy val minimalSquareInsertion: Tiling = - Tiling.maybe(squareNet(3, 2).unsafe.graphEdges.filterNot(_ == 2--3)).unsafe + Tiling.maybe(pattern_4444(3, 2).unsafe.graphEdges.filterNot(_ == 2--3)).unsafe lazy val troubledGrowthByFullVertex: Tiling = - Tiling.maybe(Tiling.triangleNet(4, 3).unsafe.graphEdges.diff(List(1--4, 4--7))).unsafe + Tiling.maybe(Tiling.pattern_333333(4, 3).unsafe.graphEdges.diff(List(1--4, 4--7))).unsafe val problematicEdges: List[Edge] = List( diff --git a/src/test/scala/io/github/scala_tessella/tessella/PatternSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/PatternSpec.scala index 2a6df38..0c0a8b6 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/PatternSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/PatternSpec.scala @@ -4,7 +4,7 @@ import org.scalatest.* import org.scalatest.flatspec.* import org.scalatest.matchers.* -class PatternSpec extends AnyFlatSpec with should.Matchers { +class PatternSpec extends AnyFlatSpec with Helper with should.Matchers { val pattern: Pattern = Pattern(List( @@ -87,5 +87,55 @@ class PatternSpec extends AnyFlatSpec with should.Matchers { Pattern.maybe("[2x(3₂.4.3.4);(q)]") shouldBe Left("malformed pattern") } + + "A pattern" can "be checked for having the same polygons of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").hasSamePolygonsOf(Tiling.pattern_2x33344_33434(6, 6).unsafe) shouldBe + true + } + + it can "be checked for NOT having the same polygons of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").hasSamePolygonsOf(Tiling.pattern_333333(6, 6).unsafe) shouldBe + false + } + + it can "be checked for having all the polygons of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").containsAllPolygonsOf(Tiling.pattern_333333(6, 6).unsafe) shouldBe + true + } + + "A pattern" can "be checked for having the same vertex configurations of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").hasSameFullVerticesOf(Tiling.pattern_2x33344_33434(6, 6).unsafe) shouldBe + true + } + + it can "be checked for NOT having the same vertex configurations of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").hasSameFullVerticesOf(Tiling.pattern_333333(6, 6).unsafe) shouldBe + false + } + + it can "be checked for having all the vertex configurations of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").containsAllFullVerticesOf(Tiling.pattern_33434(6, 6).unsafe) shouldBe + true + } + + "A pattern" can "be checked for having the same symmetry classes of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").hasSameSymmetryClassesOf(Tiling.pattern_2x33344_33434(6, 6).unsafe) shouldBe + true + } + + it can "be checked for NOT having the same symmetry classes of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").hasSameSymmetryClassesOf(Tiling.pattern_333333(6, 6).unsafe) shouldBe + false + } + + it can "be checked for having all the symmetry classes of a tiling" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]").containsAllSymmetryClassesOf(Tiling.pattern_33434(6, 6).unsafe) shouldBe + true + } + + it can "be checked for NOT having all the symmetry classes of a tiling" in { + Pattern.s("[(3.4₂.6);(3.6.3.6)]").containsAllSymmetryClassesOf(Tiling.pattern_3446_4x3636(10, 10).unsafe) shouldBe + false + } } diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingEqualitySpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingEqualitySpec.scala index eb68dc5..7a5e3f9 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingEqualitySpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingEqualitySpec.scala @@ -1,6 +1,6 @@ package io.github.scala_tessella.tessella -import Outliers.{edges12Nodes8, edges12Nodes8Similar, minimalDifferentFromItsPeri, sqr4x4Reticulate} +import Outliers.{edges12Nodes8, edges12Nodes8Similar, minimalDifferentFromItsPeri, p4444_4by4_reticulate} import TilingGrowth.* import Topology.{--, Edge, Node} @@ -22,7 +22,7 @@ class TilingEqualitySpec extends AnyFlatSpec with Helper with ring_seq.Iterating List(onePgonTenEdges, twoPgonsFiveEdges) } val twoPgonsSevenEdges: Tiling = - Tiling.squareNet(1, 2).unsafe + Tiling.pattern_4444(1, 2).unsafe "Two tilings" can "have the same number of polygons" in { twoPgonsSevenEdges.countPolygons shouldEqual @@ -67,7 +67,7 @@ class TilingEqualitySpec extends AnyFlatSpec with Helper with ring_seq.Iterating } val twoSquares: Tiling = - Tiling.squareNet(1, 2).unsafe + Tiling.pattern_4444(1, 2).unsafe "A Tiling" must "be equal to itself" in { twoSquares shouldEqual twoSquares @@ -122,8 +122,8 @@ class TilingEqualitySpec extends AnyFlatSpec with Helper with ring_seq.Iterating } "Two square nets" must "be equal" in { - Tiling.squareNet(4).unsafe shouldEqual - sqr4x4Reticulate + Tiling.pattern_4444(4).unsafe shouldEqual + p4444_4by4_reticulate } "Two tilings" must "be equal in rounded path angles" in { @@ -190,7 +190,7 @@ class TilingEqualitySpec extends AnyFlatSpec with Helper with ring_seq.Iterating // } val t: Tiling = - sqr4x4Reticulate.maybeRemoveNode(Node(21)).flatMap(_.maybeRemoveNode(Node(5))).unsafe + p4444_4by4_reticulate.maybeRemoveNode(Node(21)).flatMap(_.maybeRemoveNode(Node(5))).unsafe "A tiling" can "have two separate inner tilings" in { t.nestedTilings(isStrict = false) shouldBe @@ -207,7 +207,7 @@ class TilingEqualitySpec extends AnyFlatSpec with Helper with ring_seq.Iterating } "Another tiling" can "have only one inner tiling" in { - sqr4x4Reticulate.nestedTilings(isStrict = false) shouldBe + p4444_4by4_reticulate.nestedTilings(isStrict = false) shouldBe List( List( List( @@ -221,7 +221,7 @@ class TilingEqualitySpec extends AnyFlatSpec with Helper with ring_seq.Iterating } val aTriangleNet: Tiling = - Tiling.triangleNet(6, 3).unsafe + Tiling.pattern_333333(6, 3).unsafe "A triangle net" can "return the concentric polygons" in { aTriangleNet.nestedTilings(isStrict = false) shouldBe diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthEdgeSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthEdgeSpec.scala index 1c7e530..580cff6 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthEdgeSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthEdgeSpec.scala @@ -51,14 +51,14 @@ class TilingGrowthEdgeSpec extends AnyFlatSpec with Helper with should.Matchers // } "A tiling" can "NOT have a polygon added to a non existing edge" in { - Tiling.squareNet(2, 2).unsafe.maybeGrowEdge(1--5, Polygon(4), BEFORE_PERIMETER).left.getOrElse("").take(83) shouldBe + Tiling.pattern_4444(2, 2).unsafe.maybeGrowEdge(1--5, Polygon(4), BEFORE_PERIMETER).left.getOrElse("").take(83) shouldBe """Tiling can add polygons only to perimeter edges: | found unknown edge 1--5. |See SVG:""".stripMargin } it can "NOT have a polygon added to a non perimeter edge" in { - Tiling.squareNet(2, 2).unsafe.maybeGrowEdge(2--5, Polygon(4), BEFORE_PERIMETER).left.getOrElse("").take(81) shouldBe + Tiling.pattern_4444(2, 2).unsafe.maybeGrowEdge(2--5, Polygon(4), BEFORE_PERIMETER).left.getOrElse("").take(81) shouldBe """Tiling can add polygons only to perimeter edges: | found inner edge 2--5. |See SVG:""".stripMargin diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodePolygonSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodePolygonSpec.scala index f97c13c..400f318 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodePolygonSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthNodePolygonSpec.scala @@ -213,7 +213,7 @@ class TilingGrowthNodePolygonSpec extends AnyFlatSpec with Helper with should.Ma } val intersectTestbed: Tiling = - Tiling.maybe(Tiling.squareNet(3, 3).unsafe.graphEdges.diff(List(2--3, 6--7))).unsafe + Tiling.maybe(Tiling.pattern_4444(3, 3).unsafe.graphEdges.diff(List(2--3, 6--7))).unsafe it can "NOT have a vertex growing node 3 starting from 7 to intersect some perimeter edges" in { ( diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthSpec.scala index 15da486..cf8370a 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingGrowthSpec.scala @@ -8,7 +8,7 @@ import RegularPolygon.{Polygon, Vertex} import Topology.{--, EdgeOrdering, Node} import Geometry.Radian.{TAU_2, TAU_3, TAU_4, TAU_6} import TilingSymmetry.countSymmetries -import Tiling.squareNet +import Tiling.pattern_4444 import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should @@ -29,17 +29,17 @@ class TilingGrowthSpec extends AnyFlatSpec with Helper with should.Matchers { } "A reticulate of triangles" can "have a perimeter node removed" in { - tri4x4Reticulate.maybeRemoveNode(Node(1)).getOrElse(triangle).toString shouldBe + p333333_4by4_reticulate.maybeRemoveNode(Node(1)).getOrElse(triangle).toString shouldBe "Tiling(1--2, 1--4, 1--5, 2--5, 3--4, 3--6, 3--7, 4--5, 4--7, 4--8, 5--8, 6--7, 6--9, 6--10, 7--8, 7--10, 7--11, 8--11, 9--10, 9--12, 9--13, 10--11, 10--13, 10--14, 11--14, 12--13, 13--14)" } it can "have an inner node removed" in { - tri4x4Reticulate.maybeRemoveNode(Node(5)).isRight shouldBe + p333333_4by4_reticulate.maybeRemoveNode(Node(5)).isRight shouldBe true } it can "fail to have another perimeter node removed" in { - tri4x4Reticulate.maybeRemoveNode(Node(2)).isRight shouldBe + p333333_4by4_reticulate.maybeRemoveNode(Node(2)).isRight shouldBe false } diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingPerimeterSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingPerimeterSpec.scala index 1cceb43..e5cf2ee 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingPerimeterSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingPerimeterSpec.scala @@ -21,48 +21,48 @@ class TilingPerimeterSpec extends AnyFlatSpec with IteratingOps with SymmetryOps "The perimeter of sqr4x4Reticulate" can "have symmetries" in { ( - sqr4x4Reticulate.perimeterRotationalSymmetry, - sqr4x4Reticulate.orderedPerimeterAngles.symmetryIndices, - sqr4x4Reticulate.perimeterReflectionSymmetry + p4444_4by4_reticulate.perimeterRotationalSymmetry, + p4444_4by4_reticulate.orderedPerimeterAngles.symmetryIndices, + p4444_4by4_reticulate.perimeterReflectionSymmetry ) shouldBe (4, List(0, 4, 8, 12), 4) } it can "have reduced fillable nodes thanks to symmetries" in { - sqr4x4Reticulate.perimeterDistinctSymmetricNodes shouldBe + p4444_4by4_reticulate.perimeterDistinctSymmetricNodes shouldBe Vector(11, 6, 1) } "The perimeter of tri4x4Reticulate" can "have symmetries" in { ( - tri4x4Reticulate.perimeterRotationalSymmetry, - tri4x4Reticulate.orderedPerimeterAngles.symmetryIndices, - tri4x4Reticulate.perimeterReflectionSymmetry + p333333_4by4_reticulate.perimeterRotationalSymmetry, + p333333_4by4_reticulate.orderedPerimeterAngles.symmetryIndices, + p333333_4by4_reticulate.perimeterReflectionSymmetry ) shouldBe (2, Nil, 0) } it can "have reduced fillable nodes thanks to symmetries" in { - tri4x4Reticulate.perimeterDistinctSymmetricNodes shouldBe + p333333_4by4_reticulate.perimeterDistinctSymmetricNodes shouldBe Vector(1, 2, 3, 6, 9, 12) } "The perimeter of hex4x4Reticulate" can "have symmetries" in { ( - hex4x4Reticulate.perimeterRotationalSymmetry, - hex4x4Reticulate.orderedPerimeterAngles.symmetryIndices, - hex4x4Reticulate.perimeterReflectionSymmetry + p666_4by4_reticulate.perimeterRotationalSymmetry, + p666_4by4_reticulate.orderedPerimeterAngles.symmetryIndices, + p666_4by4_reticulate.perimeterReflectionSymmetry ) shouldBe (2, List(0, 15), 2) } it can "have reduced fillable nodes thanks to symmetries" in { - hex4x4Reticulate.perimeterDistinctSymmetricNodes shouldBe + p666_4by4_reticulate.perimeterDistinctSymmetricNodes shouldBe Vector(8, 7, 6, 5, 4, 3, 2, 1) } val asymmetricalHex: Tiling = - Tiling.hexagonNet(4, 3).unsafe + Tiling.pattern_666(4, 3).unsafe "The perimeter of asymmetricalHex" can "have symmetries" in { ( diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingSpec.scala index 0710bc9..0738d8c 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingSpec.scala @@ -2,45 +2,44 @@ package io.github.scala_tessella.tessella import Geometry.* import Geometry.Radian.{TAU_2, TAU_3, TAU_4, TAU_6} -import Outliers.* +import Outliers.{p4444_4by4_reticulate, *} import RegularPolygon.{Polygon, Vertex} -import TilingSymmetry.{countSymmetries, countRotationalSymmetries} +import TilingSymmetry.{countRotationalSymmetries, countSymmetries} import Topology.* import utility.Utils.{mapKeys, mapValues2} - import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { - val path1: sqr4x4Reticulate.Path = - sqr4x4Reticulate.Path(Vector(1, 2, 3, 4, 5, 10, 15, 20, 25).map(Node(_))) + val path1: p4444_4by4_reticulate.Path = + p4444_4by4_reticulate.Path(Vector(1, 2, 3, 4, 5, 10, 15, 20, 25).map(Node(_))) - val path2: sqr4x4Reticulate.Path = - sqr4x4Reticulate.Path(Vector(1, 2, 7, 8).map(Node(_))) + val path2: p4444_4by4_reticulate.Path = + p4444_4by4_reticulate.Path(Vector(1, 2, 7, 8).map(Node(_))) - val ringPath1: sqr4x4Reticulate.PolygonPath = - sqr4x4Reticulate.PolygonPath(Vector(1, 2, 7, 6).map(Node(_))) + val ringPath1: p4444_4by4_reticulate.PolygonPath = + p4444_4by4_reticulate.PolygonPath(Vector(1, 2, 7, 6).map(Node(_))) - val ringPath2: sqr4x4Reticulate.PolygonPath = - sqr4x4Reticulate.PolygonPath(Vector(3, 2, 7, 8).map(Node(_))) + val ringPath2: p4444_4by4_reticulate.PolygonPath = + p4444_4by4_reticulate.PolygonPath(Vector(3, 2, 7, 8).map(Node(_))) - val ringPath3: sqr4x4Reticulate.PolygonPath = - sqr4x4Reticulate.PolygonPath(Vector(6, 7, 12, 11).map(Node(_))) + val ringPath3: p4444_4by4_reticulate.PolygonPath = + p4444_4by4_reticulate.PolygonPath(Vector(6, 7, 12, 11).map(Node(_))) - val ringPath4: sqr4x4Reticulate.PolygonPath = - sqr4x4Reticulate.PolygonPath(Vector(8, 7, 12, 13).map(Node(_))) + val ringPath4: p4444_4by4_reticulate.PolygonPath = + p4444_4by4_reticulate.PolygonPath(Vector(8, 7, 12, 13).map(Node(_))) - val full: List[sqr4x4Reticulate.PolygonPath] = + val full: List[p4444_4by4_reticulate.PolygonPath] = List(ringPath1, ringPath2, ringPath3, ringPath4) "A tiling" must "have a perimeter as a circular path" in { - sqr4x4Reticulate.perimeter shouldEqual + p4444_4by4_reticulate.perimeter shouldEqual Vector(1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 16, 11, 6) } it must "have a map of perimeter polygons as circular paths" in { - sqr4x4Reticulate.perimeterOrderedPolygonPaths shouldEqual + p4444_4by4_reticulate.perimeterOrderedPolygonPaths shouldEqual Map( 5 -> Vector(Vector(5, 10, 9, 4)), 10 -> Vector(Vector(10, 15, 14, 9), Vector(10, 9, 4, 5)), @@ -146,8 +145,8 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { "A sqr4x4Reticulate" can "have perimeter nodes and perimeter path angles" in { ( - sqr4x4Reticulate.perimeter.toRingNodes, - sqr4x4Reticulate.orderedPerimeterAngles, + p4444_4by4_reticulate.perimeter.toRingNodes, + p4444_4by4_reticulate.orderedPerimeterAngles, ) shouldBe ( Vector(1, 2, 3, 4, 5, 10, 15, 20, 25, 24, 23, 22, 21, 16, 11, 6), @@ -160,9 +159,9 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { it must "have perimeter length, area and compactness measured" in { ( - sqr4x4Reticulate.perimeterLength, - sqr4x4Reticulate.area, - sqr4x4Reticulate.compactness + p4444_4by4_reticulate.perimeterLength, + p4444_4by4_reticulate.area, + p4444_4by4_reticulate.compactness ) shouldBe (16, 16.000000000000004, 0.7853981633974484) } @@ -179,24 +178,24 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { Point(3, 4), Point(4, 4), Point(4, 3), Point(4, 2), Point(4, 1), Point(4, 0), Point(3, 0), Point(2, 0), Point(1, 0) ) - sqr4x4Reticulate.perimeterPoints.almostEquals(expected) shouldBe + p4444_4by4_reticulate.perimeterPoints.almostEquals(expected) shouldBe true } it must "have a gonality value" in { - sqr4x4Reticulate.gonality shouldBe + p4444_4by4_reticulate.gonality shouldBe 1 } it can "be checked for reflectional and rotational symmetry" in { - (sqr4x4Reticulate.countSymmetries, sqr4x4Reticulate.countRotationalSymmetries) shouldBe + (p4444_4by4_reticulate.countSymmetries, p4444_4by4_reticulate.countRotationalSymmetries) shouldBe (4, 4) } "A tri4x4Reticulate" can "have perimeter nodes and perimeter path angles" in { ( - tri4x4Reticulate.perimeter.toRingNodes, - tri4x4Reticulate.orderedPerimeterAngles, + p333333_4by4_reticulate.perimeter.toRingNodes, + p333333_4by4_reticulate.orderedPerimeterAngles, ) shouldBe ( Vector(1, 2, 3, 6, 9, 12, 15, 14, 13, 10, 7, 4), @@ -206,27 +205,27 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { it must "have perimeter length, area and compactness measured" in { ( - tri4x4Reticulate.perimeterLength, - tri4x4Reticulate.area, - tri4x4Reticulate.compactness + p333333_4by4_reticulate.perimeterLength, + p333333_4by4_reticulate.area, + p333333_4by4_reticulate.compactness ) shouldBe (12, 6.928203230275511, 0.6045997880780728) } it must "have a gonality value" in { - tri4x4Reticulate.gonality shouldBe + p333333_4by4_reticulate.gonality shouldBe 1 } it can "be checked for reflectional and rotational symmetry" in { - (tri4x4Reticulate.countSymmetries, tri4x4Reticulate.countRotationalSymmetries) shouldBe + (p333333_4by4_reticulate.countSymmetries, p333333_4by4_reticulate.countRotationalSymmetries) shouldBe (0, 2) } "A hex4x4Reticulate" can "have perimeter nodes and perimeter path angles" in { ( - hex4x4Reticulate.perimeter.toRingNodes, - hex4x4Reticulate.orderedPerimeterAngles, + p666_4by4_reticulate.perimeter.toRingNodes, + p666_4by4_reticulate.orderedPerimeterAngles, ) shouldBe ( Vector( @@ -242,21 +241,21 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } it must "have a gonality value" in { - hex4x4Reticulate.gonality shouldBe + p666_4by4_reticulate.gonality shouldBe 1 } it must "have perimeter length, area and compactness measured" in { ( - hex4x4Reticulate.perimeterLength, - hex4x4Reticulate.area, - hex4x4Reticulate.compactness + p666_4by4_reticulate.perimeterLength, + p666_4by4_reticulate.area, + p666_4by4_reticulate.compactness ) shouldBe (30, 41.569219381653056, 0.5804157965549497) } it can "be checked for reflectional and rotational symmetry" in { - (hex4x4Reticulate.countSymmetries, hex4x4Reticulate.countRotationalSymmetries) shouldBe + (p666_4by4_reticulate.countSymmetries, p666_4by4_reticulate.countRotationalSymmetries) shouldBe (2, 2) } @@ -270,8 +269,8 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { 4 } - val polygonPath: sqr4x4Reticulate.PolygonPath = - sqr4x4Reticulate.PolygonPath(Vector(1, 2, 7, 6).map(Node(_))) + val polygonPath: p4444_4by4_reticulate.PolygonPath = + p4444_4by4_reticulate.PolygonPath(Vector(1, 2, 7, 6).map(Node(_))) "A polygon path of a tiling" can "be created" in { polygonPath.toPolygon shouldEqual @@ -279,7 +278,7 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } "A perimeter circular path" can "be converted to ordered polygons" in { - sqr4x4Reticulate.perimeterOrderedPolygons.mapValues2(_.map(_.toSides)) shouldBe + p4444_4by4_reticulate.perimeterOrderedPolygons.mapValues2(_.map(_.toSides)) shouldBe Map( 5 -> Vector(4), 10 -> Vector(4, 4), @@ -301,7 +300,7 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } it can "be converted to angles" in { - sqr4x4Reticulate.perimeterAngles shouldBe + p4444_4by4_reticulate.perimeterAngles shouldBe Map( 5 -> TAU_4, 10 -> TAU_2, 20 -> TAU_2, 1 -> TAU_4, 6 -> TAU_2, 21 -> TAU_4, 2 -> TAU_2, 22 -> TAU_2, @@ -311,7 +310,7 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } it can "be converted to 2D points" in { - sqr4x4Reticulate.perimeterPoints.almostEquals( + p4444_4by4_reticulate.perimeterPoints.almostEquals( Vector( Point(), Point(0, 1), @@ -335,7 +334,7 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } it can "be mapped to coords" in { - sqr4x4Reticulate.perimeterCoords.almostEqualsMap( + p4444_4by4_reticulate.perimeterCoords.almostEqualsMap( Map( Node(5) -> Point(0, 4), Node(10) -> Point(1, 4), @@ -359,19 +358,19 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } "A path of a regular polygon" can "be created" in { - triSqrHexHexoid.PolygonPath(Vector(7, 18, 19, 20).map(Node(_))) shouldEqual + p3464.PolygonPath(Vector(7, 18, 19, 20).map(Node(_))) shouldEqual Vector(7, 18, 19, 20) } it must "fail if smaller than size 3" in { val caught: IllegalArgumentException = - intercept[IllegalArgumentException] { triSqrHexHexoid.PolygonPath(Vector(1, 2).map(Node(_))) } + intercept[IllegalArgumentException] { p3464.PolygonPath(Vector(1, 2).map(Node(_))) } caught.getMessage shouldBe "Invalid number of sides: 2" } it must "fail if not a circular path" in { val caught: IllegalArgumentException = - intercept[IllegalArgumentException] { triSqrHexHexoid.PolygonPath(Vector(1, 2, 4, 11).map(Node(_))) } + intercept[IllegalArgumentException] { p3464.PolygonPath(Vector(1, 2, 4, 11).map(Node(_))) } caught.getMessage shouldBe "Invalid path: nodes 2 and 4 are not connected" } @@ -380,7 +379,7 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { it must "fail if not a regular polygon" in { val caught: IllegalArgumentException = - intercept[IllegalArgumentException] { triSqrHexHexoid.PolygonPath(notAPolygon) } + intercept[IllegalArgumentException] { p3464.PolygonPath(notAPolygon) } caught.getMessage shouldBe "Invalid regular polygon path: node 9 and node 1 are connected internally" } @@ -388,14 +387,14 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { it must "fail if also not a regular polygon" in { val caught: IllegalArgumentException = intercept[IllegalArgumentException] { - triSqrHexHexoid.PolygonPath(Vector(9, 1, 2, 10, 27, 26, 25, 24).map(Node(_))) + p3464.PolygonPath(Vector(9, 1, 2, 10, 27, 26, 25, 24).map(Node(_))) } caught.getMessage shouldBe "Invalid regular polygon path: node 9 and node 2 are connected internally" } it must "not fail if created unsafe" in { - triSqrHexHexoid.PolygonPath.unsafe(notAPolygon) shouldEqual + p3464.PolygonPath.unsafe(notAPolygon) shouldEqual Vector(1, 2, 10, 9, 8) } @@ -403,12 +402,12 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { minimalDifferentFromItsPeri.toMaybeTiling.unsafe "A triHexOfSide3" can "be checked for reflectional and rotational symmetry" in { - (triHexOfSide3.countSymmetries, triHexOfSide3.countRotationalSymmetries) shouldBe + (p333333_grown_hexagon.countSymmetries, p333333_grown_hexagon.countRotationalSymmetries) shouldBe (6, 6) } "A hexHexOfSide3" can "be checked for reflectional and rotational symmetry" in { - (hexHexOfSide3.countSymmetries, hexHexOfSide3.countRotationalSymmetries) shouldBe + (p666_grown_hexagon.countSymmetries, p666_grown_hexagon.countRotationalSymmetries) shouldBe (6, 6) } @@ -464,12 +463,12 @@ class TilingSpec extends AnyFlatSpec with Accuracy with should.Matchers { } it can "have a dual graph that is a valid tiling" in { - sqr4x4Reticulate.dual.toMaybeTiling.isRight shouldBe + p4444_4by4_reticulate.dual.toMaybeTiling.isRight shouldBe true } it can "have a dual graph" in { - tri4x4Reticulate.dual.graphEdges shouldBe + p333333_4by4_reticulate.dual.graphEdges shouldBe List( 6--8, 9--10, 14--15, 3--4, 2--7, 11--12, 4--5, 2--8, 10--11, 13--15, 5--6, 8--9, 10--14, 15--16, 1--4, 2--3, 7--11, 12--13 diff --git a/src/test/scala/io/github/scala_tessella/tessella/TilingValidationSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TilingValidationSpec.scala index 57f2bb8..3f0d113 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TilingValidationSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TilingValidationSpec.scala @@ -164,7 +164,7 @@ class TilingValidationSpec extends AnyFlatSpec with should.Matchers { it can "NOT have an inside gap" in { val withInvalidVertex = - Tiling.squareNet(3, 4).toOption.get.graphEdges.filterNot(_ == 10--11) + Tiling.pattern_4444(3, 4).toOption.get.graphEdges.filterNot(_ == 10--11) Tiling.maybe(withInvalidVertex) shouldEqual Left( """Tiling must have all internal nodes as valid FullVertex: diff --git a/src/test/scala/io/github/scala_tessella/tessella/TopologySpec.scala b/src/test/scala/io/github/scala_tessella/tessella/TopologySpec.scala index d404866..a41a0f5 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/TopologySpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/TopologySpec.scala @@ -1,7 +1,7 @@ package io.github.scala_tessella.tessella import Topology.* -import Outliers.sqr4x4Reticulate +import Outliers.p4444_4by4_reticulate import org.scalatest.* import org.scalatest.flatspec.* @@ -396,7 +396,7 @@ class TopologySpec extends AnyFlatSpec with should.Matchers { } val sqrEdges: List[Edge] = - sqr4x4Reticulate.graphEdges + p4444_4by4_reticulate.graphEdges // it can "be searched with breadth-first" in { // sqrEdges.bfs(Node(1)) shouldEqual diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthRegularSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthRegularSpec.scala index 08d08df..998d947 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthRegularSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthRegularSpec.scala @@ -1,7 +1,7 @@ package io.github.scala_tessella.tessella package creation -import Outliers.{hexHexOfSide3, sqr3x3Growth, triHexOfSide3} +import Outliers.{p666_grown_hexagon, p4444_3by3_grown, p333333_grown_hexagon} import TilingSymmetry.{countSymmetries, countRotationalSymmetries} import org.scalatest.* @@ -11,62 +11,62 @@ import org.scalatest.matchers.* class GrowthRegularSpec extends AnyFlatSpec with should.Matchers { "A (3₆) pattern grown quadratically" must "have gonality 1" in { - triHexOfSide3.gonality shouldBe + p333333_grown_hexagon.gonality shouldBe 1 } it must "have hedrality 1" in { - triHexOfSide3.hedrality shouldBe + p333333_grown_hexagon.hedrality shouldBe 1 } it can "have reflectional symmetry 6" in { - triHexOfSide3.countSymmetries shouldBe + p333333_grown_hexagon.countSymmetries shouldBe 6 } it can "have rotational symmetry 6" in { - triHexOfSide3.countRotationalSymmetries shouldBe + p333333_grown_hexagon.countRotationalSymmetries shouldBe 6 } "A (4₄) pattern grown quadratically" must "have gonality 1" in { - sqr3x3Growth.gonality shouldBe + p4444_3by3_grown.gonality shouldBe 1 } it must "have hedrality 1" in { - sqr3x3Growth.hedrality shouldBe + p4444_3by3_grown.hedrality shouldBe 1 } it can "have reflectional symmetry 4" in { - sqr3x3Growth.countSymmetries shouldBe + p4444_3by3_grown.countSymmetries shouldBe 4 } it can "have rotational symmetry 4" in { - sqr3x3Growth.countRotationalSymmetries shouldBe + p4444_3by3_grown.countRotationalSymmetries shouldBe 4 } "A (6₃) pattern grown quadratically" must "have gonality 1" in { - hexHexOfSide3.gonality shouldBe + p666_grown_hexagon.gonality shouldBe 1 } it must "have hedrality 1" in { - hexHexOfSide3.hedrality shouldBe + p666_grown_hexagon.hedrality shouldBe 1 } it can "have reflectional symmetry 6" in { - hexHexOfSide3.countSymmetries shouldBe + p666_grown_hexagon.countSymmetries shouldBe 6 } it can "have rotational symmetry 6" in { - hexHexOfSide3.countRotationalSymmetries shouldBe + p666_grown_hexagon.countRotationalSymmetries shouldBe 6 } diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthSemiregularSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthSemiregularSpec.scala index f0427af..cbecd18 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthSemiregularSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/GrowthSemiregularSpec.scala @@ -11,142 +11,142 @@ import org.scalatest.matchers.* class GrowthSemiregularSpec extends AnyFlatSpec with should.Matchers { "A (3₄.6) pattern grown quadratically" must "have gonality 1" in { - triHexHexoid.gonality shouldBe + p33336.gonality shouldBe 1 } it must "have hedrality 2" in { - triHexHexoid.hedrality shouldBe + p33336.hedrality shouldBe 2 } it can "have reflectional symmetry 0" in { - triHexHexoid.countSymmetries shouldBe + p33336.countSymmetries shouldBe 0 } it can "have rotational symmetry 6" in { - triHexHexoid.countRotationalSymmetries shouldBe + p33336.countRotationalSymmetries shouldBe 6 } "A (3₃.4₂) pattern grown quadratically" must "have gonality 1" in { - triSqrSquaroid.gonality shouldBe + p33444.gonality shouldBe 1 } it must "have hedrality 2" in { - triSqrSquaroid.hedrality shouldBe + p33444.hedrality shouldBe 2 } it can "have reflectional symmetry 2" in { - triSqrSquaroid.countSymmetries shouldBe + p33444.countSymmetries shouldBe 2 } it can "have rotational symmetry 2" in { - triSqrSquaroid.countRotationalSymmetries shouldBe + p33444.countRotationalSymmetries shouldBe 2 } "A (3.4.6.4) pattern grown quadratically" must "have gonality 1" in { - triSqrHexHexoid.gonality shouldBe + p3464.gonality shouldBe 1 } it must "have hedrality 3" in { - triSqrHexHexoid.hedrality shouldBe + p3464.hedrality shouldBe 3 } it can "have reflectional symmetry 6" in { - triSqrHexHexoid.countSymmetries shouldBe + p3464.countSymmetries shouldBe 6 } it can "have rotational symmetry 6" in { - triSqrHexHexoid.countRotationalSymmetries shouldBe + p3464.countRotationalSymmetries shouldBe 6 } "A (3.6.3.6) pattern grown quadratically" must "have gonality 1" in { - triHexHex.gonality shouldBe + p3636.gonality shouldBe 1 } it must "have hedrality 2" in { - triHexHex.hedrality shouldBe + p3636.hedrality shouldBe 2 } it can "have reflectional symmetry 6" in { - triHexHex.countSymmetries shouldBe + p3636.countSymmetries shouldBe 6 } it can "have rotational symmetry 6" in { - triHexHex.countRotationalSymmetries shouldBe + p3636.countRotationalSymmetries shouldBe 6 } "A (3.12₂) pattern grown quadratically" must "have gonality 1" in { - triDodHexoid.gonality shouldBe + p31212.gonality shouldBe 1 } it must "have hedrality 2" in { - triDodHexoid.hedrality shouldBe + p31212.hedrality shouldBe 2 } it can "have reflectional symmetry 6" in { - triDodHexoid.countSymmetries shouldBe + p31212.countSymmetries shouldBe 6 } it can "have rotational symmetry 6" in { - triDodHexoid.countRotationalSymmetries shouldBe + p31212.countRotationalSymmetries shouldBe 6 } "A (4.6.12) pattern grown quadratically" must "have gonality 1" in { - sqrHexDodHexoid.gonality shouldBe + p4612.gonality shouldBe 1 } it must "have hedrality 3" in { - sqrHexDodHexoid.hedrality shouldBe + p4612.hedrality shouldBe 3 } it can "have reflectional symmetry 6" in { - sqrHexDodHexoid.countSymmetries shouldBe + p4612.countSymmetries shouldBe 6 } it can "have rotational symmetry 6" in { - sqrHexDodHexoid.countRotationalSymmetries shouldBe + p4612.countRotationalSymmetries shouldBe 6 } "A (4.8₂) pattern grown quadratically" must "have gonality 1" in { - sqrOctSquaroid.gonality shouldBe + p488.gonality shouldBe 1 } it must "have hedrality 2" in { - sqrOctSquaroid.hedrality shouldBe + p488.hedrality shouldBe 2 } it can "have reflectional symmetry 4" in { - sqrOctSquaroid.countSymmetries shouldBe + p488.countSymmetries shouldBe 4 } it can "have rotational symmetry 4" in { - sqrOctSquaroid.countRotationalSymmetries shouldBe + p488.countRotationalSymmetries shouldBe 4 } diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/QuadraticSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/QuadraticSpec.scala index 993c61a..ceec02a 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/creation/QuadraticSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/QuadraticSpec.scala @@ -13,12 +13,12 @@ import org.scalatest.matchers.* class QuadraticSpec extends AnyFlatSpec with Helper with Quadratic with should.Matchers { "A hexagon of triangles grown quadratically" can "have side 3" in { - Tiling.triangularHex(3).isRight shouldBe + Tiling.pattern_333333(3).isRight shouldBe true } it can "NOT have side 0" in { - Tiling.triangularHex(0) shouldEqual + Tiling.pattern_333333(0) shouldEqual Left("Side should be greater than 0") } diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateRegularSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateRegularSpec.scala index 6aa47d3..9ea2f4d 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateRegularSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateRegularSpec.scala @@ -8,52 +8,52 @@ import org.scalatest.matchers.* class ReticulateRegularSpec extends AnyFlatSpec with Helper with should.Matchers { "A square net" can "be generated with width 1 and height 1" in { - Tiling.squareNet(1, 1).map(_.toString) shouldEqual + Tiling.pattern_4444(1, 1).map(_.toString) shouldEqual Right("Tiling(1--2, 1--3, 2--4, 3--4)") } it can "NOT be generated with width 0" in { - Tiling.squareNet(0, 1) shouldEqual + Tiling.pattern_4444(0, 1) shouldEqual Left("Width should be greater than 0") } it can "NOT be generated with height 0" in { - Tiling.squareNet(1, 0) shouldEqual + Tiling.pattern_4444(1, 0) shouldEqual Left("Height should be greater than 0") } "A triangular net" can "be generated with width 2 and height 1" in { - Tiling.triangleNet(2, 1).map(_.toString) shouldEqual + Tiling.pattern_333333(2, 1).map(_.toString) shouldEqual Right("Tiling(1--2, 1--3, 1--4, 2--4, 3--4)") } it can "NOT be generated with width not even" in { - Tiling.triangleNet(3, 1) shouldEqual + Tiling.pattern_333333(3, 1) shouldEqual Left("Width should be even and greater than 0") } it can "NOT be generated with width 0" in { - Tiling.triangleNet(0, 1) shouldEqual + Tiling.pattern_333333(0, 1) shouldEqual Left("Width should be even and greater than 0") } it can "NOT be generated with height 0" in { - Tiling.triangleNet(2, 0) shouldEqual + Tiling.pattern_333333(2, 0) shouldEqual Left("Height should be greater than 0") } "An hexagonal net" can "be generated with width 1 and height 1" in { - Tiling.hexagonNet(1, 1).map(_.toString) shouldEqual + Tiling.pattern_666(1, 1).map(_.toString) shouldEqual Right("Tiling(1--2, 1--4, 2--3, 3--6, 4--5, 5--6)") } it can "NOT be generated with width 0" in { - Tiling.hexagonNet(0, 1) shouldEqual + Tiling.pattern_666(0, 1) shouldEqual Left("Width should be greater than 0") } it can "NOT be generated with height 0" in { - Tiling.hexagonNet(1, 0) shouldEqual + Tiling.pattern_666(1, 0) shouldEqual Left("Height should be greater than 0") } diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateSpec.scala index 0ad1fa7..58629e1 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/ReticulateSpec.scala @@ -1,8 +1,6 @@ package io.github.scala_tessella.tessella package creation -import TilingUniformity.uniformity - import org.scalatest.* import org.scalatest.flatspec.* import org.scalatest.matchers.* @@ -10,126 +8,138 @@ import org.scalatest.matchers.* class ReticulateSpec extends AnyFlatSpec with Helper with should.Matchers { "A uniform tiling as a holed triangular net" can "NOT be generated with width 4" in { - Tiling.uniform(4, 3) shouldEqual + Tiling.pattern_3636_other(4, 3) shouldEqual Left("Width should be even and greater than 4") } it can "NOT be generated with height 1" in { - Tiling.uniform(6, 1) shouldEqual + Tiling.pattern_3636_other(6, 1) shouldEqual Left("Height should be greater than 1") } it can "be generated" in { - Tiling.uniform(6, 2).isRight shouldBe + Tiling.pattern_3636_other(6, 2).isRight shouldBe true } "Another uniform tiling" can "NOT be generated with width 2" in { - Tiling.uniform2(2, 1) shouldEqual + Tiling.pattern_33336(2, 1) shouldEqual Left("Width should be even and greater than 2") } it can "be generated" in { - Tiling.uniform2(4, 1).isRight shouldBe + Tiling.pattern_33336(4, 1).isRight shouldBe true } - "A 2 uniform tiling" can "be generated" in { - Tiling.twoUniform(2, 1).isRight shouldBe + "A tiling with a [(3₆);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366(4, 4).unsafe) shouldBe true } - "A second 2 uniform tiling" can "be generated" in { - Tiling.twoUniform2(2, 1).isRight shouldBe + "A tiling with a [(3₆);(3₄.6)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336(4, 4).unsafe) shouldBe true } - "A third 2 uniform tiling" can "be generated" in { - Tiling.twoUniform3(2, 1).isRight shouldBe - true + "A tiling with a [(3₆);(3₂.6₂)] pattern" can "NOT be generated with width 2" in { + Tiling.pattern_33336_3366(2, 2) shouldEqual + Left("Width should be even and greater than 2") } - "A fourth 2 uniform tiling" can "NOT be generated with width 2" in { - Tiling.twoUniform4(2, 2) shouldEqual + it can "NOT be generated with height 1" in { + Tiling.pattern_33336_3366(4, 1) shouldEqual + Left("Height should be greater than 1") + } + + "A tiling with a [(3.6.3.6);(3₂.6₂)] pattern" can "NOT be generated with width 2" in { + Tiling.pattern_3636_3366(2, 2) shouldEqual Left("Width should be even and greater than 2") } it can "NOT be generated with height 1" in { - Tiling.twoUniform4(4, 1) shouldEqual + Tiling.pattern_3636_3366(4, 1) shouldEqual Left("Height should be greater than 1") } it can "be generated" in { - Tiling.twoUniform4(4, 2).isRight shouldBe + Pattern.s("[(3.6.3.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_3636_3366(8, 8).unsafe) shouldBe true } - "A fifth 2 uniform tiling" can "NOT be generated with width 2" in { - Tiling.twoUniform5(2, 2) shouldEqual - Left("Width should be even and greater than 2") + "A tiling with a [(3₆);(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366_666(8, 8).unsafe) shouldBe + true } - it can "NOT be generated with height 1" in { - Tiling.twoUniform5(4, 1) shouldEqual - Left("Height should be greater than 1") + "A tiling with a [(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366(8, 8).unsafe) shouldBe + true } - it can "be generated" in { - Tiling.twoUniform5(4, 2).isRight shouldBe + "A tiling with a different [(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_alt(8, 8).unsafe) shouldBe true } - "A 3 uniform tiling with gonality 3" can "be generated" in { - val t: Tiling = - Tiling.threeUniformOneOneOne(8, 5).unsafe - (t.uniformity, t.gonality) shouldBe - (3, 3) + "A tiling with a [(3₂.6₂);(3.6.3.6);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₂.6₂);(3.6.3.6);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_3366_3636_666_alt(8, 8).unsafe) shouldBe + true } - "A second 3 uniform tiling" can "be generated" in { - Tiling.threeUniformOneOneOne2(2, 1).isRight shouldBe + "A tiling with a [(3₆);(3₄.6);(3.6.3.6)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3.6.3.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3636(8, 8).unsafe) shouldBe true } - "A third 3 uniform tiling" can "be generated" in { - Tiling.threeUniformOneOneOne3(2, 1).isRight shouldBe + "A tiling with a [2x(3₆);(3₄.6)] pattern" can "be created" in { + Pattern.s("[2x(3₆);(3₄.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_33336(8, 8).unsafe) shouldBe true } - "A fourth 3 uniform tiling" can "be generated" in { - Tiling.threeUniformOneOneOne4(4, 2).isRight shouldBe + "A tiling with a [2x(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[2x(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_33336_3366(10, 10).unsafe) shouldBe true } - "A fifth 3 uniform tiling" can "be generated" in { - Tiling.threeUniformOneOneOne5(2, 2).isRight shouldBe + "A tiling with a [(3₆);2x(3₂.6₂);4x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₂.6₂);4x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x3366_4x666(10, 10).unsafe) shouldBe true } - "A sixth 3 uniform tiling" can "be generated" in { - Tiling.threeUniformOneOneOne6(2, 2).isRight shouldBe + "A tiling with a [(3₂.4.3.4)] pattern" can "be created" in { + Pattern.s("[(3₂.4.3.4)]") + .hasSameSymmetryClassesOf(Tiling.pattern_33434(6, 6).unsafe) shouldBe true } - "A three uniform tiling with gonality 2" can "be generated" in { - val t: Tiling = - Tiling.threeUniformTwoOne(8, 5).unsafe - (t.uniformity, t.gonality) shouldBe - (3, 2) + "A tiling with a [(3₃.4₂);(3₂.4.3.4)] pattern" can "be created" in { + Pattern.s("[(3₃.4₂);(3₂.4.3.4)]") + .hasSameSymmetryClassesOf(Tiling.pattern_33344_33434(6, 6).unsafe) shouldBe + true } - "A 4 uniform tiling with gonality 3" can "be generated" in { - val t: Tiling = - Tiling.fourUniformTwoOneOne8(16, 10).unsafe - (t.uniformity, t.gonality) shouldBe - (4, 3) + "A tiling with a [2x(3₃.4₂);(3₂.4.3.4)] pattern" can "be created" in { + Pattern.s("[2x(3₃.4₂);(3₂.4.3.4)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x33344_33434(6, 6).unsafe) shouldBe + true } - "A 7 uniform tiling with gonality 3" can "be generated" in { - val t: Tiling = - Tiling.sevenUniformFourTwoOne(16, 10).unsafe - (t.uniformity, t.gonality) shouldBe - (7, 3) + "A tiling with a [(3₃.4₂);(3₂.4.3.4);(4₄)] pattern" can "be created" in { + Pattern.s("[(3₃.4₂);(3₂.4.3.4);(4₄)]") + .hasSameSymmetryClassesOf(Tiling.pattern_33344_33434_4444(6, 6).unsafe) shouldBe + true } } diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/SymmetricSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/SymmetricSpec.scala index 0fb67ad..91f7bb1 100644 --- a/src/test/scala/io/github/scala_tessella/tessella/creation/SymmetricSpec.scala +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/SymmetricSpec.scala @@ -39,7 +39,7 @@ class SymmetricSpec extends AnyFlatSpec with SymmetryOps with SymmetricHelper wi } "A 3464 hexoid" can "have sets of perimeter nodes at minimal angle where to apply growth" in { - triSqrHexHexoid.rotationalPerimeterNodeSets shouldBe + p3464.rotationalPerimeterNodeSets shouldBe ( List(List(19, 35, 27), List(19, 31)), List(3, 4, 12) diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/Uni4HexSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/Uni4HexSpec.scala new file mode 100644 index 0000000..40277dc --- /dev/null +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/Uni4HexSpec.scala @@ -0,0 +1,70 @@ +package io.github.scala_tessella.tessella +package creation + +import org.scalatest.* +import org.scalatest.flatspec.* +import org.scalatest.matchers.* + +class Uni4HexSpec extends AnyFlatSpec with Helper with should.Matchers { + + "A tiling with a [(3₆);(3₄.6);(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_666(4, 4).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);(3₄.6);(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_666_alt(4, 4).unsafe) shouldBe + true + } + + "A tiling with a third different [(3₆);(3₄.6);(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_666_alt2(4, 4).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366_2x666(6, 6).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366_2x666_alt(6, 6).unsafe) shouldBe + true + } + + "A tiling with a third different [(3₆);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366_2x666_alt2(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);2x(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x3366_666(4, 4).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);2x(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x3366_666_alt(4, 4).unsafe) shouldBe + true + } + + "A tiling with a fourth different [(3₆);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366_2x666_alt3(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);2x(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x33336_3366(6, 6).unsafe) shouldBe + true + } + +} diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/Uni5HexSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/Uni5HexSpec.scala new file mode 100644 index 0000000..acc472d --- /dev/null +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/Uni5HexSpec.scala @@ -0,0 +1,100 @@ +package io.github.scala_tessella.tessella +package creation + +import org.scalatest.* +import org.scalatest.flatspec.* +import org.scalatest.matchers.* + +class Uni5HexSpec extends AnyFlatSpec with Helper with should.Matchers { + + "A tiling with a [2x(3₆);(3₄.6);(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[2x(3₆);(3₄.6);(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_33336_3366_666(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_2x666(6, 6).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_2x666_alt(6, 6).unsafe) shouldBe + true + } + + "A tiling with a third different [(3₆);(3₄.6);(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_2x666_alt2(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₄.6);2x(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);2x(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_2x3366_666(6, 6).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);(3₄.6);2x(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);2x(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_2x3366_666_alt(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);3x(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);3x(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3x3366_666(6, 6).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);3x(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);3x(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3x3366_666_alt(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [3x(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[3x(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_3x333333_33336_3366(6, 6).unsafe) shouldBe + true + } + + "A tiling with a different [3x(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[3x(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_3x333333_33336_3366_alt(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);2x(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x3366_2x666(6, 6).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);2x(3₂.6₂);2x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₂.6₂);2x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x3366_2x666_alt(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [2x(3₆);(3₄.6);2x(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[2x(3₆);(3₄.6);2x(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_33336_2x3366(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [2x(3₆);2x(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[2x(3₆);2x(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_2x33336_3366(6, 6).unsafe) shouldBe + true + } + + "A tiling with a [4x(3₆);(3₄.6)] pattern" can "be created" in { + Pattern.s("[4x(3₆);(3₄.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_4x333333_33336(6, 6).unsafe) shouldBe + true + } + +} diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/UniHexSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/UniHexSpec.scala new file mode 100644 index 0000000..e9f3eb8 --- /dev/null +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/UniHexSpec.scala @@ -0,0 +1,52 @@ +package io.github.scala_tessella.tessella +package creation + +import org.scalatest.* +import org.scalatest.flatspec.* +import org.scalatest.matchers.* + +class UniHexSpec extends AnyFlatSpec with Helper with should.Matchers { + + "A tiling with a [(3₆);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366(4, 4).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₄.6)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336(4, 4).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₂.6₂);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₂.6₂);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_3366_666(4, 4).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366(4, 4).unsafe) shouldBe + true + } + + "A tiling with a different [(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3366_alt(4, 4).unsafe) shouldBe + true + } + + "A tiling with a [2x(3₆);(3₄.6)] pattern" can "be created" in { + Pattern.s("[2x(3₆);(3₄.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_33336(4, 4).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);2x(3₂.6₂);4x(6₃)] pattern" can "be created" in { + Pattern.s("[(3₆);2x(3₂.6₂);4x(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_2x3366_4x666(8, 8).unsafe) shouldBe + true + } + +} diff --git a/src/test/scala/io/github/scala_tessella/tessella/creation/UniTriangleSpec.scala b/src/test/scala/io/github/scala_tessella/tessella/creation/UniTriangleSpec.scala new file mode 100644 index 0000000..498c092 --- /dev/null +++ b/src/test/scala/io/github/scala_tessella/tessella/creation/UniTriangleSpec.scala @@ -0,0 +1,34 @@ +package io.github.scala_tessella.tessella +package creation + +import org.scalatest.* +import org.scalatest.flatspec.* +import org.scalatest.matchers.* + +class UniTriangleSpec extends AnyFlatSpec with Helper with should.Matchers { + + "A tiling with a [(3₆);(3₄.6)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_alt(8, 8).unsafe) shouldBe + true + } + + "A tiling with a [(3₂.6₂);(3.6.3.6);(6₃)] pattern" can "be created" in { + Pattern.s("[(3₂.6₂);(3.6.3.6);(6₃)]") + .hasSameSymmetryClassesOf(Tiling.pattern_3366_3636_666(10, 10).unsafe) shouldBe + true + } + + "A tiling with a [(3₆);(3₄.6);(3.6.3.6)] pattern" can "be created" in { + Pattern.s("[(3₆);(3₄.6);(3.6.3.6)]") + .hasSameSymmetryClassesOf(Tiling.pattern_333333_33336_3636(10, 10).unsafe) shouldBe + true + } + + "A tiling with a [2x(3₆);(3₄.6);(3₂.6₂)] pattern" can "be created" in { + Pattern.s("[2x(3₆);(3₄.6);(3₂.6₂)]") + .hasSameSymmetryClassesOf(Tiling.pattern_2x333333_33336_3366(10, 10).unsafe) shouldBe + true + } + +}