public void Drehen(double Winkel) { // Gradmaß in Bogemaß umrechnen Winkel *= Math.PI / 180; // Punkt speichern Point A_Alt = A; // Zum Ursprung verschieben Point Verschiebung = A; Verschiebung.X *= -1; Verschiebung.Y *= -1; Verschieben(new Vector(Verschiebung.X, Verschiebung.Y)); // Drehen mit Drehmatrix double MA = Math.Cos(Winkel); double MB = -Math.Sin(Winkel); double MC = Math.Sin(Winkel); double MD = Math.Cos(Winkel); TMatrix M = new TMatrix(MA, MB, MC, MD); Vector VA = M.VektorMult(new Vector(A.X, A.Y)); Vector VB = M.VektorMult(new Vector(B.X, B.Y)); Vector VC = M.VektorMult(new Vector(C.X, C.Y)); A = new Point(VA.X, VA.Y); B = new Point(VB.X, VB.Y); C = new Point(VC.X, VC.Y); // Zurück verschieben Verschieben(new Vector(A_Alt.X, A_Alt.Y)); }
private bool Kollision(Point A, Point B, Point P, Point Q, out Vector ST) { Vector BA = new Vector(A.X - B.X, A.Y - B.Y); Vector PQ = new Vector(Q.X - P.X, Q.Y - P.Y); Vector PA = new Vector(A.X - P.X, A.Y - P.Y); TMatrix M = new TMatrix(PQ.X, BA.X, PQ.Y, BA.Y); if (M.Determinante() == 0.0) { ST = new Vector(); return(false); } Vector X = M.Invertiert().VektorMult(PA); double s = X.X; double t = X.Y; ST = new Vector(s, t); const double Eps = 1E-12; if ((s < 0.0) || (t <= Eps) || (s > 1.0) || (t >= 1.0 - Eps)) { return(false); } return(true); }
public TMatrix Invertiert() { TMatrix M = new TMatrix(D, -B, -C, A); return(M.Mult(1 / Determinante())); }