Class GrayScott

java.lang.Object
toxi.sim.grayscott.GrayScott

public class GrayScott extends Object
Implementation of the Gray-Scott reaction diffusion model described in detail on the links below:
  • http://groups.csail.mit.edu/mac/projects/amorphous/GrayScott/
  • http://ix.cs.uoregon.edu/~jlidbeck/java/rd/
  • http://www.mrob.com/pub/comp/xmorphia/
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float[]
     
    float[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    GrayScott(int width, int height, boolean wrap)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    getCurrentUAt(int x, int y)
    Convenience method to access U array using 2D coordinates.
    float
    getCurrentVAt(int x, int y)
    Convenience method to access V array using 2D coordinates.
    float
     
    float
     
    float
     
    float
    getFCoeffAt(int x, int y)
    Extension point for subclasses to modulate the F coefficient of the reaction diffusion, based on spatial (or other) parameters.
    float
     
    float
    getKCoeffAt(int x, int y)
    Extension point for subclasses to modulate the K coefficient of the reaction diffusion, based on spatial (or other) parameters.
    boolean
     
    void
    Resets the simulation matrix to an initial, clean state.
    void
    seedImage(int[] pixels, int imgWidth, int imgHeight)
     
    void
    setCoefficients(float f, float k, float dU, float dV)
     
    void
    setDiffuseU(float dU)
     
    void
    setDiffuseV(float dV)
     
    void
    setF(float f)
     
    void
    setK(float k)
     
    void
    setRect(int x, int y, int w, int h)
     
    void
     
    void
    setTiling(boolean isTiling)
     
    void
    update(float t)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • u

      public float[] u
    • v

      public float[] v
  • Constructor Details

    • GrayScott

      public GrayScott(int width, int height, boolean wrap)
  • Method Details

    • getCurrentUAt

      public float getCurrentUAt(int x, int y)
      Convenience method to access U array using 2D coordinates.
      Parameters:
      x -
      y -
      Returns:
      current u value at the given position
    • getCurrentVAt

      public float getCurrentVAt(int x, int y)
      Convenience method to access V array using 2D coordinates.
      Parameters:
      x -
      y -
      Returns:
      current v value at the given position
    • getDiffuseU

      public float getDiffuseU()
      Returns:
      the diffuse U coefficient
    • getDiffuseV

      public float getDiffuseV()
      Returns:
      the diffuse V coefficient
    • getF

      public float getF()
      Returns:
      the F coefficient
    • getFCoeffAt

      public float getFCoeffAt(int x, int y)
      Extension point for subclasses to modulate the F coefficient of the reaction diffusion, based on spatial (or other) parameters. This method is called for every cell/pixel of the simulation space from the main update(float) cycle and can be used to create parameter gradients, animations and other spatial or temporal modulations.
      Parameters:
      x -
      y -
      Returns:
      the active F coefficient at the given position
    • getK

      public float getK()
      Returns:
      the K coefficient
    • getKCoeffAt

      public float getKCoeffAt(int x, int y)
      Extension point for subclasses to modulate the K coefficient of the reaction diffusion, based on spatial (or other) parameters. This method is called for every cell/pixel of the simulation space and can be used to create parameter gradients, animations and other spatial or temporal modulations.
      Parameters:
      x -
      y -
      Returns:
      the active K coefficient at the given position
    • isTiling

      public boolean isTiling()
      Returns:
      the isTiling
    • reset

      public void reset()
      Resets the simulation matrix to an initial, clean state.
    • seedImage

      public void seedImage(int[] pixels, int imgWidth, int imgHeight)
    • setCoefficients

      public void setCoefficients(float f, float k, float dU, float dV)
    • setDiffuseU

      public void setDiffuseU(float dU)
      Parameters:
      dU - the diffuse U coefficient to set
    • setDiffuseV

      public void setDiffuseV(float dV)
      Parameters:
      dV - the diffuse V coefficient to set
    • setF

      public void setF(float f)
      Parameters:
      f - the F coefficient to set
    • setK

      public void setK(float k)
      Parameters:
      k - the K coefficient to set
    • setRect

      public void setRect(int x, int y, int w, int h)
      Parameters:
      x -
      y -
      w -
      h -
    • setRect

      public void setRect(Rect r)
    • setTiling

      public void setTiling(boolean isTiling)
      Parameters:
      isTiling - the isTiling to set
    • update

      public void update(float t)