Prechádzať zdrojové kódy

Moved math examples from brl.blitz to brl.math.

woollybah 6 rokov pred
rodič
commit
40a8a012bd

+ 0 - 9
blitz.mod/doc/acos.bmx

@@ -1,9 +0,0 @@
-Rem
-Inverse Cosine of x
-End Rem
-
-SuperStrict
-
-For Local d:Double = -1.0 To 1.0 Step 0.125
-	Print "ACos("+d+")="+ACos(d)
-Next

+ 0 - 9
blitz.mod/doc/asin.bmx

@@ -1,9 +0,0 @@
-Rem
-Inverse Sine of x
-End Rem
-
-SuperStrict
-
-For Local d:Double = -1.0 To 1.0 Step 0.125
-	Print "ASin("+d+")="+ASin(d)
-Next

+ 0 - 9
blitz.mod/doc/atan.bmx

@@ -1,9 +0,0 @@
-Rem
-ATan returns the Inverse Tangent of x
-End Rem
-
-SuperStrict
-
-For Local d:Double = -1.0 To 1.0 Step 0.125
-	Print "ATan("+d+")="+ATan(d)
-Next

+ 0 - 19
blitz.mod/doc/atan2.bmx

@@ -1,19 +0,0 @@
-Rem
-ATan2 returns the Inverse Tangent of two variables
-End Rem
-
-SuperStrict
-
-Function Angle:Double(x0:Double,y0:Double,x1:Double,y1:Double)
-	Return ATan2(y1-y0,x1-x0)
-End Function
-
-Graphics 640,480
-While Not KeyHit(KEY_ESCAPE)
-	Cls
-	Local x:Float = MouseX()
-	Local y:Float = MouseY()
-	DrawLine 320,240,x,y
-	DrawText "Angle="+Angle(320,240,x,y),20,20
-	Flip
-Wend

+ 0 - 9
blitz.mod/doc/ceil.bmx

@@ -1,9 +0,0 @@
-Rem
-Ceil(x#) returns the smallest integral value not less than x
-End Rem
-
-SuperStrict
-
-For Local i:Float = -1 To 1 Step .2
-	Print "Ceil("+i+")="+Ceil(i)
-Next

+ 0 - 9
blitz.mod/doc/cos.bmx

@@ -1,9 +0,0 @@
-Rem
-Cosine of x
-End Rem
-
-SuperStrict
-
-For Local d:Int = 0 To 360 Step 45
-	Print "Cos("+d+")="+Cos(d)
-Next

+ 0 - 9
blitz.mod/doc/floor.bmx

@@ -1,9 +0,0 @@
-Rem
-Floor(x!) returns the largest integral value not greater than x
-End Rem
-
-SuperStrict
-
-For Local i:Double = -1 To 1 Step .2
-	Print "Floor("+i+")="+Floor(i)
-Next

+ 0 - 9
blitz.mod/doc/log.bmx

@@ -1,9 +0,0 @@
-Rem
-Log(n#) returns the natural logarithm of n
-End Rem
-
-SuperStrict
-
-For n:Float = 1 To 20
-	Print "Log("+n+")="+Log(n)
-Next

+ 0 - 9
blitz.mod/doc/log10.bmx

@@ -1,9 +0,0 @@
-Rem
-Log10(n#) returns the Base 10 logarithm of n
-End Rem
-
-SuperStrict
-
-For Local n:Float = 0 To 100 Step 10
-	Print "Log10("+n+")="+Log10(n)
-Next

+ 0 - 9
blitz.mod/doc/sin.bmx

@@ -1,9 +0,0 @@
-Rem
-Sin:Double( x:Double )
-End Rem
-
-SuperStrict
-
-For Local d:Int = 0 To 360 Step 45
-	Print "Sin("+d+")="+Sin(d)
-Next

+ 0 - 9
blitz.mod/doc/tan.bmx

@@ -1,9 +0,0 @@
-Rem
-Tangent of x degrees
-End Rem
-
-SuperStrict
-
-For Local d:Int = 0 To 360 Step 45
-	Print "Tan("+d+")="+Float(Tan(d))
-Next

+ 5 - 11
math.mod/doc/acos.bmx

@@ -1,15 +1,9 @@
-'inverse cosine example
+Rem
+Inverse Cosine of x
+End Rem
 
 SuperStrict
 
-For Local x:Double = - 1 To 1 Step 0.5
-	Print "Arccos("+x+")="+ACos(x)+" degrees"
+For Local d:Double = -1.0 To 1.0 Step 0.125
+	Print "ACos("+d+")="+ACos(d)
 Next
-
-' ===================
-' Output
-' Arccos(-1.0000000000000000)=180.00000000000000 degrees
-' Arccos(-0.50000000000000000)=120.00000000000001 degrees
-' Arccos(0.00000000000000000)=90.000000000000000 degrees
-' Arccos(0.50000000000000000)=60.000000000000007 degrees
-' Arccos(1.0000000000000000)=0.00000000000000000 degrees

+ 5 - 11
math.mod/doc/asin.bmx

@@ -1,15 +1,9 @@
-'inverse sine example
+Rem
+Inverse Sine of x
+End Rem
 
 SuperStrict
 
-For Local x:Double = - 1 To 1 Step 0.5
-	Print "ArcSine("+x+")="+ASin(x)+" degrees"
+For Local d:Double = -1.0 To 1.0 Step 0.125
+	Print "ASin("+d+")="+ASin(d)
 Next
-
-' ===================
-' Output
-' ArcSine(-1.0000000000000000)=-90.000000000000000 degrees
-' ArcSine(-0.50000000000000000)=-30.000000000000004 degrees
-' ArcSine(0.00000000000000000)=0.00000000000000000 degrees
-' ArcSine(0.50000000000000000)=30.000000000000004 degrees
-' ArcSine(1.0000000000000000)=90.000000000000000 degrees

+ 5 - 11
math.mod/doc/atan.bmx

@@ -1,15 +1,9 @@
-'Inverse Tangent example
+Rem
+ATan returns the Inverse Tangent of x
+End Rem
 
 SuperStrict
 
-For Local x:Double = -1 To 1 Step 0.5
-	Print "ATan("+x+")="+ATan(x)+" degrees"
+For Local d:Double = -1.0 To 1.0 Step 0.125
+	Print "ATan("+d+")="+ATan(d)
 Next
-
-' ===================
-' Output
-' ATan(-1.0000000000000000)=-45.000000000000000 degrees
-' ATan(-0.50000000000000000)=-26.565051177077990 degrees
-' ATan(0.00000000000000000)=0.00000000000000000 degrees
-' ATan(0.50000000000000000)=26.565051177077990 degrees
-' ATan(1.0000000000000000)=45.000000000000000 degrees

+ 14 - 13
math.mod/doc/atan2.bmx

@@ -1,18 +1,19 @@
-'atan2 is a two-argument function that computes the arctangent of y / x 
-'given y And x, but with a range of ( - p,p].
+Rem
+ATan2 returns the Inverse Tangent of two variables
+End Rem
 
 SuperStrict
 
-Graphics 640 , 480
-Local x:Float
-Local y:Float
-Repeat
-	
+Function Angle:Double(x0:Double,y0:Double,x1:Double,y1:Double)
+	Return ATan2(y1-y0,x1-x0)
+End Function
+
+Graphics 640,480
+While Not KeyHit(KEY_ESCAPE)
 	Cls
-	x = MouseX()
-	y = MouseY()
-	DrawLine 320, 240, x, y
-	DrawText "Angle to mouse cursor=" + ATan2(y-240,x-320),10,10
+	Local x:Float = MouseX()
+	Local y:Float = MouseY()
+	DrawLine 320,240,x,y
+	DrawText "Angle="+Angle(320,240,x,y),20,20
 	Flip
-	
-Until KeyDown(KEY_ESCAPE) Or AppTerminate()
+Wend

+ 6 - 2
math.mod/doc/ceil.bmx

@@ -1,5 +1,9 @@
+Rem
+Ceil(x#) returns the smallest integral value not less than x
+End Rem
+
 SuperStrict
 
-For Local t:Int=-31 To 31
-	Print "real value: "+t/10.0+" Ceil value: "+Ceil(Double(t/10.0))
+For Local i:Float = -1 To 1 Step .2
+	Print "Ceil("+i+")="+Ceil(i)
 Next

+ 7 - 10
math.mod/doc/cos.bmx

@@ -1,12 +1,9 @@
-SuperStrict
-
-'The cosine of 0 degrees is 1
-Print Cos(0)
+Rem
+Cosine of x
+End Rem
 
-'The cosine of 90 degrees is 0. Note rounding errors
-Print Cos(90)
+SuperStrict
 
-' ===================
-' Output
-' 1.0000000000000000
-' 2.6535848171582721e-017
+For Local d:Int = 0 To 360 Step 45
+	Print "Cos("+d+")="+Cos(d)
+Next

+ 6 - 2
math.mod/doc/floor.bmx

@@ -1,5 +1,9 @@
+Rem
+Floor(x!) returns the largest integral value not greater than x
+End Rem
+
 SuperStrict
 
-For Local t:Int=-31 To 31
-	Print "real value: "+t/10.0+" Floor value: "+Floor(Double(t/10.0))
+For Local i:Double = -1 To 1 Step .2
+	Print "Floor("+i+")="+Floor(i)
 Next

+ 6 - 15
math.mod/doc/log.bmx

@@ -1,18 +1,9 @@
+Rem
+Log(n#) returns the natural logarithm of n
+End Rem
+
 SuperStrict
 
-For Local f:Float = - 0.4 Until 0.4 Step 0.2
-	If IsInf(Log(f) ) Then
-	Print "Log(" + f + ")=Infinity "+Log(f)
-	Else If IsNan(Log(f) ) Then
-		Print "Log(" + f + ") is not a real number "+Log(f)
-	Else
-		Print "Log(" + f + ")=" + Log(f) 
-   End If
+For n:Float = 1 To 20
+	Print "Log("+n+")="+Log(n)
 Next
-
-' ===================
-' Output
-' Log(-0.400000006) is not a real number -1.#IND000000000000
-' Log(-0.200000003) is not a real number -1.#IND000000000000
-' Log(0.000000000)=Infinity -1.#INF000000000000
-' Log(0.200000003)=-1.6094378975329393

+ 6 - 16
math.mod/doc/log10.bmx

@@ -1,19 +1,9 @@
+Rem
+Log10(n#) returns the Base 10 logarithm of n
+End Rem
+
 SuperStrict
 
-For Local f:Float = - 0.4 Until 0.41 Step 0.2
-	If IsInf(Log10(f) ) Then
-	Print "Log10(" + f + ")=Infinity "+Log10(f)
-	Else If IsNan(Log10(f) ) Then
-		Print "Log10(" + f + ") is not a real number "+Log10(f)
-	Else
-		Print "Log10(" + f + ")=" + Log10(f) 
-   End If
+For Local n:Float = 0 To 100 Step 10
+	Print "Log10("+n+")="+Log10(n)
 Next
-
-' ===================
-' Output
-' Log10(-0.400000006) is not a real number -1.#IND000000000000
-' Log10(-0.200000003) is not a real number -1.#IND000000000000
-' Log10(0.000000000)=Infinity -1.#INF000000000000
-' Log10(0.200000003)=-0.69896999786452674
-' Log10(0.400000006)=-0.39794000220054560

+ 7 - 10
math.mod/doc/sin.bmx

@@ -1,12 +1,9 @@
-SuperStrict
-
-'The sine of 0 degrees is 0
-Print Sin(0)
+Rem
+Sin:Double( x:Double )
+End Rem
 
-'The sine of 90 degrees is 1
-Print Sin(90)
+SuperStrict
 
-' ===================
-' Output
-' 0.00000000000000000
-' 1.0000000000000000
+For Local d:Int = 0 To 360 Step 45
+	Print "Sin("+d+")="+Sin(d)
+Next

+ 6 - 12
math.mod/doc/tan.bmx

@@ -1,15 +1,9 @@
+Rem
+Tangent of x degrees
+End Rem
+
 SuperStrict
 
-For Local x:Double = 0 To 180 Step 30
-	Print "Tan("+x+" degrees)="+Tan(x)
+For Local d:Int = 0 To 360 Step 45
+	Print "Tan("+d+")="+Float(Tan(d))
 Next
-
-' ===================
-' Output
-' Tan(0.00000000000000000 degrees)=0.00000000000000000
-' Tan(30.000000000000000 degrees)=0.57735026918962573
-' Tan(60.000000000000000 degrees)=1.7320508075688767
-' Tan(90.000000000000000 degrees)=16331778728383844.
-' Tan(120.00000000000000 degrees)=-1.7320508075688783
-' Tan(150.00000000000000 degrees)=-0.57735026918962573
-' Tan(180.00000000000000 degrees)=-1.2246063538223773e-016