|
|
|
@ -1,7 +1,10 @@ |
|
|
|
|
package mightypork.utils.math.num; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
import mightypork.utils.math.rect.RectView; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abstract class NumMathDynamic extends NumMathBase<NumView> { |
|
|
|
|
|
|
|
|
|
private NumView ceil; |
|
|
|
|
private NumView floor; |
|
|
|
@ -20,12 +23,14 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
private NumView neg; |
|
|
|
|
private NumView abs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView add(final double addend) |
|
|
|
|
{ |
|
|
|
|
return new NumView() { |
|
|
|
|
|
|
|
|
|
private Num t = NumMathDynamic.this; |
|
|
|
|
private final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
@ -35,18 +40,21 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView sub(final double subtrahend) |
|
|
|
|
{ |
|
|
|
|
return add(-subtrahend); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView mul(final double factor) |
|
|
|
|
{ |
|
|
|
|
return new NumView() { |
|
|
|
|
|
|
|
|
|
private Num t = NumMathDynamic.this; |
|
|
|
|
private final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
@ -56,42 +64,48 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView div(final double factor) |
|
|
|
|
{ |
|
|
|
|
return mul(1/factor); |
|
|
|
|
return mul(1 / factor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView perc(final double percent) |
|
|
|
|
{ |
|
|
|
|
return mul(percent/100); |
|
|
|
|
return mul(percent / 100); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView neg() |
|
|
|
|
{ |
|
|
|
|
if(neg==null) neg = new NumView() { |
|
|
|
|
if (neg == null) neg = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
|
return -1*t.value(); |
|
|
|
|
return -1 * t.value(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return neg; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView abs() |
|
|
|
|
{ |
|
|
|
|
if(abs==null) abs = new NumView() { |
|
|
|
|
if (abs == null) abs = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -102,6 +116,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return abs; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView max(final double other) |
|
|
|
|
{ |
|
|
|
@ -109,6 +124,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -117,6 +133,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView min(final double other) |
|
|
|
|
{ |
|
|
|
@ -124,6 +141,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -132,6 +150,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView pow(final double other) |
|
|
|
|
{ |
|
|
|
@ -139,6 +158,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -147,49 +167,55 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView square() |
|
|
|
|
{ |
|
|
|
|
if(square==null) square = new NumView() { |
|
|
|
|
if (square == null) square = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
|
final double v = t.value(); |
|
|
|
|
return v*v; |
|
|
|
|
return v * v; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return square; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView cube() |
|
|
|
|
{ |
|
|
|
|
if(cube==null) cube = new NumView() { |
|
|
|
|
if (cube == null) cube = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
|
final double v = t.value(); |
|
|
|
|
return v*v*v; |
|
|
|
|
return v * v * v; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return cube; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView sqrt() |
|
|
|
|
{ |
|
|
|
|
if(sqrt==null) sqrt = new NumView() { |
|
|
|
|
if (sqrt == null) sqrt = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -200,13 +226,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return sqrt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView cbrt() |
|
|
|
|
{ |
|
|
|
|
if(cbrt==null) cbrt = new NumView() { |
|
|
|
|
if (cbrt == null) cbrt = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -217,13 +245,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return cbrt; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView sin() |
|
|
|
|
{ |
|
|
|
|
if(sin==null) sin = new NumView() { |
|
|
|
|
if (sin == null) sin = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -234,13 +264,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return sin; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView cos() |
|
|
|
|
{ |
|
|
|
|
if(cos==null) cos = new NumView() { |
|
|
|
|
if (cos == null) cos = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -251,13 +283,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return cos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView tan() |
|
|
|
|
{ |
|
|
|
|
if(tan==null) tan = new NumView() { |
|
|
|
|
if (tan == null) tan = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -268,13 +302,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return tan; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView asin() |
|
|
|
|
{ |
|
|
|
|
if(asin==null) asin = new NumView() { |
|
|
|
|
if (asin == null) asin = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -285,13 +321,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return asin; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView acos() |
|
|
|
|
{ |
|
|
|
|
if(acos==null) acos = new NumView() { |
|
|
|
|
if (acos == null) acos = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -302,13 +340,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return acos; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView atan() |
|
|
|
|
{ |
|
|
|
|
if(atan==null) atan = new NumView() { |
|
|
|
|
if (atan == null) atan = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -319,13 +359,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return atan; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView round() |
|
|
|
|
{ |
|
|
|
|
if(round==null) round = new NumView() { |
|
|
|
|
if (round == null) round = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -336,13 +378,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return round; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView floor() |
|
|
|
|
{ |
|
|
|
|
if(floor==null) floor = new NumView() { |
|
|
|
|
if (floor == null) floor = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -353,13 +397,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return floor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView ceil() |
|
|
|
|
{ |
|
|
|
|
if(ceil==null) ceil = new NumView() { |
|
|
|
|
if (ceil == null) ceil = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -370,13 +416,15 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return ceil; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView signum() |
|
|
|
|
{ |
|
|
|
|
if(sgn==null) sgn = new NumView() { |
|
|
|
|
if (sgn == null) sgn = new NumView() { |
|
|
|
|
|
|
|
|
|
final Num t = NumMathDynamic.this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public double value() |
|
|
|
|
{ |
|
|
|
@ -387,6 +435,7 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
return sgn; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView average(final double other) |
|
|
|
|
{ |
|
|
|
@ -401,7 +450,6 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NumView add(final Num addend) |
|
|
|
|
{ |
|
|
|
@ -555,4 +603,11 @@ public abstract class NumMathDynamic extends NumMathBase<NumView>{ |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public RectView box() |
|
|
|
|
{ |
|
|
|
|
return RectView.make(this, this); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|