Difference between revisions of "ObjectType:math"

From Lavish Software Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
  
 
== Members ==
 
== Members ==
* [[DataType:float|float]] '''Abs['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the absolute value of a given formula
+
* [[ObjectType:float|float]] '''Abs['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the absolute value of a given formula
* [[DataType:float|float]] '''Asin['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the asin of a given formula in degrees (<tt>asin(sin(x))=x</tt>)
+
* [[ObjectType:float|float]] '''Asin['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the asin of a given formula in degrees (<tt>asin(sin(x))=x</tt>)
* [[DataType:float|float]] '''Acos['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the acos of a given formula in degrees (<tt>acos(cos(x))=x</tt>)
+
* [[ObjectType:float|float]] '''Acos['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the acos of a given formula in degrees (<tt>acos(cos(x))=x</tt>)
* [[DataType:float|float]] '''Atan['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the atan of a given formula in degrees (<tt>atan(tan(x))=x</tt>)
+
* [[ObjectType:float|float]] '''Atan['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the atan of a given formula in degrees (<tt>atan(tan(x))=x</tt>)
* [[DataType:float|float]] '''Atan['''[[LavishScript:Mathematical Formulae|formula]]''','''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the atan2 of two given formulae in degrees
+
* [[ObjectType:float|float]] '''Atan['''[[LavishScript:Mathematical Formulae|formula]]''','''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the atan2 of two given formulae in degrees
* [[DataType:float|float]] '''Calc['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the result of a given formula
+
* [[ObjectType:float64ptr|float64ptr]] '''Calc['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the result of a given formula
* [[DataType:int64ptr|int64ptr]] '''Calc64['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the result of a given formula with 64-bit integer precision
+
* [[ObjectType:int64ptr|int64ptr]] '''Calc64['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the result of a given formula with 64-bit integer precision
* [[DataType:float|float]] '''Cos['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the cosine of a given formula in degrees
+
* [[ObjectType:float|float]] '''Cos['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the cosine of a given formula in degrees
* [[DataType:float|float]] '''Sin['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the sine of a given formula in degrees
+
* [[ObjectType:float|float]] '''Sin['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the sine of a given formula in degrees
* [[DataType:float|float]] '''Sqrt['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the square root of a given formula
+
* [[ObjectType:float|float]] '''Sqrt['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the square root of a given formula
* [[DataType:float|float]] '''Tan['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the tangent of a given formula in degrees
+
* [[ObjectType:float|float]] '''Tan['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns the tangent of a given formula in degrees
* [[DataType:float|float]] '''Distance['''x1,x2''']''': Returns the 1-dimensional distance between x1 and x2
+
* [[ObjectType:float|float]] '''Distance['''x1,x2''']''': Returns the 1-dimensional distance between x1 and x2
* [[DataType:float|float]] '''Distance['''x1,y1,x2,y2''']''': Returns the 2-dimensional distance between x1,y1 and x2,y2
+
* [[ObjectType:float|float]] '''Distance['''x1,y1,x2,y2''']''': Returns the 2-dimensional distance between x1,y1 and x2,y2
* [[DataType:float|float]] '''Distance['''x1,y1,z1,x2,y2,z2''']''': Returns the 3-dimensional distance between x1,y1,z1 and x2,y2,z2
+
* [[ObjectType:float|float]] '''Distance['''x1,y1,z1,x2,y2,z2''']''': Returns the 3-dimensional distance between x1,y1,z1 and x2,y2,z2
* [[DataType:string|string]] '''Hex['''#''']''': Returns a hexadecimal string equivalent to the #
+
* [[ObjectType:string|string]] '''Hex['''#''']''': Returns a hexadecimal string equivalent to the #
* [[DataType:int|int]] '''Rand['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns a random number from 0 to # - 1, where # is the result of the given formula
+
* [[ObjectType:int|int]] '''Rand['''[[LavishScript:Mathematical Formulae|formula]]''']''': Returns a random number from 0 to # - 1, where # is the result of the given formula. The maximum value that can be returned is 32767.
* [[DataType:int|int]] '''Not['''#''']''':  Returns the bitwise NOT of the #
+
* [[ObjectType:int|int]] '''Not['''#''']''':  Returns the bitwise NOT of the #
* [[DataType:int|int]] '''Dec['''hex''']''': Returns the decimal equivalent to the hexadecimal value given
+
* [[ObjectType:int|int]] '''Dec['''hex''']''': Returns the decimal equivalent to the hexadecimal value given
* [[DataType:float|float]] '''DistancePointLine['''x,y,ax,ay,bx,by''']''': Returns the distance from x,y to the nearest point on the line from a and b, or NULL if the point (x,y) does not intersect (ax,ay)-(bx,by).
+
* [[ObjectType:float|float]] '''DistancePointLine['''x,y,ax,ay,bx,by''']''': Returns the distance from x,y to the nearest point on the line from a and b, or NULL if the perpendicular passing through point (x,y) to the line defined by (ax,ay) (bx,by) does not intersect on the segment between points a and b.
  
 
== Methods ==
 
== Methods ==
Line 30: Line 30:
  
 
== Examples ==
 
== Examples ==
===Create a random number between 10 and 100===
+
===Create a random number between 10 and 99===
 
*${Math.Rand[90]:Inc[10]}
 
*${Math.Rand[90]:Inc[10]}
:Returns 10-100
+
:Returns 10-99
 +
 
 
===Return absolute value of a variable===
 
===Return absolute value of a variable===
 
*${Math.Abs[Faction]}
 
*${Math.Abs[Faction]}
 
===Display the cosine of a given formula===
 
===Display the cosine of a given formula===
*declare x int 9293
+
*variable int x=9293
 
*echo ${Math.Cos[${x}*82]}
 
*echo ${Math.Cos[${x}*82]}
 
;Output
 
;Output
 
  -0.07
 
  -0.07
 
===Square root a variable and set it as that number===
 
===Square root a variable and set it as that number===
*declare x float 12934
+
*variable float x=12934
 
*x:Set[${Math.Sqrt[${x}]}]
 
*x:Set[${Math.Sqrt[${x}]}]
 
*echo X=${x}
 
*echo X=${x}
Line 65: Line 66:
 
== See Also ==
 
== See Also ==
 
* [[LavishScript:Mathematical Formulae|Mathematical Formulae]]
 
* [[LavishScript:Mathematical Formulae|Mathematical Formulae]]
* [[LavishScript:Data Types|Data Types]]
+
{{LavishScript:ObjectType}}
[[Category:LavishScript]]
 
[[Category:LavishScript Data Types]]
 

Latest revision as of 16:41, 8 July 2018

Description

Members

  • float Abs[formula]: Returns the absolute value of a given formula
  • float Asin[formula]: Returns the asin of a given formula in degrees (asin(sin(x))=x)
  • float Acos[formula]: Returns the acos of a given formula in degrees (acos(cos(x))=x)
  • float Atan[formula]: Returns the atan of a given formula in degrees (atan(tan(x))=x)
  • float Atan[formula,formula]: Returns the atan2 of two given formulae in degrees
  • float64ptr Calc[formula]: Returns the result of a given formula
  • int64ptr Calc64[formula]: Returns the result of a given formula with 64-bit integer precision
  • float Cos[formula]: Returns the cosine of a given formula in degrees
  • float Sin[formula]: Returns the sine of a given formula in degrees
  • float Sqrt[formula]: Returns the square root of a given formula
  • float Tan[formula]: Returns the tangent of a given formula in degrees
  • float Distance[x1,x2]: Returns the 1-dimensional distance between x1 and x2
  • float Distance[x1,y1,x2,y2]: Returns the 2-dimensional distance between x1,y1 and x2,y2
  • float Distance[x1,y1,z1,x2,y2,z2]: Returns the 3-dimensional distance between x1,y1,z1 and x2,y2,z2
  • string Hex[#]: Returns a hexadecimal string equivalent to the #
  • int Rand[formula]: Returns a random number from 0 to # - 1, where # is the result of the given formula. The maximum value that can be returned is 32767.
  • int Not[#]: Returns the bitwise NOT of the #
  • int Dec[hex]: Returns the decimal equivalent to the hexadecimal value given
  • float DistancePointLine[x,y,ax,ay,bx,by]: Returns the distance from x,y to the nearest point on the line from a and b, or NULL if the perpendicular passing through point (x,y) to the line defined by (ax,ay) (bx,by) does not intersect on the segment between points a and b.

Methods

None

Returns

NULL

Examples

Create a random number between 10 and 99

  • ${Math.Rand[90]:Inc[10]}
Returns 10-99

Return absolute value of a variable

  • ${Math.Abs[Faction]}

Display the cosine of a given formula

  • variable int x=9293
  • echo ${Math.Cos[${x}*82]}
Output
-0.07

Square root a variable and set it as that number

  • variable float x=12934
  • x:Set[${Math.Sqrt[${x}]}]
  • echo X=${x}
Output
 X=113.73

Obtain a hex value from a number

  • echo Hex value of 1234567890: ${Math.Hex[1234567890]}
Output
Hex value of 1234567890: 499602d2

Obtain a number from a hex value

  • echo Hex 499602d2 converted to a number: ${Math.Dec[499602d2]}
Output
Hex 499602d2 converted to a number: 1234567890

Find the distance between two 3-dimensional points

  • echo Distance between point 4332,3194,-293 and 1023,4823,-5991 is: ${Math.Distance[4332,3194,-293,1023,4823,-5991]}
Output
Distance between point 4332,3194,-293 and 1023,4823,-5991 is: 6787.51


Operates On

none

See Also

LavishScript Object Types