public static void zeichneVektor(Vektor v, Vektor Startpunkt) { double a = v.y / v.x; for (int i = 0; i < v.x; i += 2) { Console.SetCursorPosition((int)(Startpunkt.x + i), (int)(Startpunkt.y + a * i)); Console.Write("*"); } }
public static Vektor Vektorprodukt(Vektor a, Vektor b) { return(new Vektor(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x)); }
public static double Skalarprodukt(Vektor a, Vektor b) { return(a.x * b.x + a.y * b.y + a.z * b.z); }
//TODO Punkte //TODO Vorzeichen //TODO KGV Vektor //TODO GGT Vektor //TODO Surface (Rechteck, Quadrat, Dreieck, Kreis) //TODO Volume (Würfel, Quader, Spat, Pyramide...) //TODO Ebene //TODO GERADE public static double Abs(Vektor a) { return(Math.Sqrt(a.x * a.x + a.y * a.y + a.z * a.z)); }
//TODO public static Vektor Einheitsvektor(Vektor a) { double absA = Vektor.Abs(a); return(new Vektor(a.x / absA, a.y * absA, a.z * absA)); }
//TODO public static Vektor SkalarDivision(Vektor a, double b) { return(new Vektor(a.x / b, a.y / b, a.z / b)); }
public static double Zwischenwinkel(Vektor a, Vektor b) { return((180 / Math.PI) * Math.Acos(Vektor.Skalarprodukt(a, b) / (Vektor.Abs(a) * Vektor.Abs(b)))); }
public Linie() { Console.WriteLine("Konstruktor Linie"); this.a = new Vektor(0, 0, 0); this.b = new Vektor(0, 0, 0); }
public static Vektor Addition(Vektor a, Vektor b) { return(new Vektor(a.x + b.x, a.y + b.y, a.z + b.z)); }
public static Vektor operator *(Vektor a, double b) { return(Vektor.SkalarMultiplikation(a, b)); }
public static Vektor operator /(Vektor a, double b) { return(Vektor.SkalarDivision(a, b)); }
public static double operator *(Vektor a, Vektor b) { return(Vektor.Skalarprodukt(a, b)); }
public static Vektor operator -(Vektor a, Vektor b) { return(Vektor.Subtraktion(a, b)); }
public static Vektor operator +(Vektor a, Vektor b) { return(Vektor.Addition(a, b)); }
public Linie(Vektor a, Vektor b) { this.a = a; this.b = b; }
public static Vektor Subtraktion(Vektor a, Vektor b) { return(new Vektor(a.x - b.x, a.y - b.y, a.z - b.z)); }
public Linie(Vektor a) { this.b = a; }
public static Vektor SkalarMultiplikation(Vektor b, double a) { return(new Vektor(b.x * a, b.y * a, b.z * a)); }
public static int Main(string[] args) { //System.Threading.Thread t1 = new System.Threading.Thread(new System.Threading.ThreadStart(GdiThread1)); //t1.Start(); //System.Threading.Thread t2 = new System.Threading.Thread(new System.Threading.ThreadStart(GdiThread2)); //t2.Start(); System.Threading.Thread t3 = new System.Threading.Thread(new System.Threading.ThreadStart(gdiThread3)); t3.Start(); Console.Clear(); Console.Beep(2000, 50); System.Threading.Thread.Sleep(30); Console.Beep(1000, 50); Console.WriteLine("Beispielprogramm für simple Bruch- und Vektorbibliothek"); Console.WriteLine("-------------------------------------------------------"); Console.WriteLine(); Console.WriteLine("Bereitstellen der Brüche:"); Console.WriteLine(); Bruch a = new Bruch(1, 2); Bruch b = new Bruch(-1, 4); Bruch c = new Bruch(3, 10); Console.WriteLine("a = " + a + " b = " + b + " c = " + c); Console.WriteLine(); Console.WriteLine("Rechnen mit Brüchen:"); Bruch d = a + b; Console.WriteLine("a + b = " + d); Console.WriteLine("Das ganze gekürzt (also durch den ggT geteilt): " + Bruch.Kuerzen(a + b)); Bruch e = a * c; Console.WriteLine("a * c = " + e); Console.WriteLine(); Console.WriteLine("Bereitstellen der Vektoren:"); Console.WriteLine(); Vektor A = new Vektor(1, 0, 0); Vektor B = new Vektor(0, 2, 0); Vektor C = new Vektor(0, 0, 3); Console.WriteLine("A = " + A + " B = " + B + " C = " + C); Console.WriteLine("(a + b) * A = " + ((a + b) * A)); Console.WriteLine(); Console.WriteLine("(a * b) * (A*B) = " + (a * b) * (A * B)); // Schön wäre zumindest das Vektorprodukt auch noch mit überlademem Operator zu // steuern, leider hat das * schon die höchste Priorität bei den operatorn // Alternativ müsste man einen Parser schreiben Console.WriteLine("(a * b) * (AxB) = " + (a * b) * Vektor.Vektorprodukt(A, B)); Console.WriteLine("(a * b) * (BxA) = " + (a * b) * Vektor.Vektorprodukt(B, A)); Console.WriteLine("(a * b) * <A B C> = " + (a * b) * Vektor.Spatprodukt(A, B, C)); Console.WriteLine("Winkel Zwischen A und B: " + Vektor.Zwischenwinkel(A, B) + "°"); Console.WriteLine(); Console.WriteLine("Bitte eine Taste drücken!"); Console.ReadKey(); Console.Clear(); //Vektor.zeichneVektor(new Vektor(50,20,0),new Vektor(3,3,0)); for (int i = 1; i < 17; i++) { Console.WriteLine(i + " " + primFaktoren.istPrim(i)); } Console.WriteLine("----------------------------------------"); primFaktoren pf = new primFaktoren(); primFaktoren.primfaktoren(1230); Console.WriteLine("----------------------------------------"); pf.gekuerzteTeiler(2 * 2 * 3 * 3 * 3 * 7); Console.WriteLine("----------------------------------------"); Console.ReadKey(); return(0); }
public static double Spatprodukt(Vektor a, Vektor b, Vektor c) { return(Skalarprodukt(a, Vektorprodukt(b, c))); }