Loading...
This chapter shows how to script with the Math object and its members which offer a wide variety of mathematical functions. It always returns the computed result as a numeric value without changing the argument itself.
Find here a list of all available methods. Remember to assign a suiting type to the variable for the result, e.g. "Double". In the interests of clarity, the result is rounded to two digits.
As explained in the topic"Object and Member Notation (dot syntax)", all kinds of objects can be addressed in the scripting language by using their members which set (or return if applicable) properties or methods of that object. Please refer to the chapter "Script Language" for more details about scripting in general.
Math.Abs(number) |
Example: |
Abs returns the absolute value of a specified number. The result for the above example would be: 1.23 |
Math.Acos(number) |
Example: |
Acos returns the angle whose cosine is the specified number (in radians!). The result for the above example would be: 0.14 |
Math.Asin(number) |
Example: |
Asin returns the angle whose sine is the specified number (in radians!). The result for the above example would be: 1.43 |
Math.Atan(number) |
Example: |
Atan returns the angle whose tangent is the specified number (in radians!). The result for the above example would be: 0.78 |
Math.Ceiling(number) |
Example: |
Ceiling returns the smallest integer greater than or equal to the specified number. The result for the above example would be: 2 |
Math.Cos(number) |
Example: |
Cos returns the cosine of the specified angle (in radians!). The result for the above example would be: 0.15 |
Math.Deg2Rad(number) |
Example: |
Deg2Rad returns the radiant of the angle specified in degrees. The result for the above example would be: 3.14 The formula is: 1° × π/180 = 0,01745rad |
Math.E |
Example: |
E returns the mathematical constant "Eulers number" The result for the above example would be: 2.72 |
Math.Exp(number) |
Example: |
Exp returns e (Eulers number) raised to the specified power. The result for the above example would be: 2.72 |
Math.Floor(number) |
Example: |
Floor returns the largest integer less than or equal to the specified number. The result for the above example would be: 1 |
Math.Log(number) |
Example: |
Log returns the natural logarithm of a specified number. The result for the above example would be: 0.99 |
Math.Log10(number) |
Example: |
Log10 returns the base 10 logarithm of a specified number. The result for the above example would be: 0.7 |
Math.Max(number1,number2) |
Example: |
Max returns the larger of two specified numbers. The result for the above example would be: 2 |
Math.Min(number1,number2) |
Example: |
Min returns the smaller of two numbers. The result for the above example would be: 3 |
Math.Mod(number1,dividedByNumber) |
Example: |
Mod returns the remainder after the division of one number by another. The result for the above example would be: 1 |
Math.Pi |
Example: |
Pi returns the mathematical constant π ("Archimedes' constant"). The result for the above example would be: 3.14159... You can multiply as follows: vdouble = Math.Pi *2 |
Math.Pow(base,exponent) |
Example: |
Pow returns a specified number (base) raised to the specified power (exponent), i.e. base^exponent. The result for the above example would be: 25 |
Math.Rad2Deg(number) |
Example: |
Rad2Deg returns the degree of the angle specified in radians. The result for the above example would be: 180 The formula is: 1° × π/180 = 0,01745rad |
Math.Random(minNumber,maxNumber) |
Example: |
As common practice in most programming languages, the lower bound is included, the upper bound is excluded from the returned numbers. The result for the above example would be similar to: 42 |
Math.Round(numberWithDecimals,count) |
Example: |
Round rounds a value to the nearest integer or specified number of decimal places. The result for the above example would be: 1.23 |
Math.Sign(number) |
Example: |
Sign returns a value indicating the sign of a number. The result for the above example would be: -1 |
Math.Sin(number) |
Example: |
Sin returns the sine of the specified angle (in radians!). The result for the above example would be: -0.99 |
Math.Sqrt(number) |
Example: |
Sqrt returns the square root of a specified number. The result for the above example would be: 5 |
Math.Tan(number) |
Example: |
Tan returns the tangent of the specified angle (in radians!). The result for the above example would be: -6.41 |
Math.Truncate(number) |
Example: |
Truncate calculates the integral part of a number. The result for the above example would be: 10 |