public bool IntersectsXY(IntLineSegment3 other) { cInt ax = X1, ay = Y1, bx = X2, by = Y2; cInt cx = other.X1, cy = other.Y1, dx = other.X2, dy = other.Y2; // http://stackoverflow.com/questions/3838329/how-can-i-check-if-two-segments-intersect var tl = Math.Sign((ax - cx) * (by - cy) - (ay - cy) * (bx - cx)); var tr = Math.Sign((ax - dx) * (by - dy) - (ay - dy) * (bx - dx)); var bl = Math.Sign((cx - ax) * (dy - ay) - (cy - ay) * (dx - ax)); var br = Math.Sign((cx - bx) * (dy - by) - (cy - by) * (dx - bx)); return(tl == -tr && bl == -br); }
// Equality by endpoints, not line geometry public bool Equals(IntLineSegment3 other) { return(First == other.First && Second == other.Second); }