Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:programmingblocks:math [2018/06/12 10:42]
kniwwelino [Trigonometric functions]
en:programmingblocks:math [2018/07/18 08:36] (current)
kniwwelino [Trigonometric functions]
Line 1: Line 1:
 +===== Math =====
 +
 +==== Number ====
 +{{:en:programmingblocks:math_01.png|}}
 +
 +This block allows you to define a positive or negative number and use it as part of another block. This number can either be an integer, e.g. ''-58'', or a float, e.g., ''1.58''.
 +
 +\\
 +==== Operation ====
 +{{:en:programmingblocks:math_02.png|}}
 +
 +With this block you can make basic mathematical operations on two numbers.
 +
 +Options:
 +  * ''+'': addition
 +  * ''-'': substraction
 +  * ''x'': multiplication
 +  * ''%'': division
 +  * ''^'': exponentiation
 +
 +\\
 +==== Random integer ====
 +{{:en:programmingblocks:math_03.png|}}
 +
 +This block returns an integer between or equal to the two specified numbers, which is generated randomly at each call.
 +
 +\\
 +==== Random fraction ====
 +{{:en:programmingblocks:math_04.png|}}
 +
 +This block returns a random floating point number larger or equal to 0.0 and strictly smaller than 1.0.
 +
 +\\
 +==== Increase variable ====
 +{{:en:programmingblocks:math_05.png|}}
 +
 +This block, adds a number to a selected variable. When choosing a negative number, the number is substracted.
 +
 +\\
 +==== Constrain value ====
 +{{:en:programmingblocks:math_06.png|}}
 +
 +This block restricts a value to a specified range. The result will be identical if the value is between the two limits. In case the value is smaller than the minimum (resp larger then the maximum), the result will be set to the minimum (resp maximum).
 +\\
 +==== Map value ====
 +{{:en:programmingblocks:math_07.png|}}
 +
 +\\
 +==== Mathematical functions ====
 +{{:en:programmingblocks:math_08.png|}}
 +
 +This block allows you to apply classical mathematical functions to numbers.
 +
 +Options:
 +  * ''square root''
 +  * ''absolute'': a number's numerical value without regard to its sign
 +  * ''-'': opposite number (sign reversed)
 +  * ''ln'': logarithm with base e
 +  * ''log10'': logarithm to base 10
 +  * ''e^'': exponentiation with base e
 +  * ''10^'': exponentiation with base 10
 +
 +\\
 +==== Trigonometric functions ====
 +{{:en:programmingblocks:math_09.png|}}
 +
 +This block allows you to apply classical trigonometric functions to numbers. 
 +
 +Options:
 +  * ''sin'': calculates the sine of an angle (in radians), result is between -1 and 1
 +  * ''cos'': calculates the cosine of an angle (in radians), result is between -1 and 1
 +  * ''tan'': calculates the tangent of an angle (in radians), result is between negative infinity and infinity
 +  * ''asin'': calculates the arc sine of a given number in radians
 +  * ''acos'': calculates the arc cosine of a given number in radians
 +  * ''atan'': calculates the arc tangent of a given number in radians
 +
 +\\
 +==== Mathematical constants ====
 +{{:en:programmingblocks:math_10.png|}}
 +
 +This block provides you with mathematical constants.
 +
 +Options:
 +  * ''π'': Archimedes' constant, equals approximately to 3.1415926535
 +  * ''e'': Euler's number, equals approximately to 2.7182818284
 +  * ''φ'': Golden ratio, equals approximately to 1.61803398874
 +  * ''sqrt(2)'': Pythagoras' constant, square root of 2, equals approximately to 1.4142135623
 +  * ''sqrt(1/2)'': square root of 1/2
 +  * ''∞'': infinity
 +\\
 +==== Number checks ====
 +{{:en:programmingblocks:math_11.png|}}
 +
 +With this block you can do typical number checks. The result will be ''true'' or ''false''.
 +
 +Options:
 +  * ''even'': checks if an integer is even (divisible by 2)
 +  * ''odd'': checks if an integer is odd (not even)
 +  * ''prime'': checks if an integer is a prime number
 +  * ''whole'': checks if a number is an integer
 +  * ''positive'': checks if a number is > or = to 0
 +  * ''negative'': checks if a number is < than 0
 +  * ''divisible by'': checks if a number is divisible by a given number
 +
 +\\
 +==== Rounding a number ====
 +{{:en:programmingblocks:math_12.png|}}
 +
 +This block allows you to round a floating point number to an integer.
 +
 +Options:
 +  * ''round'': rounds the number to the nearest integer, e.g. round(5.6) = 6  
 +  * ''round up'': rounds the number to the nearest integer larger than the number, e.g. round(5.2) = 6
 +  * ''round down'': rounds the number to the nearest integer smaller than the number, e.g. round(5.6) = 5
 +
 +\\
 +==== Remainder ====
 +{{:en:programmingblocks:math_13.png|}}
 +
 +This block returns the remainder after division of one number by another.
 +
 +E.g. ''remainder of 11 % 2'' will return ''1'', or ''remainder of 19 % 10'' will return ''9''
 +