Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

BlitzMax/Modules/Math/Math

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Functions IsNan Function IsNan( x:Double ) Description: Check if a value is NAN Returns: True if x is 'not a number' (e.g.: Sqr(-1)) Example: Local a:Float = Sqr(-1) Local b:Int = IsNan(a) 'b will equal True in this example, because the square root of -1 is 'not a number' IsInf Function IsInf( x:Double ) Description: Check if a value is infinite (e.g.: 1.0/0.0) Returns: True if x is infinite Example: Local a:Float = 1.0 / 0.0 Local b:Int = IsInf(a) 'b will equal True in this example, because 1.0 divided by 0.0 is infinite Sqr Function Sqr:Double( x:Double ) Description: Square root of x Example: Local a:Int = 4 Local b:Int = Sqr(a) Sin Function Sin:Double( x:Double ) Description: Sine of x degrees Cos Function Cos:Double( x:Double ) Description: Cosine of x degrees Tan Function Tan:Double( x:Double ) Description: Tangent of x degrees ASin Function ASin:Double( x:Double ) Description: Inverse Sine of x Comments: The inverse sine can determine the remaining angles of a right triangle when the lengths of the sides are known. For instance, an angle may be calculated using the length of the opposite side and the hypotenuse. Example: Local alpha:Double = ASin(length_opposite / length_hypotenuse) ACos Function ACos:Double( x:Double ) Description: Inverse Cosine of x Comments: The inverse cosine can determine the remaining angles of a right triangle when the lengths of the sides are known. For instance, an angle may be calculated using the length of the adjacent side and the hypotenuse. Example: Local alpha:Double = ACos(length_adjacent / length_hypotenuse) ATan Function ATan:Double( x:Double ) Description: Inverse Tangent of x Comments: The inverse tangent can determine the remaining angles of a right triangle when the lengths of the sides are known. For instance, an angle may be calculated using the length of the opposite side and the adjacent side. Example: Local alpha:Double = ATan(length_opposite / length_adjacent) ATan2 Function ATan2:Double( y:Double,x:Double ) Description: Inverse Tangent of two variables x , y Comments: ATan2 is similar to ATan. However, it makes use of the two arguments signs to determine the angle of a imaginary vector (x,y) relatively to the x-axis (counterclockwise). This is very useful, for example in determining the direction from one point to another. Example: Local ax:Float = -1, ay:Float =- 2 'Point A Local bx:Float = 3, by:Float = 2 'Point B 'Notice how the variables we are using are Float's, BlitzMax will automatically 'convert them into Double's when we call ATan2() Local angle:Float = ATan2(by - ay, bx - ax) 'Angle from A to B Sinh Function Sinh:Double( x:Double ) Description: Hyperbolic sine of x Cosh Function Cosh:Double( x:Double ) Description: Hyperbolic cosine of x Tanh Function Tanh:Double( x:Double ) Description: Hyperbolic tangent of x Exp Function Exp:Double( x:Double ) Description: Exponential function Log Function Log:Double( x:Double ) Description: Natural logarithm Log10 Function Log10:Double( x:Double ) Description: Base 10 logarithm Ceil Function Ceil:Double( x:Double ) Description: Smallest integral value not less than x Floor Function Floor:Double( x:Double ) Description: Largest integral value not greater than x Comments: Ceil() will round a variable up, whereas Floor() will round it down. Example: Local a:Float = 3.5 Local round_up:Float = Ceil(a) 'Becomes 4.0 Local round_down:Float = Floor(a) 'Becomes 3.0