Package toxi.sim.grayscott
Class GrayScott
java.lang.Object
toxi.sim.grayscott.GrayScott
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
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
getF()
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
getK()
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
isTiling()
void
reset()
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)
-
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 mainupdate(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
-
setTiling
public void setTiling(boolean isTiling) - Parameters:
isTiling
- the isTiling to set
-
update
public void update(float t)
-