net.returnvoid.graphics.grid

## Class EquiSpiralGrid

- java.lang.Object
- - net.returnvoid.graphics.grid.EquiSpiralGrid

- All Implemented Interfaces:
    RGrid

      public class EquiSpiralGrid
      extends java.lang.Object
      implements RGrid

  This class helps to build an spiral grid. The elements of this grid will be located on a spiral with a given start and end radius. The elements will be distributed visually evenly (approx.).
  Author:
    Diana Lange

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EquiSpiralGrid(float x, float y, float startRadius, float endRadius, float elementDistance, float rotations, float startAngle, int dir)` Builds a new grid.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `processing.core.PVector` | `get(int index)` Returns the location of the element with the given index.
    `java.lang.Float` | `getAngle(java.lang.Integer index)` Returns the angle of an element with the given index.
    `processing.core.PVector[]` | `getCoordinates()` Returns all positions of all elements in the grid.
    `java.lang.Float` | `getElementDistance()` The distance each element will have to its neighbors.
    `java.lang.Float` | `getEndRadius()` Returns the radius which describes the position of the last element of this grid.
    `java.lang.Float` | `getHeight()` Returns the current height of the grid.
    `java.lang.Float` | `getHeight(java.lang.Integer i)` Returns the current height of the grid.
    `java.lang.Float` | `getPadding()` Returns the space between the elements of the grid.
    `java.lang.Integer` | `getRotationDirection()` Returns the direction of rotation for this grid. 1=clockwise, -1=anti-clockwise.
    `java.lang.Float` | `getRotations()` Returns the number of rotations of this spiral.
    `java.lang.Float` | `getStartAngle()` Returns the angle that describes the position of the first element of this grid.
    `java.lang.Float` | `getStartRadius()` Returns the radius which describes the position of the first element of this grid.
    `java.lang.Float` | `getWidth()` Returns the width of the element at the given index.
    `java.lang.Float` | `getWidth(java.lang.Integer i)` Returns the current width of the grid.
    `java.lang.Float` | `getX()` Returns the current x-position of the grid.
    `java.lang.Float` | `getX(java.lang.Integer index)` Returns the x-position of the element at the given index.
    `java.lang.Float` | `getY()` Returns the current y-position of the grid.
    `java.lang.Float` | `getY(java.lang.Integer index)` Returns the y-position of the element at the given index.
    `EquiSpiralGrid` | `setElementDistance(float elementDistance)` Sets the distance of each element to its neighbors of this grid.
    `EquiSpiralGrid` | `setEndRadius(float r)` Sets the radius where the spiral ends.
    `EquiSpiralGrid` | `setPadding(float padding)` Sets the padding (space between elements of the grid).
    `EquiSpiralGrid` | `setRotationDirection(int dir)` Sets the direction of the rotation.
    `EquiSpiralGrid` | `setRotations(float r)` Sets the number of rotations the spiral should make.
    `EquiSpiralGrid` | `setStartAngle(float a)` Set the position of the first element of the grid.
    `EquiSpiralGrid` | `setStartRadius(float r)` Sets the radius where the spiral starts.
    `EquiSpiralGrid` | `setX(float x)` Set to x-position of the grid.
    `EquiSpiralGrid` | `setY(float y)` Set to y-position of the grid.
    `java.lang.Integer` | `size()` Returns the number of elements in the grid.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EquiSpiralGrid

          public EquiSpiralGrid(float x,
                                float y,
                                float startRadius,
                                float endRadius,
                                float elementDistance,
                                float rotations,
                                float startAngle,
                                int dir)

      Builds a new grid. Please provide reasonable value for each parameter or use the GridMaker.
      Parameters:
        `x` - The center x-location of this grid.
        `y` - The center y-location of this grid.
        `startRadius` - The radius where the spiral starts.
        `endRadius` - The radius where the spiral ends.
        `elementDistance` - The distance for each element on the grid.
        `rotations` - The number of rotations of this spiral.
        `startAngle` - The angle where the grid starts (in radians). The startAngle defines where the first element will positioned.
        `dir` - The direction of the rotation of the spiral. For dir=1 the spiral will rotate clockwise, for dir -1 anti-clockwise.

  - ### Method Detail

    - #### setX

          public EquiSpiralGrid setX(float x)

      Description copied from interface: `RGrid`
      Set to x-position of the grid.
      Specified by:
        `setX` in interface `RGrid`
      Parameters:
        `x` - The new x-position of the grid.
      Returns:
        The current grid object.

    - #### setY

          public EquiSpiralGrid setY(float y)

      Description copied from interface: `RGrid`
      Set to y-position of the grid.
      Specified by:
        `setY` in interface `RGrid`
      Parameters:
        `y` - The new y-position of the grid.
      Returns:
        The current grid object.

    - #### setStartRadius

          public EquiSpiralGrid setStartRadius(float r)

      Sets the radius where the spiral starts. The first element of this grid will be positioned on that radius.
      Parameters:
        `r` - The starting radius.
      Returns:
        The grid object.

    - #### setEndRadius

          public EquiSpiralGrid setEndRadius(float r)

      Sets the radius where the spiral ends. The last element of this grid will be positioned on that radius.
      Parameters:
        `r` - The ending radius.
      Returns:
        The grid object.

    - #### setElementDistance

          public EquiSpiralGrid setElementDistance(float elementDistance)

      Sets the distance of each element to its neighbors of this grid.
      Parameters:
        `elementDistance` - The distance of each element to its neighbors (>= 1).
      Returns:
        The grid object.

    - #### setStartAngle

          public EquiSpiralGrid setStartAngle(float a)

      Set the position of the first element of the grid.
      Parameters:
        `a` - The angle which describes the position of the first element (in radian).
      Returns:
        The current grid object.

    - #### setRotations

          public EquiSpiralGrid setRotations(float r)

      Sets the number of rotations the spiral should make.
      Parameters:
        `r` - The number of rotations (>= 0.01)
      Returns:
        The current grid object.

    - #### setRotationDirection

          public EquiSpiralGrid setRotationDirection(int dir)

      Sets the direction of the rotation.
      Parameters:
        `dir` - Clockwise for dir >= 0, anti-clockwise for dir < 0.
      Returns:
        The current grid object.

    - #### setPadding

          public EquiSpiralGrid setPadding(float padding)

      Sets the padding (space between elements of the grid).
      Specified by:
        `setPadding` in interface `RGrid`
      Parameters:
        `padding` - The new padding of this grid (percentage based on elementDistances()) [0, 1].
      Returns:
        The current grid object.

    - #### getCoordinates

          public processing.core.PVector[] getCoordinates()

      Description copied from interface: `RGrid`
      Returns all positions of all elements in the grid.
      Specified by:
        `getCoordinates` in interface `RGrid`
      Returns:
        The positions.

    - #### getX

          public java.lang.Float getX()

      Description copied from interface: `RGrid`
      Returns the current x-position of the grid.
      Specified by:
        `getX` in interface `RGrid`
      Returns:
        The x-position.

    - #### getY

          public java.lang.Float getY()

      Description copied from interface: `RGrid`
      Returns the current y-position of the grid.
      Specified by:
        `getY` in interface `RGrid`
      Returns:
        The y-position.

    - #### getWidth

          public java.lang.Float getWidth()

      Description copied from interface: `RGrid`
      Returns the width of the element at the given index.
      Specified by:
        `getWidth` in interface `RGrid`
      Returns:
        The width.

    - #### getHeight

          public java.lang.Float getHeight()

      Description copied from interface: `RGrid`
      Returns the current height of the grid.
      Specified by:
        `getHeight` in interface `RGrid`
      Returns:
        The height.

    - #### getStartRadius

          public java.lang.Float getStartRadius()

      Returns the radius which describes the position of the first element of this grid.
      Returns:
        The starting radius.

    - #### getEndRadius

          public java.lang.Float getEndRadius()

      Returns the radius which describes the position of the last element of this grid.
      Returns:
        The ending radius.

    - #### getElementDistance

          public java.lang.Float getElementDistance()

      The distance each element will have to its neighbors.
      Returns:
        The distance.

    - #### getStartAngle

          public java.lang.Float getStartAngle()

      Returns the angle that describes the position of the first element of this grid.
      Returns:
        The angle.

    - #### getRotationDirection

          public java.lang.Integer getRotationDirection()

      Returns the direction of rotation for this grid. 1=clockwise, -1=anti-clockwise.
      Returns:
        The direction of rotation.

    - #### getRotations

          public java.lang.Float getRotations()

      Returns the number of rotations of this spiral.
      Returns:
        The number of rotations.

    - #### getPadding

          public java.lang.Float getPadding()

      Returns the space between the elements of the grid.
      Specified by:
        `getPadding` in interface `RGrid`
      Returns:
        The padding.

    - #### size

          public java.lang.Integer size()

      Description copied from interface: `RGrid`
      Returns the number of elements in the grid. This is usefull if you want to iterate over all elements of the grid. Example:

           for (int i = 0; i < myGrid.size(); i++) {
                          float x = myGrid.getX(i);
                          float y = myGrid.getY(i):
           }

      Specified by:
        `size` in interface `RGrid`
      Returns:
        The number of elements of the grid.

    - #### getAngle

          public java.lang.Float getAngle(java.lang.Integer index)

      Returns the angle of an element with the given index.
      Parameters:
        `index` - The index of the element [0, size()]
      Returns:
        The angle the element with that index.

    - #### getX

          public java.lang.Float getX(java.lang.Integer index)

      Description copied from interface: `RGrid`
      Returns the x-position of the element at the given index. index should be in the range of this grid [0, myGrid.size()], otherwise the call of this function might produce strange results or will produce an ArrayIndexOutOfBoundsException. Usage:

           for (int i = 0; i < myGrid.size(); i++) {
                          float x = myGrid.getX(i);
                          float y = myGrid.getY(i):
           }

      Specified by:
        `getX` in interface `RGrid`
      Parameters:
        `index` - The index of the element.
      Returns:
        The x-position of the element.

    - #### getY

          public java.lang.Float getY(java.lang.Integer index)

      Description copied from interface: `RGrid`
      Returns the y-position of the element at the given index. index should be in the range of this grid [0, myGrid.size()], otherwise the call of this function might produce strange results or will produce an ArrayIndexOutOfBoundsException. Usage:

           for (int i = 0; i < myGrid.size(); i++) {
                          float x = myGrid.getX(i);
                          float y = myGrid.getY(i):
           }

      Specified by:
        `getY` in interface `RGrid`
      Parameters:
        `index` - The index of the element.
      Returns:
        The y-position of the element.

    - #### get

          public processing.core.PVector get(int index)

      Returns the location of the element with the given index. Usage:

           for (int i = 0; i < myGrid.size(); i++) {
                  PVector position = myGrid.get(index);
           }

      Parameters:
        `index` - The index of the element.
      Returns:
        The position of the element.

    - #### getWidth

          public java.lang.Float getWidth(java.lang.Integer i)

      Description copied from interface: `RGrid`
      Returns the current width of the grid.
      Specified by:
        `getWidth` in interface `RGrid`
      Parameters:
        `i` - The index of the element.
      Returns:
        The width.

    - #### getHeight

          public java.lang.Float getHeight(java.lang.Integer i)

      Description copied from interface: `RGrid`
      Returns the current height of the grid.
      Specified by:
        `getHeight` in interface `RGrid`
      Parameters:
        `i` - The index of the element.
      Returns:
        The height.