math: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
|version=1.4.0.5 | |version=1.4.0.5 | ||
|description= | |description= | ||
This is NOT a single MapTool function but a collection of math functions in MapTool. | This is NOT a single MapTool function but a collection of math functions in MapTool. | ||
'''Important Note''': | |||
'''Important Note''': Most of these functions return a floating-point number (e.g.: `3.0`). | |||
|usage= | |usage= | ||
Line 38: | Line 39: | ||
Logarithmic | Logarithmic | ||
[r:val = math.log(num)] (this is | [r:val = math.log(num)] (this is the log to base e) | ||
[r:val = math.log10(num)] | [r:val = math.log10(num)] | ||
Pythagorean: | Pythagorean: | ||
[r:val = math.hypot(num1,num2)] | [r:val = math.hypot(num1, num2)] | ||
[r:val = math.hypotenuse(num1,num2)] | [r:val = math.hypotenuse(num1, num2)] | ||
Simple operations | Simple operations | ||
Line 54: | Line 55: | ||
[r:val = math.max(num1, num2, num2, etc.)] | [r:val = math.max(num1, num2, num2, etc.)] | ||
[r:val = math.min(num1, num2, num2, etc.)] | [r:val = math.min(num1, num2, num2, etc.)] | ||
[r:val = math.mod( | [r:val = math.mod(dividend, divisor)] | ||
</source> | </source> | ||
|examples= | |examples=<nowiki></nowiki> | ||
====abs==== | ====abs==== | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r:val = math.abs(-3)] | [r:val = math.abs(-3)] | ||
</source> | </source> | ||
Returns: | Returns: 3.0 | ||
====mod==== | ====mod==== | ||
Returns the result of the modulo operation between the two numbers, which represents the remainder after a division operation. | |||
<source lang="mtmacro" line> | |||
[r: math.mod(14,6)] | |||
</source> | |||
Returns 2 | |||
<source lang="mtmacro" line> | |||
[r: math.mod(10,5)] | |||
</source> | |||
Returns 0 | |||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: | [r: math.mod(-13,4) | ||
</source> | </source> | ||
Returns | Returns -1 | ||
====pow==== | ====pow==== | ||
Line 75: | Line 88: | ||
[r:val = math.pow(2,3)] | [r:val = math.pow(2,3)] | ||
</source> | </source> | ||
Returns: | Returns: 8.0 | ||
}} | }} | ||
[[Category:Mathematical Function]] | [[Category:Mathematical Function]] |
Revision as of 20:11, 16 April 2020
math() Function
• Introduced in version 1.4.0.5
This is NOT a single MapTool function but a collection of math functions in MapTool.
Important Note: Most of these functions return a floating-point number (e.g.: `3.0`).
Usage
Numbers:
[r:val = math.pi()]
[r:val = math.e()]
Trigonomotry:
[r:val = math.acos(degrees)]
[r:val = math.acos_r(radians)]
[r:val = math.asin(degrees)]
[r:val = math.asin_r(radians)]
[r:val = math.atan(degrees)]
[r:val = math.atan_r(radians)]
[r:val = math.atan2(degrees)]
[r:val = math.atan2_r(radians)]
[r:val = math.cos(degrees)]
[r:val = math.cos_r(num)]
[r:val = math.sin(degrees)]
[r:val = math.sin_r(num)]
[r:val = math.tan(degrees)]
[r:val = math.tan_r(num)]
[r:val = math.toDegrees(num)]
[r:val = math.toRadians(degrees)]
Power and root:
[r:val = math.sqrt(num)]
[r:val = math.squareroot(num)]
[r:val = math.cbrt(num)]
[r:val = math.cuberoot(num)]
[r:val = math.pow(num1,num2)]
Logarithmic
[r:val = math.log(num)] (this is the log to base e)
[r:val = math.log10(num)]
Pythagorean:
[r:val = math.hypot(num1, num2)]
[r:val = math.hypotenuse(num1, num2)]
Simple operations
[r:val = math.abs(num)]
[r:val = math.ceil(num)]
[r:val = math.floor(num)]
[r:val = math.isEven(num)]
[r:val = math.isInt(num)]
[r:val = math.isOdd(num)]
[r:val = math.max(num1, num2, num2, etc.)]
[r:val = math.min(num1, num2, num2, etc.)]
[r:val = math.mod(dividend, divisor)]
Examples
abs
[r:val = math.abs(-3)]
Returns: 3.0
mod
Returns the result of the modulo operation between the two numbers, which represents the remainder after a division operation.
[r: math.mod(14,6)]
Returns 2
[r: math.mod(10,5)]
Returns 0
[r: math.mod(-13,4)
Returns -1
pow
[r:val = math.pow(2,3)]