anar

Class Param

java.lang.Object
  extended by anar.Parametric
      extended by anar.Param
All Implemented Interfaces:
iTaggable
Direct Known Subclasses:
ParamAngle, ParamArea, ParamAtan2, ParamCycle, ParamDot, ParamDynamicMinMax, ParamLength, ParamOp, ParamOpMono, ParamPt, ParMinMax

public class Param
extends Parametric

Design with Ratio

In OOG, the numbers are considered as parameters of a form. Expression of relationship among parameters ensure to keep the number of parameters as low as possible. Rather than having a metrical measurement to a global origin referential coordinate system, a set of simple mathematical relationships replace absolute references to a value. Parameters are chained from one to another one. The combination of simple relationship create complex structures that could express more complex relationships. This is done in order to replace the use of references based on absolute coordinates for relationships based on local conditions. By replacing numbers by a ratio improve the flexibility of geometric constructions as the conditions could be changed easily.

Interraction with parameters

Parameters are a the generalized way to describe numerical values. The parameters could be interactively explored by the manual modification of values. On a simplest form, parameters are represented as graphical sliders through a built-in process. As every parameter provide a similar structure, this structure could be easily be adapted to different kind of physical interfaces or could be processed through an automated process.

Param represent a number (a value). Param is for Paramters. A value could be chained with operators (ParamSum. If one parent value is changed, the change is propagated to all other children of this instance.


Field Summary
static float DefaultValue
           
 float max
          Maximum value (constraint)
 float min
          Minimum value (constraint)
 float mod
          Modulo operator.
 
Fields inherited from class anar.Parametric
meta
 
Constructor Summary
Param()
          If no value is given as parameter, value is initialized to 0;
Param(float value)
          Intialize Param with given value
Param(float value, float mod)
           
Param(float value, float min, float max)
          Value and bounded value (min-max)
Param(float value, float min, float max, float mod)
           
Param(float value, float min, float max, java.lang.String simpleMetaTag)
          Deprecated replaced by tag(String) ex: Constructor().tag(String);
Param(float value, java.lang.String tag)
          Deprecated replaced by tag(String) ex: Constructor().tag(String);
 
Method Summary
 Param abs()
           
 void addRatio(float delta)
           
 Param addToSlidersMain()
          Add the Param to Anar.slider list.
 Param cos()
           
 Param div(Param p)
           
 Param divide(float k)
           
 Param divide(Param p)
           
 float get()
           
 float getRatio()
          If min = 10, max =110; v = 60 then returns --> 0.5
 float getRatio(float min, float max)
          Example:
 Param inv()
           
 Param invert()
           
 Param minus(float k)
           
 Param minus(Param p)
           
 Param mul(Param p)
           
 Param multiply(float k)
           
 Param multiply(Param p)
           
 Param plus(float k)
           
 Param plus(Param p)
           
 Param pow(Param p)
           
 void set(float value)
          Change the value of this Param
 void set(float value, float mod)
           
 void set(float value, float min, float max)
          Change the value and reset min, max.
 void set(float value, float min, float max, float mod)
           
 Param set(Meta meta)
           
 Param setMeta(Meta meta)
           
 void setMidi(int midiValue)
          Convert a midi value 0xEF (0...127) to a value (with predefined min and max values.
 void setRatio(float value)
           
 Param sign()
           
 Param sin()
           
 Param sqrt()
           
 Param square()
           
 Param sub(Param p)
           
 Param sum(Param p)
           
 Param tag(Meta tag)
           
 Param tag(java.lang.String tag)
           
 Param tan()
           
 float toFloat()
           v = 0.8888888888888888888888888...(float) --> v = 0.88888888888 (float)
 int toInt()
           v = 0.8888888888888888888888888...(float) --> v = 0 (int)
 long toLong()
           
 java.lang.String toString()
           
 
Methods inherited from class anar.Parametric
child, get, getMeta, getPrimitive, parent, parent, parentList, parentList, parentList, parentListGraphViz, parentListGraphViz, parentListRecursive, parentListRecursiveGraphViz, parentToString, parentToStringRecursive, parentToStringRecursive, primitiveToString, replaceParent, replaceParent, replicate, tag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DefaultValue

public static float DefaultValue

min

public float min
Minimum value (constraint)


max

public float max
Maximum value (constraint)


mod

public float mod
Modulo operator. (similar to %) but based on floats. By default, not used (=0). Example mod = 1.01 will create describe a series of numbers [1.01,2.02,3.03,4.04...]

Constructor Detail

Param

public Param()
If no value is given as parameter, value is initialized to 0;


Param

public Param(float value)
Intialize Param with given value

Parameters:
value -

Param

public Param(float value,
             float mod)
Parameters:
value -
mod - (equivalent to modulo, constrain the parameter on multiples of the given value)

Param

public Param(float value,
             java.lang.String tag)
Deprecated replaced by tag(String) ex: Constructor().tag(String);

Intialize Param with given value. String is used for the meta tag.

Parameters:
value -
tag -
See Also:
Param(float), Param(float)

Param

public Param(float value,
             float min,
             float max)
Value and bounded value (min-max)

Parameters:
value -
min - (minimum possible value)
max - (maximum possible value)

Param

public Param(float value,
             float min,
             float max,
             float mod)
Parameters:
value -
min - (minimum possible value)
max - (maximum possible value)
mod - (equivalent to modulo, constrain the parameter on multiples of the given value)

Param

public Param(float value,
             float min,
             float max,
             java.lang.String simpleMetaTag)
Deprecated replaced by tag(String) ex: Constructor().tag(String);

Parameters:
value -
min - (minimum possible value)
max - (maximum possible value)
simpleMetaTag -
See Also:
Param(float, float, float)
Method Detail

get

public float get()
Returns:
Actual value of the Parameter

getRatio

public float getRatio()
If min = 10, max =110; v = 60 then returns --> 0.5

Returns:
0...1 value between min-max values

getRatio

public float getRatio(float min,
                      float max)
Example:
 Param.min = 10, Param.max = 110, value = 60 --> with(newMin=1 + newMax = 20) = 0.25
 

Parameters:
min -
max -
Returns:
Value normalized with other bounds

setRatio

public void setRatio(float value)
Parameters:
value - 0..1 nomalized value

inv

public Param inv()
Returns:

div

public Param div(Param p)

invert

public Param invert()

mul

public Param mul(Param p)

sum

public Param sum(Param p)

sub

public Param sub(Param p)

sqrt

public Param sqrt()

square

public Param square()

pow

public Param pow(Param p)

sign

public Param sign()

abs

public Param abs()

cos

public Param cos()

sin

public Param sin()

tan

public Param tan()

addRatio

public void addRatio(float delta)
Parameters:
delta -

set

public void set(float value)
Change the value of this Param

Parameters:
value -

set

public void set(float value,
                float mod)
Parameters:
value -
mod -

set

public void set(float value,
                float min,
                float max)
Change the value and reset min, max.

Parameters:
value -
min -
max -

set

public void set(float value,
                float min,
                float max,
                float mod)
Parameters:
value -
min -
max -
mod -

setMidi

public void setMidi(int midiValue)
Convert a midi value 0xEF (0...127) to a value (with predefined min and max values.

Parameters:
midiValue -

set

public Param set(Meta meta)

setMeta

public Param setMeta(Meta meta)

tag

public Param tag(java.lang.String tag)

tag

public Param tag(Meta tag)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toFloat

public float toFloat()
 v = 0.8888888888888888888888888...(float) --> v = 0.88888888888 (float)
 

Returns:
value as a float

toInt

public int toInt()
 v = 0.8888888888888888888888888...(float) --> v = 0 (int)
 

Returns:
value as a int

toLong

public long toLong()
Returns:
value as a long

divide

public Param divide(Param p)

divide

public Param divide(float k)

multiply

public Param multiply(Param p)

multiply

public Param multiply(float k)

plus

public Param plus(Param p)

plus

public Param plus(float k)

minus

public Param minus(Param p)

minus

public Param minus(float k)

addToSlidersMain

public Param addToSlidersMain()
Add the Param to Anar.slider list.

Returns:
himself