|
JavaView® v2.12 | ||||||||
| 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.
The following constant(s) are implemented by default: {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', ...
An arbitrary number of additional variables can be added to a function.
Info panel of the function object can be added to some panel to allow interactive editing of the functions.
Usage:
// Graph of real-valued function in one variable
PuFunction function = new PuFunction(1, 1);
m_function.setName("Sin Function");
m_function.setExpression("sin(u)", 0);
double result = m_function.eval(double arg);
or
// Parametrized surface from R2 to R3
PuFunction function = new PuFunction(2, 3);
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);
Later, a function can be evaluated by calling
m_function.eval(double [] result, double [] arg);
See jv.thirdParty.expr.Expr
for a list and notation of functions.
Expr, Serialized Form| Fields inherited from class jv.object.PsObject |
HAS_CONFIG_PANEL, HAS_INFO_PANEL, HAS_MATERIAL_PANEL, HAS_TEXTURE_PANEL, INSPECTOR_INFO, INSPECTOR_INFO_EXT, IS_DELETED, IS_FIXED, IS_SELECTED, IS_USED, 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)
Deprecated. use jvx.numeric.PnRootFinder#findValue instead, this method is no longer functional. |
double[] |
findZero(double[] a,
double[] b)
Deprecated. use jvx.numeric.PnRootFinder#findZero instead, this method is no longer functional. |
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.
|
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, assureInspector, 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, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 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.
If there exist no default function, then the first invocation of this method with a non-empty expression argument is assigned as default expression.
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)
This method just calls #findValue with value of zero.
a - a double[] with one vertexb - a double[] with another vertex
public double[] findValue(double[] a,
double[] b,
double value)
First the function is evaluated at the two end points. If either of them is already equal to the value, then this vertex is returned. If both values are bigger or smaller, then a warning message is issued and the first vertex is returned.
Otherwise the bisection starts by computing the midpoint of the interval, choosing the section with different signs for the difference, bisecting this subinterval again and so on until one of the function values becomes equal. This vertex is finally returned.
a - coordinates of the first vertexb - coordinates of the second vertexvalue - function value to search for its argument vertex
|
JavaView® v2.12 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||