public static CGPoint?Intersection(CGPoint from, CGPoint to, CGPoint from2, CGPoint to2) { var cgPoint = new CGPoint(to.X - from.X, to.Y - from.Y); var self = new CGPoint(to2.X - from2.X, to2.Y - from2.Y); var point1 = new CGPoint(from2.X - from.X, from2.Y - from.Y); var point2 = new CGPoint(to.X - from2.X, to.Y - from2.Y); var nfloat1 = self.Cross(point1); var nfloat2 = self.Cross(point2); if (Math.Abs(nfloat1 + nfloat2) < 0.1) { return(new CGPoint?()); } var nfloat3 = nfloat1 / (nfloat1 + nfloat2); return(new CGPoint(from.X + nfloat3 * cgPoint.X, from.Y + nfloat3 * cgPoint.Y)); }