/// <summary> /// Transform calculator /// </summary> public bool CalculateTransform(Rhino.Display.RhinoViewport vp, double length, ref Rhino.Geometry.Transform xform) { bool rc = false; if (null == xform) { xform = new Rhino.Geometry.Transform(); } xform = Rhino.Geometry.Transform.Identity; if (length >= Rhino.RhinoMath.ZeroTolerance) { Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(vp.ConstructionPlane()) { Origin = m_origin }; Rhino.Geometry.Transform rotate_xform = Rhino.Geometry.Transform.PlaneToPlane(Rhino.Geometry.Plane.WorldXY, plane); Rhino.Geometry.Transform scale_xform = Rhino.Geometry.Transform.Scale(plane, length, length, length); xform = scale_xform * rotate_xform; rc = xform.IsValid; if (rc) { m_length = length; } } return(rc); }
public Transform CalculateTransform(Rhino.Display.RhinoViewport viewport, double d) { Point3d basePoint; if (!TryGetBasePoint(out basePoint)) { return(Transform.Identity); } Plane plane = viewport.ConstructionPlane(); plane.Origin = basePoint; Vector3d v = RefPoint - basePoint; double len1 = v.Length; if (Math.Abs(len1) < 0.000001) { return(Transform.Identity); } v.Unitize(); v = v * d; double len2 = v.Length; if (Math.Abs(len2) < 0.000001) { return(Transform.Identity); } Scale = len2 / len1; return(Transform.Scale(plane, Scale, Scale, Scale)); }
/// <summary> /// Transform calculator /// </summary> public bool CalculateTransform(Rhino.Display.RhinoViewport vp, Rhino.Geometry.Point3d pt, ref Rhino.Geometry.Transform xform) { bool rc = false; if (null == xform) { xform = new Rhino.Geometry.Transform(); } xform = Rhino.Geometry.Transform.Identity; if (pt.IsValid) { Rhino.Geometry.Plane plane = new Rhino.Geometry.Plane(vp.ConstructionPlane()) { Origin = m_origin }; Rhino.Geometry.Vector3d xaxis = (pt - plane.Origin); double length = xaxis.Length; if (length >= Rhino.RhinoMath.ZeroTolerance) { Rhino.Geometry.Vector3d yaxis; yaxis = 0 != xaxis.IsParallelTo(plane.Normal) ? plane.YAxis : Rhino.Geometry.Vector3d.CrossProduct(plane.Normal, xaxis); plane = new Rhino.Geometry.Plane(plane.Origin, xaxis, yaxis); if (!plane.IsValid) { return(rc); } Rhino.Geometry.Transform rotate_xform = Rhino.Geometry.Transform.PlaneToPlane(Rhino.Geometry.Plane.WorldXY, plane); Rhino.Geometry.Transform scale_xform = Rhino.Geometry.Transform.Scale(plane, length, length, length); xform = scale_xform * rotate_xform; rc = xform.IsValid; if (rc) { m_length = length; } } } return(rc); }
public override Transform CalculateTransform(Rhino.Display.RhinoViewport viewport, Point3d point) { Point3d basePoint; if (!TryGetBasePoint(out basePoint)) { return(Transform.Identity); } double len2 = (point - basePoint).Length; double len1 = (RefPoint - basePoint).Length; if (Math.Abs(len1) < 0.000001 || Math.Abs(len2) < 0.000001) { return(Transform.Identity); } Scale = len2 / len1; Plane plane = viewport.ConstructionPlane(); plane.Origin = basePoint; return(Transform.Scale(plane, Scale, Scale, Scale)); }