public override List <double> Intersect(SimpleObject obj) { if (obj is StraightLine) { return(LineLineIntersect(this.args, obj.args)); } else if (obj is Circle) { return(LineCircleIntersect(this.args, obj.args)); } else if (obj is RayLine) { List <double> intersection = LineLineIntersect(this.args, obj.args); // Need to check if the intersection points is on the ray line. if (intersection.Count >= 2 && Dot(obj.args[0], obj.args[1], obj.args[2], obj.args[3], obj.args[0], obj.args[1], intersection[0], intersection[1]) < 0) { intersection.Clear(); } return(intersection); } else { List <double> intersection = LineLineIntersect(this.args, obj.args); // Need to check if the intersection points is on the line segment. if (intersection.Count >= 2 && Dot(intersection[0], intersection[1], obj.args[0], obj.args[1], intersection[0], intersection[1], obj.args[2], obj.args[3]) > 0) { intersection.Clear(); } return(intersection); } }
// Compute the intersection points between two geometric objects. public abstract List <double> Intersect(SimpleObject obj);