|
JavaView® v2.00.008 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--jv.object.PsObject
|
+--jv.function.PuFunction
Describes a function in terms of a string with variables and constants. Strings may be interactively edited, for example, when studying parametrized surfaces.
A number of constants are implemented, like 'pi'. The first independent variables have names 'u', 'v', 'w' in this order. If more than three variables are use, they are numbered as 'u0', 'u1', ...
Additional variables may be added to function.
Info panel of the function object may be added to some panel to allow interactive editing of the functions.
Usage:
m_function.setName("Kuen Surface");
m_function.setExpression("2./(1.+(u*sin(v))^2)*sqrt(1.+u*u)*sin(v)*cos(u-atan(u))", 0);
m_function.setExpression("2./(1.+(u*sin(v))^2)*sqrt(1.+u*u)*sin(v)*sin(u-atan(u))", 1);
m_function.setExpression("log(tan(v/2.))+2./(1.+(u*sin(v))^2)*cos(v)", 2);
m_function.eval(double [] result, double [] arg);
or
m_function.setName("Real-valued function of one variable");
m_function.setExpression("sin(u)", 0);
double result = m_function.eval(double arg);
Later the function may be evaluated by
m_function.eval(double [] result, double [] arg);
See jv.thirdParty.expr.Expr
for a list and notation of functions.
Expr, Serialized Form| Field Summary | |
protected java.lang.String[] |
m_defExprString
|
protected Expr[] |
m_expr
|
protected java.lang.String[] |
m_exprString
|
protected int |
m_numFunctions
|
protected int |
m_numParameters
|
protected int |
m_numVariables
|
protected java.util.Hashtable |
m_parm
|
protected Variable[] |
m_var
|
| Fields inherited from class jv.object.PsObject |
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, m_infoPanel, m_name, m_panelList, m_parent, m_tag, m_updateList, NUM_TAGS |
| Constructor Summary | |
PuFunction()
|
|
PuFunction(int numVariables,
int numFunctions)
|
|
| Method Summary | |
void |
addParameter(java.lang.String name,
double initialValue)
Add additional variables to all expressions, usually used as constants or parameters. |
double |
eval(double arg)
Evaluate a real-valued function of one variable. |
boolean |
eval(double[] result,
double[] arg)
Evaluate an m-dim functions of n-variables'. |
double |
eval(int ind,
double[] arg)
Evaluate a component of an m-dim functions of n-variables'. |
double[] |
findValue(double[] a,
double[] b,
double value)
Finds the position of a value between two vertices. |
double[] |
findZero(double[] a,
double[] b)
Finds the zero position between two vertices. |
java.lang.String |
getExpression(int ind)
Get string of function with index ind. |
int |
getNumFunctions()
Get number of functions. |
int |
getNumVariables()
Get number of arguments used in current functions. |
void |
init()
If instance has missing name then assign default name 'object_NUMBER' where number is the total number of already created instances. |
boolean |
setExpression(java.lang.String[] s)
Supply string array of functions. |
boolean |
setExpression(java.lang.String s,
int ind)
Set string of function with index ind, overwrite default values. |
protected boolean |
setExpressionFromPanel(java.lang.String s,
int ind)
Set string of function with index ind from panel,
i.e. do not overwrite default. |
void |
setNumFunctions(int numFunctions)
Set number of functions. |
void |
setNumVariables(int numVariables)
Set number of arguments used in current functions. |
void |
setParameter(java.lang.String name,
double value)
Set value of variable in all expressions, usually used as constants or parameters. |
| Methods inherited from class jv.object.PsObject |
addInspector, addUpdateListener, clearTag, clone, clone, clone, copy, getFather, getInfoPanel, getInspector, getName, getNumObjects, hasInspector, hasTag, hasUpdateListener, instanceOf, instanceOf, removeInspector, removeUpdateListener, setName, setParent, setTag, toString, update, updatePanels |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected int m_numVariables
protected int m_numFunctions
protected int m_numParameters
protected Expr[] m_expr
protected java.lang.String[] m_exprString
protected java.lang.String[] m_defExprString
protected Variable[] m_var
protected java.util.Hashtable m_parm
| Constructor Detail |
public PuFunction()
public PuFunction(int numVariables,
int numFunctions)
| Method Detail |
public void init()
PsObjectinit in class PsObject
public void addParameter(java.lang.String name,
double initialValue)
public void setParameter(java.lang.String name,
double value)
public int getNumVariables()
public void setNumVariables(int numVariables)
public int getNumFunctions()
public void setNumFunctions(int numFunctions)
public java.lang.String getExpression(int ind)
ind.
public boolean setExpression(java.lang.String s,
int ind)
ind, overwrite default values.
protected boolean setExpressionFromPanel(java.lang.String s,
int ind)
ind from panel,
i.e. do not overwrite default.public boolean setExpression(java.lang.String[] s)
public double eval(double arg)
arg - Value of function argument.
public double eval(int ind,
double[] arg)
ind - Component to evaluatearg - Array with value for each function argument.
public boolean eval(double[] result,
double[] arg)
result - Existing array to contain the computed function values.arg - Array with value for each function argument.
public double[] findZero(double[] a,
double[] b)
a - a double[] with one vertexb - a double[] with another vertex
public double[] findValue(double[] a,
double[] b,
double value)
First the two limiting function values are calculated. If one of them is already equal to the value it is returned. If both of them are bigger or both of them are smaller there comes a warning message and the first one is returned.
Then the bisection starts by computing the midpoint, choosing the section with different signs for the difference, bisecting this again and so on until one of the function values becomes equal. This vertex is finally returned.
a - a double[] with one vertexb - a double[] with another vertexvalue - a double with the function value to find
|
JavaView® v2.00.008 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||