Skip to content

Commit

Permalink
Merge pull request #369 from govariantsteam/fix_sierpinsky_board
Browse files Browse the repository at this point in the history
fix distances of sierpinsky board
  • Loading branch information
merowin authored Jan 4, 2025
2 parents 778f308 + 1313026 commit f74abf1
Showing 1 changed file with 2 additions and 58 deletions.
60 changes: 2 additions & 58 deletions packages/shared/src/lib/abstractBoard/helper/SierpinskyBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ 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) =>
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),
).Multiply(radius),
),
) as [Intersection, Intersection, Intersection];

Expand All @@ -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[];

Expand Down

0 comments on commit f74abf1

Please sign in to comment.