Mathematische kurven zeichnen (Ansatz)
Übersicht

![]() |
BtbNBetreff: Mathematische kurven zeichnen (Ansatz) |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Function GetMath:Double(typ:String,val:Double)
typ = typ.ToUpper() Select typ Case "TAN" Return Tan(val) Case "SIN" Return Sin(val) Case "COS" Return Cos(val) Case "ATAN" Return ATan(val) Case "ASIN" Return ASin(val) Case "ACOS" Return ACos(val) Case "LOG" Return Log(val) EndSelect EndFunction Function DrawMath(typ:String,move:Int=0,modify:Int=100,ori:Byte=0) Local scrwdh:Int = 800 Local scrhgt:Int = 600 Local i:Int,x:Int,y:Int move:*-1 If ori = 1 Then x = GetMath(typ,move)*modify+scrwdh/2 y = 0 For i = 0 To scrhgt DrawLine(x,y,GetMath(typ,i+move)*modify+scrwdh/2,i) x = GetMath(typ,i+move)*modify+scrwdh/2 y = i Next Else x = 0 y = GetMath(typ,move)*modify+scrhgt/2 For i = 0 To scrwdh DrawLine(x,y,i,GetMath(typ,i+move)*modify+scrhgt/2) x = i y = GetMath(typ,i+move)*modify+scrhgt/2 Next EndIf EndFunction Das sind die beiden funktionen dafür, und hier ein Beispiel: Code: [AUSKLAPPEN] Strict
Framework BRL.GLMax2D Import BRL.Max2D Import BRL.Math SetGraphicsDriver(GLMax2DDriver()) Graphics(800,600,32,85) Function GetMath:Double(typ:String,val:Double) typ = typ.ToUpper() Select typ Case "TAN" Return Tan(val) Case "SIN" Return Sin(val) Case "COS" Return Cos(val) Case "ATAN" Return ATan(val) Case "ASIN" Return ASin(val) Case "ACOS" Return ACos(val) Case "LOG" Return Log(val) EndSelect EndFunction Function DrawMath(typ:String,move:Int=0,modify:Int=100,ori:Byte=0) Local scrwdh:Int = 800 Local scrhgt:Int = 600 Local i:Int,x:Int,y:Int move:*-1 If ori = 1 Then x = GetMath(typ,move)*modify+scrwdh/2 y = 0 For i = 0 To scrhgt DrawLine(x,y,GetMath(typ,i+move)*modify+scrwdh/2,i) x = GetMath(typ,i+move)*modify+scrwdh/2 y = i Next Else x = 0 y = GetMath(typ,move)*modify+scrhgt/2 For i = 0 To scrwdh DrawLine(x,y,i,GetMath(typ,i+move)*modify+scrhgt/2) x = i y = GetMath(typ,i+move)*modify+scrhgt/2 Next EndIf EndFunction Repeat Cls SetColor(255,0,0) DrawMath("Tan",MouseX()) SetColor(0,255,0) DrawMath("Cos",MouseY()) Flip Until KeyHit(KEY_ESCAPE) End |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group