internal static IPoint3D GetClosestPointToFictiousLine(IPoint3D p, IPoint3D lineStart, IPoint3D lineEnd) { IVector3D direction = lineEnd - lineStart; IVector3D projection = lineStart - p; IPoint3D pos; double t = IVector3D.Dot(projection, direction); if (t <= 0) { return(lineStart); } else { double eval = Math.Pow(lineStart.DistanceTo(lineEnd), 2); if (t >= eval) { return(lineEnd); } else { t = t / eval; pos = new IPoint3D(); direction.Mult(t); pos = lineStart + direction; return(pos); } } }
public static IMesh Skew(IMesh mesh, IPlane plane = default, IVector3D skewDirection = default, double skewFactor = 1.0) { IMesh dM = mesh.DeepCopy(); if (plane == default) { plane = IPlane.WorldXY; } if (skewDirection == default) { skewDirection = IVector3D.UnitZ; } IPoint3D pt; double d; foreach (int vK in dM.VerticesKeys) { pt = dM.GetVertexWithKey(vK).Position; d = plane.DistanceToPlane(pt); if (d > 0) { pt += IVector3D.Mult(skewDirection, d * skewFactor); } dM.SetVertexPosition(vK, pt); } dM.UpdateGraphics(); return(dM); }