Skip to content
Pieter De Rycke edited this page Jan 1, 2020 · 13 revisions

The following mathematical functions are out of the box supported by Jace.NET:

Function Arguments Added in Jace Description More Information
sin sin(A1) v0.8 Sine http://en.wikipedia.org/wiki/Sine
cos cos(A1) v0.8 Cosine http://en.wikipedia.org/wiki/Trigonometric_functions
asin asin(A1) v0.8 Arcsine http://en.wikipedia.org/wiki/Inverse_trigonometric_functions
acos acos(A1) v0.8 Arccosine http://en.wikipedia.org/wiki/Inverse_trigonometric_functions
tan tan(A1) v0.8 Tangent http://en.wikipedia.org/wiki/Trigonometric_functions
cot cot(A1) v0.8 Cotangent http://en.wikipedia.org/wiki/Trigonometric_functions
atan atan(A1) v0.8 Arctangent http://en.wikipedia.org/wiki/Inverse_trigonometric_functions
acot acot(A1) v0.8 Arccotangent http://en.wikipedia.org/wiki/Inverse_trigonometric_functions
loge loge(A1) v0.8 Natural Logarithm http://en.wikipedia.org/wiki/Logarithm
log10 log10(A1) v0.8 Common Logarithm http://en.wikipedia.org/wiki/Logarithm
logn logn(A1, A2) v0.8 Logarithm http://en.wikipedia.org/wiki/Logarithm
sqrt sqrt(A1) v0.8 Square Root http://en.wikipedia.org/wiki/Square_root
if if(A1, A2, A3) v0.8 If Function IF A1 IS true THEN A2 ELSE A3
max max(A1, ..., An) v0.9.1 Maximum
min min(A1, ..., An) v0.9.1 Minimum
avg avg(A1, ..., An) v0.9.1 Average
median median(A1, ..., An) v0.9.1 Median
round round(A1) v0.9.2 Round
random random() v1.0 Random Generate a random double value between 0.0 and 1.0

Examples

Calculating the sine of 90:

CalculationEngine engine = new CalculationEngine();
double result = engine.Calculate("sin(90)");

The logarithm of var1 to base var2:

Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2.5);
variables.Add("var2", 3.4);

CalculationEngine engine = new CalculationEngine();
double result = engine.Calculate("logn(var1, var2)", variables);

Conditional based logic:

Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2.5);
variables.Add("var2", 3.4);

CalculationEngine engine = new CalculationEngine();
double result = engine.Calculate("if(var1 < var2, 23, 8)", variables);
Clone this wiki locally