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); }
public static IMesh Stretch(IMesh mesh, IPlane plane = default, IVector3D direction = default, double stretchFactor = 1, double compressionFactor = 1) { if (plane == default) { plane = IPlane.WorldXY; } if (direction == default) { direction = plane.Normal; } IMesh dM = mesh.DeepCopy(); IPoint3D p; IVector3D vec; ITopologicVertex v; foreach (int vK in mesh.VerticesKeys) { v = dM.GetVertexWithKey(vK); double d = plane.DistanceToPlane(v.Position); if (d > 1e-9) { p = plane.GetClosestPoint(v.Position); vec = v.Position - p; vec *= stretchFactor; vec += p; p = GetClosestPointToFictiousLine(v.Position, plane.Origin, plane.Origin + direction); vec -= p; vec *= 1 / compressionFactor; vec += p; dM.SetVertexPosition(vK, vec.X, vec.Y, vec.Z); } } dM.UpdateGraphics(); return(dM); }