} // End Function Determinant2d public MyPoint2D <T> Schnittpunktli(MyPoint2D <T> p1, MyPoint2D <T> p2, MyPoint2D <T> p3, MyPoint2D <T> p4) { T x1 = p1.X; T x2 = p2.X; T x3 = p3.X; T x4 = p4.X; T y1 = p1.Y; T y2 = p2.Y; T y3 = p3.Y; T y4 = p4.Y; T topaX = Determinant2d(x1, y1, x2, y2); T topbX = Determinant2d(x1, Arithmetics <T> .ONE, x2, Arithmetics <T> .ONE); T topcX = Determinant2d(x3, y3, x4, y4); T topdX = Determinant2d(x3, Arithmetics <T> .ONE, x4, Arithmetics <T> .ONE); T topX = Determinant2d(topaX, topbX, topcX, topdX); T bottomaX = Determinant2d(x1, Arithmetics <T> .ONE, x2, Arithmetics <T> .ONE); T bottombX = Determinant2d(y1, Arithmetics <T> .ONE, y2, Arithmetics <T> .ONE); T bottomcX = Determinant2d(x3, Arithmetics <T> .ONE, x4, Arithmetics <T> .ONE); T bottomdX = Determinant2d(y3, Arithmetics <T> .ONE, y4, Arithmetics <T> .ONE); T bottomX = Determinant2d(bottomaX, bottombX, bottomcX, bottomdX); T x = Arithmetics <T> .Divide(topX, bottomX); T topaY = Determinant2d(x1, y1, x2, y2); T topbY = Determinant2d(y1, Arithmetics <T> .ONE, y2, Arithmetics <T> .ONE); T topcY = Determinant2d(x3, y3, x4, y4); T topdY = Determinant2d(x3, Arithmetics <T> .ONE, y4, Arithmetics <T> .ONE); T topY = Determinant2d(topaY, topbY, topcY, topdY); T bottomaY = Determinant2d(x1, Arithmetics <T> .ONE, x2, Arithmetics <T> .ONE); T bottombY = Determinant2d(y1, Arithmetics <T> .ONE, y2, Arithmetics <T> .ONE); T bottomcY = Determinant2d(x3, Arithmetics <T> .ONE, x4, Arithmetics <T> .ONE); T bottomdY = Determinant2d(y3, Arithmetics <T> .ONE, y4, Arithmetics <T> .ONE); T bottomY = Determinant2d(bottomaY, bottombY, bottomcY, bottomdY); T y = Arithmetics <T> .Divide(topY, bottomY); // m = (y2-y1)/(x2-x1) // Case 1: horizontal line: slope = 0 | y=constant, x=variable // Case 2: vertical line: slope = +/-infinity | x=constant, y=variable // Case 3: Parallel => m1 = m2 // Case 4: orthogonal resp. right-angle => m1 = -1/m2 return(new MyPoint2D <T>(x, y)); } // End Function Schnittpunktli
} // End function DotP public static T Angle_Rad(MyVector2D <T> a, MyVector2D <T> b) { T axbx = Arithmetics <T> .Multiply(a.X, b.X); T ayby = Arithmetics <T> .Multiply(a.Y, b.Y); T azbz = Arithmetics <T> .ZERO; T sumAB = Arithmetics <T> .Sum(axbx, ayby, azbz); T ax2 = Arithmetics <T> .Pow(a.X, 2); T ay2 = Arithmetics <T> .Pow(a.Y, 2); T az2 = Arithmetics <T> .ZERO; T bx2 = Arithmetics <T> .Pow(b.X, 2); T by2 = Arithmetics <T> .Pow(b.Y, 2); T bz2 = Arithmetics <T> .ZERO; T aSquare = Arithmetics <T> .Sum(ax2, ay2, az2); T bSquare = Arithmetics <T> .Sum(bx2, by2, bz2); T val = Arithmetics <T> .Divide(sumAB, ( Arithmetics <T> .Multiply(Arithmetics <T> .Sqrt(aSquare), Arithmetics <T> .Sqrt(bSquare)) ) ); T nReturnValue = Arithmetics <T> .Acos(val); return(nReturnValue); } // End function Angle_Rad