TWiki
> Main
>
UsingTheMathsLibrary
Using the Maths Library
Mscape has a series of built-in functions for those times when you really need to do a little bit of trigonometry - for example you might want to find the distance between two points, or the angle between two lines.
I'm not going to teach you the maths for doing these on this page (Google for the Pythagoras theorem or basic trigonometry) - but instead I'll list the mathematical functions you can access as part of your mscape script.
Here's a simple example of using one of these functions..
Logger.Log (" The square root of 9 is " + Math.Sqrt(9) );
Note that all trigonometrical functions use angles in radians, not degrees.
| Math.Abs(n) |
Returns the absolute value of a specified number |
| Math.Acos(n) |
Returns the angle whose cosine is the specified number |
| Math.Asin(n) |
Returns the angle whose sine is the specified number |
| Math.Atan(n) |
Returns the angle whose tangent is the specified number |
| Math.Atan2(x, y) |
Returns the angle whose tangent is the quotient of two specified numbers. This function will give you the angle of a line from 0,0 to x,y in radians, measured from the x-axis |
| Math.Cos(n) |
Returns the cosine of the specified angle |
| Math.Cosh(n) |
Returns the hyperbolic cosine of the specified angle |
| Math.Cosh(n) |
Returns e raised to the specified power |
| Math.Floor(n) |
Returns the largest integer less than or equal to the specified number |
| Math.Log(n) |
Returns the logarithm of a specified number |
| Math.Log10(n) |
Returns the base 10 logarithm of a specified number |
| Math.Max(n, m) |
Returns the larger of two specified numbers |
| Math.Min(n, m) |
Returns the smaller of two numbers |
| Math.Pow(x, y) |
Returns a specified number raised to the specified power |
| Math.Round(n) |
Rounds a value to the nearest integer or specified number of decimal places |
| Math.Sign(n) |
Returns a value indicating the sign of a number (-1 negative, 1 positive) |
| Math.Sin(n) |
Returns the sine of the specified angle |
| Math.Sinh(n) |
Returns the hyperbolic sine of the specified angle |
| Math.Sqrt(n) |
Returns the square root of a specified number |
| Math.Tan(n) |
Returns the tangent of the specified angle |
| Math.Tanh(n) |
Returns the hyperbolic tangent of the specified angle |