/// <summary> /// http://www.ambrsoft.com/TrigoCalc/Plan3D/PlaneLineIntersection_.htm /// https://www.youtube.com/watch?v=WPYTruLFas8 /// </summary> /// <param name="edge"></param> /// <param name="planePosition"></param> /// <returns></returns> public static MVertex GetIntersection(STLEdge edge, double planePosition) { // plane equation = z - D; where D = planePosition // and the z equation in the parametric form // z = zp + ct; where c = edge.End.Z - edge.Start.Z and zp = edge.Start.Z double t = (planePosition - edge.Start.Z) / (edge.End.Z - edge.Start.Z); return(new MVertex( edge.Start.X + ((edge.End.X - edge.Start.X) * t), edge.Start.Y + ((edge.End.Y - edge.Start.Y) * t) )); }
public static bool CompareEqual(STLEdge e1, STLEdge e2, double tolerance = 0.0001) { return(CompareEqual(e1.Start, e2.Start, tolerance) && CompareEqual(e1.End, e2.End, tolerance)); }
public void PrintEdge(string tag, STLEdge edge) { Console.WriteLine($"{tag} Edge"); PrintVertex("Start", edge.Start); PrintVertex("End", edge.End); }