Class ChaosGame

java.lang.Object
edu.ntnu.stud.chaosgame.controller.game.ChaosGame

public class ChaosGame extends Object
Class representing the chaos game, responsible for managing its progression.
  • Field Details

    • canvas

      private final ChaosCanvas canvas
      The ChaosCanvas for this ChaosGame.
    • description

      private ChaosGameDescription description
      The chaos game description.
    • observers

      private ArrayList<ChaosGameObserver> observers
      Observers monitoring this ChaosGame.
    • currentPoint

      private Vector2D currentPoint
      The current point in the chaos game.
    • random

      private final Random random
      The random number generator for the chaos game.
    • numOfTransforms

      private final int numOfTransforms
      Number of transforms.
  • Constructor Details

    • ChaosGame

      public ChaosGame(ChaosGameDescription description, ChaosCanvas canvas)
      Basic parameterised constructor.
      Parameters:
      description - the ChaosGameDescription.
      canvas - the ChaosCanvas.
  • Method Details

    • getCanvas

      public ChaosCanvas getCanvas()
      Get the canvas of this chaos game.
      Returns:
      the canvas.
    • getCurrentPoint

      public Vector2D getCurrentPoint()
      Get the current point in the chaos game.
      Returns:
      the point.
    • getDescription

      public ChaosGameDescription getDescription()
      Get the description for this choas game.
      Returns:
      the description.
    • setDescription

      public void setDescription(ChaosGameDescription description)
      Get the chaos game description.
      Parameters:
      description - the description to set.
    • runSteps

      public void runSteps(int n)
      Run the chaos game for n iterations.
      Parameters:
      n - the number of iterations.
    • findValidPoint

      public Vector2D findValidPoint(Vector2D point)
      If the point is out of bounds, iterate until it is within bounds. If the method fails to find a valid point within 100 iterations, it returns the original point.
      Parameters:
      point - the starting point.
      Returns:
      the resulting valid point within bounds, or the original point if no valid point is found.