Last active
October 7, 2020 17:24
-
-
Save chuongmep/72b8e79f65206d612654963a9909ccaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Check Intersect Between Two Curve | |
/// </summary> | |
/// <param name="c1"></param> | |
/// <param name="c2"></param> | |
/// <returns></returns> | |
public static XYZ Intersection(this Curve c1, Curve c2) | |
{ | |
XYZ p1 = c1.GetEndPoint(0); | |
XYZ q1 = c1.GetEndPoint(1); | |
XYZ p2 = c2.GetEndPoint(0); | |
XYZ q2 = c2.GetEndPoint(1); | |
XYZ v1 = q1 - p1; | |
XYZ v2 = q2 - p2; | |
XYZ w = p2 - p1; | |
XYZ p5 = null; | |
double c = (v2.X * w.Y - v2.Y * w.X) | |
/ (v2.X * v1.Y - v2.Y * v1.X); | |
if (!double.IsInfinity(c)) | |
{ | |
double x = p1.X + c * v1.X; | |
double y = p1.Y + c * v1.Y; | |
p5 = new XYZ(x, y, 0); | |
} | |
return p5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment