'= , =, =, =, =, =, =, = ,=, = 'by downloading you agree, to use this couple of functions at your own risk! 'you DO have to know what you are doing, when and always when you are going to use them 'Please do not blame me for errors, maybe it is not my fault.. '2006 by ytwinky, MD Const Esc=!"\27" var i=0, m="" Dim Shared As Double Rho Dim As Double SollAT(8)={0, Sqr(3)/3, -Sqr(3)/3, 1, -1, Sqr(3), -Sqr(3), 1e270, -1e270} Dim As Double SollAG(8)={1E270, -1E270, Sqr(3), -Sqr(3), 1, -1, Sqr(3)/3, -Sqr(3)/3, 0} Dim As Double SollAS(10)={0, 1, -1, 0.5, -0.5, 1/Sqr(2), -1/Sqr(2), Sqr(3)/2, -Sqr(3)/2, 0.999, -0.999} Dim As Double SollAC(10)={1, -1, Sqr(3)/2, -Sqr(3)/2, 1/Sqr(2), -1/Sqr(2), 0.5, -0.5, 0.999, -0.999, 0} Function MenuChar(s As String, First As Integer=1, nVG As Integer=12)As String If First<>1 Then Print Left(s, First-1); Color nVG Print Chr(s[First-1]); Color 7 Return Mid(s, First+1) End Function Sub FormatIt(byVal AngleFunction As Double, byVal Angle As Double) Print Using" +##.######";AngleFunction; Print Using" ####.##";Angle*Rho End Sub Function ArcTan(x As Double) As Double 'Not really needed, just for fun.. Return Atn(x) 'ValueRage [-Inf..+Inf] End Function 'ReturnValue in[-Pi/2..Pi/2] Function ArcCos(x As Double) As Double 'ok Static As Double r(1)={0, 4*Atn(1)} Select Case Abs(x) 'ValueRange: -1..+1, others are not possible.. Case Is>1.0 Print "ArcCos-Error, Argument x>1.0" Print "x="; x GetKey End Case 0.0: Return r(1) Case 1.0: Return r(Abs(x<0)) Case Else: Return Atn(Sqr(1.0-x*x)/x)+r(Abs(x<0)) End Select End Function 'ReturnValue in[-Pi/2..Pi/2] Function ArcSin(x As Double) As Double Select Case Abs(x) Case Is>1.0 'ValueRange: -1..+1, others are not possible.. Print "ArcSin-Error, Argument x>1.0" Print "x="; x GetKey End Case 1.0 Return 2*Atn(x) 'case else would abort, because of runtime_error Case Else Return Atn(x/Sqr(1.0-x*x)) End Select End Function 'ReturnValue in[-Pi/2..Pi/2] Function ArcCot(byVal x As Double) As Double 'ok Dim As Double r=x 'ValueRage [-Inf..+Inf] If x<>0.0 Then r=Atn(1/x) If x<0 Then r+=4*Atn(1) Return r End Function 'ReturnValue in[-Pi/2..Pi/2] Print "Arc_Functions.Bas 2006 by ytwinky, MD" Print "The angles should show up in:" Print MenuChar("Gon, circle is 400 gon") Print MenuChar("Deg, circle is 360") Print MenuChar("Rad, circle is 2*Pi radians") Print "Your choice, stranger:"; Do m=lcase(Inkey) Sleep(1) Loop Until Instr("gdr" &Esc, m) Print m ' remember: m$ ist the abbreviation of Menu$, nothing else.. Select Case m Case "g" : Rho=50/Atn(1) Case "d" : Rho=45/Atn(1) Case "r" : Rho=1 Case Else : Print "OMG, I didn't want to hurt you.. :D" End Select If m<>Esc Then Print "ArcSin" For i=0 To UBound(SollAS) FormatIt(SollAS(i), ArcSin(SollAS(i))) Next Print "ArcCos" For i=0 To UBound(SollAC) FormatIt(SollAC(i), ArcCos(SollAC(i))) Next Print "ArcTan" For i=0 To UBound(SollAT) FormatIt(SollAT(i), ArcTan(SollAT(i))) Next Print "ArcCot" For i=0 To UBound(SollAG) FormatIt(SollAG(i), ArcCot(SollAG(i))) Next End If Print "Arc_Functions.Bas has been tested with FB0.20 using current FBEdit"; GetKey