Fix for plotting
This commit is contained in:
parent
3467ba828f
commit
7c546a0ea9
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="108" android:versionName="1.5.1-b2" package="org.solovyev.android.calculator">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" android:versionCode="109" android:versionName="1.5.1-b3-SNAPSHOT" package="org.solovyev.android.calculator">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
@ -55,7 +55,7 @@ public final class PlotUtils {
|
|||||||
@NotNull MyXYSeries realSeries,
|
@NotNull MyXYSeries realSeries,
|
||||||
@Nullable MyXYSeries imagSeries,
|
@Nullable MyXYSeries imagSeries,
|
||||||
boolean addExtra,
|
boolean addExtra,
|
||||||
int numberOfSteps) throws ArithmeticException {
|
int numberOfSteps) {
|
||||||
|
|
||||||
boolean imagExists = false;
|
boolean imagExists = false;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ public final class PlotUtils {
|
|||||||
int bgColor,
|
int bgColor,
|
||||||
boolean interpolate,
|
boolean interpolate,
|
||||||
int realLineColor,
|
int realLineColor,
|
||||||
int imagLineColor) throws ArithmeticException{
|
int imagLineColor) {
|
||||||
final MyXYSeries realSeries = new MyXYSeries(getRealFunctionName(expression, variable), DEFAULT_NUMBER_OF_STEPS * 2);
|
final MyXYSeries realSeries = new MyXYSeries(getRealFunctionName(expression, variable), DEFAULT_NUMBER_OF_STEPS * 2);
|
||||||
final MyXYSeries imagSeries = new MyXYSeries(getImagFunctionName(variable), DEFAULT_NUMBER_OF_STEPS * 2);
|
final MyXYSeries imagSeries = new MyXYSeries(getImagFunctionName(variable), DEFAULT_NUMBER_OF_STEPS * 2);
|
||||||
|
|
||||||
@ -372,7 +372,11 @@ public final class PlotUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Complex calculatorExpression(@NotNull Generic expression, @NotNull Constant variable, double x) {
|
public static Complex calculatorExpression(@NotNull Generic expression, @NotNull Constant variable, double x) {
|
||||||
|
try {
|
||||||
return unwrap(expression.substitute(variable, Expression.valueOf(x)).numeric());
|
return unwrap(expression.substitute(variable, Expression.valueOf(x)).numeric());
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return NaN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addSingularityPoint(@NotNull MyXYSeries series,
|
public static void addSingularityPoint(@NotNull MyXYSeries series,
|
||||||
@ -410,6 +414,8 @@ public final class PlotUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Complex NaN = Complex.valueOf(Double.NaN, 0d);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static Complex unwrap(@Nullable Generic numeric) {
|
public static Complex unwrap(@Nullable Generic numeric) {
|
||||||
if (numeric instanceof JsclInteger) {
|
if (numeric instanceof JsclInteger) {
|
||||||
@ -417,7 +423,7 @@ public final class PlotUtils {
|
|||||||
} else if (numeric instanceof NumericWrapper) {
|
} else if (numeric instanceof NumericWrapper) {
|
||||||
return unwrap(((NumericWrapper) numeric).content());
|
return unwrap(((NumericWrapper) numeric).content());
|
||||||
} else {
|
} else {
|
||||||
throw new ArithmeticException();
|
return NaN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user