From c8fd2876775cee6c4ff4619e5fa2d0e5326f7427 Mon Sep 17 00:00:00 2001
From: Anders <alunde@stud.ntnu.no>
Date: Mon, 13 May 2024 12:34:48 +0200
Subject: [PATCH 1/2] Made ChaosGameDescriptionFactory

---
 .../model/ChaosGameDescriptionFactory.java    | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 src/main/java/edu/ntnu/idatt2003/model/ChaosGameDescriptionFactory.java

diff --git a/src/main/java/edu/ntnu/idatt2003/model/ChaosGameDescriptionFactory.java b/src/main/java/edu/ntnu/idatt2003/model/ChaosGameDescriptionFactory.java
new file mode 100644
index 0000000..d8c5a6f
--- /dev/null
+++ b/src/main/java/edu/ntnu/idatt2003/model/ChaosGameDescriptionFactory.java
@@ -0,0 +1,56 @@
+package edu.ntnu.idatt2003.model;
+
+import java.util.Arrays;
+
+/**
+ * This class is a factory for creating different standard fractals as ChaosGameDescriptions.
+ */
+public class ChaosGameDescriptionFactory {
+  /**
+   * Creates a ChaosGameDescription for the Sierpinski triangle.
+   * @return a ChaosGameDescription for the Sierpinski triangle
+   */
+  public static ChaosGameDescription createSierpinskiTriangle() {
+    AffineTransform2D[] transforms = new AffineTransform2D[3];
+    transforms[0] = new AffineTransform2D(new Matrix2x2(0.5, 0.0, 0.0, 0.5), new Vector2D(0.0, 0.0));
+    transforms[1] = new AffineTransform2D(new Matrix2x2(0.5, 0.0, 0.0, 0.5), new Vector2D(0.5, 0.0));
+    transforms[2] = new AffineTransform2D(new Matrix2x2(0.5, 0.0, 0.0, 0.5), new Vector2D(0.25, 0.5));
+
+    Vector2D lowerLeft = new Vector2D(0.0, 0.0);
+    Vector2D lowerRight = new Vector2D(1.0, 1.0);
+
+    return new ChaosGameDescription(Arrays.asList(transforms), lowerLeft, lowerRight);
+  }
+
+  /**
+   * Creates a ChaosGameDescription for the Barnsley fern.
+   * @return a ChaosGameDescription for the Barnsley fern
+   */
+  public  static ChaosGameDescription createBarnsleyFern() {
+    AffineTransform2D[] transforms = new AffineTransform2D[4];
+    transforms[0] = new AffineTransform2D(new Matrix2x2(0.0, 0.0, 0.0, 0.16), new Vector2D(0.0, 0.0));
+    transforms[1] = new AffineTransform2D(new Matrix2x2(0.85, 0.04, -0.04, 0.85), new Vector2D(0.0, 1.6));
+    transforms[2] = new AffineTransform2D(new Matrix2x2(0.2, -0.26, 0.23, 0.22), new Vector2D(0.0, 1.6));
+    transforms[3] = new AffineTransform2D(new Matrix2x2(-0.15, 0.28, 0.26, 0.24), new Vector2D(0.0, 0.44));
+
+    Vector2D lowerLeft = new Vector2D(-2.1820, 0.0);
+    Vector2D upperRight = new Vector2D(2.6558, 9.9983);
+
+    return new ChaosGameDescription(Arrays.asList(transforms), lowerLeft, upperRight);
+  }
+
+  /**
+   * Creates a ChaosGameDescription for the Julia set with the given complex number.
+   * @param c the complex number
+   * @param sign the sign of the imaginary part of the complex number
+   * @return a ChaosGameDescription for the Julia set
+   */
+  public static ChaosGameDescription createJuliaSet(Complex c, int sign) {
+    JuliaTransform[] transforms = new JuliaTransform[1];
+    transforms[0] = new JuliaTransform(c, sign);
+    Vector2D lowerLeft = new Vector2D(-2.0, -2.0);
+    Vector2D upperRight = new Vector2D(2.0, 2.0);
+
+    return new ChaosGameDescription(Arrays.asList(transforms), lowerLeft, upperRight);
+  }
+}
-- 
GitLab


From 15944f2e63551e032401c1c9fbb99c5291fe2683 Mon Sep 17 00:00:00 2001
From: Anders <alunde@stud.ntnu.no>
Date: Mon, 13 May 2024 12:35:14 +0200
Subject: [PATCH 2/2] Text file of Affine2D fractal

---
 src/main/resources/Affine2d.txt | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 src/main/resources/Affine2d.txt

diff --git a/src/main/resources/Affine2d.txt b/src/main/resources/Affine2d.txt
new file mode 100644
index 0000000..8219677
--- /dev/null
+++ b/src/main/resources/Affine2d.txt
@@ -0,0 +1,6 @@
+Affine2D # Type of transform
+0, 0 # Lower left
+1, 1 # Upper right
+.5, 0, 0, .5, 0, 0 # 1st transform
+.5, 0, 0, .5, .25, .5 # 2nd transform
+.5, 0, 0, .5, .5, 0 # 3rd transform
-- 
GitLab