From a86471b5ae145b2f6eecfc60839c8d2919ac8f7e Mon Sep 17 00:00:00 2001 From: merowin Date: Thu, 2 Jan 2025 23:46:00 +0100 Subject: [PATCH 1/2] fix distances of sierpinsky board --- .../shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts b/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts index 6f8e16c0..fe5217f6 100644 --- a/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts +++ b/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts @@ -2,7 +2,7 @@ import { Vector2D } from "./types/Vector2D"; import { Intersection } from "./types/intersection"; export function createSierpinskyBoard(depth: number): Intersection[] { - const sideLength = Math.pow(2, depth + 1); + const radius = Math.pow(2, depth + 1) / Math.sqrt(3); const middleIntersections = [0, 1, 2].map( (number) => @@ -10,7 +10,7 @@ export function createSierpinskyBoard(depth: number): Intersection[] { new Vector2D( Math.cos((Math.PI * (0.5 + 2 * number)) / 3), Math.sin((Math.PI * (0.5 + 2 * number)) / 3), - ).Multiply(sideLength / 2), + ).Multiply(radius), ), ) as [Intersection, Intersection, Intersection]; From 13130260170782c5796d1dd7a11c1c6c70c9377f Mon Sep 17 00:00:00 2001 From: merowin Date: Fri, 3 Jan 2025 04:50:47 +0100 Subject: [PATCH 2/2] remove commented code --- .../abstractBoard/helper/SierpinskyBoard.ts | 56 ------------------- 1 file changed, 56 deletions(-) diff --git a/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts b/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts index fe5217f6..1781c2c4 100644 --- a/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts +++ b/packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts @@ -19,62 +19,6 @@ export function createSierpinskyBoard(depth: number): Intersection[] { return [...middleIntersections, ...sierpinskyTriangle.flatten()]; } -// Not sure if this is usable, I'd like to leave it here as comment for the time being. -// creates a board for 4 Sierpinsky Triangles connected in 3D, projected onto the plane -/* -export function create3DSierpinskyBoard(depth: number): Intersection[] { - const sideLength = Math.pow(2, depth + 1); - - var middleIntersections = [0, 1, 2].map( - (number) => - new Intersection( - new Vector2D( - Math.cos((Math.PI * (0.5 + 2 * number)) / 3), - Math.sin((Math.PI * (0.5 + 2 * number)) / 3), - ).Multiply(sideLength / 2), - ), - ) as [Intersection, Intersection, Intersection]; - - const sierpinskyTriangle = new SierpinskyTriangle(middleIntersections, depth); - - // experimenting - const outwardsStretch = 3; - - const outerIntersections = [0, 1, 2].map( - (number) => - new Intersection( - new Vector2D( - Math.cos((Math.PI * (1.5 + 2 * number)) / 3), - Math.sin((Math.PI * (1.5 + 2 * number)) / 3), - ).Multiply(sideLength * outwardsStretch), - ), - ); - - const outerSierpinskyTriangles = outerIntersections.map( - (intersection, index) => - new SierpinskyTriangle( - [ - intersection, - outerIntersections[(index + 2) % 3], - middleIntersections[index], - ], - depth, - ), - ); - - return [ - ...middleIntersections, - ...outerIntersections, - ...sierpinskyTriangle.flatten(), - ...outerSierpinskyTriangles[0].flatten(), - ...outerSierpinskyTriangles[1].flatten(), - ...outerSierpinskyTriangles[2].flatten(), - ].map((intersection, index) => { - intersection.Identifier = index; - return intersection; - }); -}*/ - class SierpinskyTriangle { private subTriangles: null | SierpinskyTriangle[];