generativedesign
Class Attractor

java.lang.Object
  extended by processing.core.PVector
      extended by generativedesign.Node
          extended by generativedesign.Attractor
All Implemented Interfaces:
Serializable

public class Attractor
extends Node

This class extends the functionality of the Node class to provide some more functions that make working with the attractor easier.

See Also:
Serialized Form

Field Summary
static int BASIC
          Basic attractor function
 int mode
          One of the constants BASIC, SMOOTH (default), TWIRL.
static int SMOOTH
          Attractor function with a smooth transition at the attractor radius
 float strength
          Attraction strength (default = 1).
static int TWIRL
          Same as SMOOTH, but perpendicular to the attraction vector
 
Fields inherited from class generativedesign.Node
damping, diameter, id, maxVelocity, maxX, maxY, maxZ, minX, minY, minZ, radius, ramp, velocity
 
Fields inherited from class processing.core.PVector
x, y, z
 
Constructor Summary
Attractor()
          Creates an attractor at default position (0, 0, 0).
Attractor(float theX, float theY)
          Creates an attractor position (theX, theY, 0).
Attractor(float theX, float theY, float theZ)
          Creates an attractor position (theX, theY, theZ).
Attractor(PVector theVector)
          Creates an attractor at the position given by theVector.
 
Method Summary
 void attachNode(Node theNode)
          Adds a node to this attractor
 void attract()
          Performs attraction for all attached nodes.
 void attract(Node theNode)
          Performs attraction for theNode.
 int getMode()
           
 Node[] getNodes()
           
 float getStrength()
           
 void setMode(int theMode)
           
 void setNodes(Node[] nodes)
           
 void setStrength(float theStrength)
           
 
Methods inherited from class generativedesign.Node
attract, getDamping, getDiameter, getID, getMaxVelocity, getMaxX, getMaxY, getMaxZ, getMinX, getMinY, getMinZ, getRadius, getRamp, getVelocity, rotateX, rotateY, rotateZ, setBoundary, setBoundary, setDamping, setDiameter, setID, setMaxVelocity, setMaxX, setMaxY, setMaxZ, setMinX, setMinY, setMinZ, setRadius, setRamp, setVelocity, update, update
 
Methods inherited from class processing.core.PVector
add, add, add, add, add, angleBetween, array, copy, cross, cross, cross, dist, dist, div, div, div, dot, dot, dot, equals, fromAngle, fromAngle, get, get, hashCode, heading, heading2D, lerp, lerp, lerp, limit, mag, magSq, mult, mult, mult, normalize, normalize, random2D, random2D, random2D, random2D, random3D, random3D, random3D, random3D, rotate, set, set, set, set, setMag, setMag, sub, sub, sub, sub, sub, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

BASIC

public static final int BASIC
Basic attractor function

See Also:
Constant Field Values

SMOOTH

public static final int SMOOTH
Attractor function with a smooth transition at the attractor radius

See Also:
Constant Field Values

TWIRL

public static final int TWIRL
Same as SMOOTH, but perpendicular to the attraction vector

See Also:
Constant Field Values

mode

public int mode
One of the constants BASIC, SMOOTH (default), TWIRL.


strength

public float strength
Attraction strength (default = 1). Positive numbers mean attraction, negative numbers result in repulsion.

Constructor Detail

Attractor

public Attractor()
Creates an attractor at default position (0, 0, 0).


Attractor

public Attractor(float theX,
                 float theY)
Creates an attractor position (theX, theY, 0).


Attractor

public Attractor(float theX,
                 float theY,
                 float theZ)
Creates an attractor position (theX, theY, theZ).


Attractor

public Attractor(PVector theVector)
Creates an attractor at the position given by theVector.

Method Detail

attachNode

public void attachNode(Node theNode)
Adds a node to this attractor

Parameters:
theNode - Node to attach

attract

public void attract()
Performs attraction for all attached nodes.


attract

public void attract(Node theNode)
Performs attraction for theNode.

Overrides:
attract in class Node
Parameters:
theNode - Node to attract

getMode

public int getMode()

setMode

public void setMode(int theMode)

getStrength

public float getStrength()
Overrides:
getStrength in class Node

setStrength

public void setStrength(float theStrength)
Overrides:
setStrength in class Node

getNodes

public Node[] getNodes()

setNodes

public void setNodes(Node[] nodes)


Processing Library generativedesign by Hartmut Bohnacker, Benedikt Gross. (c) 2015