public static IBody2 CreateBodyFromCylTs(this IModeler modeler, Vector3  xyz, Vector3 axis, double radius, double length)
        {
            var array = xyz
                .ToDoubles()
                .Concat(axis.ToDoubles())
                .Concat(new[] {radius, length})
                .ToArray();

            return (IBody2)modeler.CreateBodyFromCyl(array);
        }
        public static ICurve CreateTrimmedArc
            (this IModeler modeler, Vector3 center, Vector3 axis, Vector3 startPoint, Vector3 endPoint)
        {
            var radius = (startPoint - center).Length();
            var arc =
                (Curve)
                    modeler.CreateArc
                        (center.ToDoubles(), axis.ToDoubles(), (double) radius, startPoint.ToDoubles(), endPoint.ToDoubles());

            var pp0 = arc.GetClosestPointOn(startPoint.X, startPoint.Y, startPoint.Z).CastArray<double>();
            var pp1 = arc.GetClosestPointOn(endPoint.X, endPoint.Y, endPoint.Z).CastArray<double>();

            return arc.CreateTrimmedCurve(pp0[3], pp1[3]);

        }
 public static IBody2 CreateCone
     (this IModeler m, Vector3 center, Vector3 axis, double baseRadius, double topRadius, double height)
 {
     var array = center.ToDoubles().Concat(axis.ToDoubles()).Concat(new[] {baseRadius, topRadius, height}).ToArray();
     return (IBody2) m.CreateBodyFromCone(array);
 }
 public static IBody2 CreateBox
     (this IModeler modeler
     , Vector3 center 
     , Vector3 axis
     , double width
     , double length
     , double height
     )
 {
     var array = new List<double>();
     array.AddRange(center.ToDoubles());
     array.AddRange(axis.ToDoubles());
     array.Add(width);
     array.Add(length);
     array.Add(height);
     return modeler.CreateBodyFromBox3(array.ToArray());
 }
        public static IBody2 CreateSphereBody(this IModeler modeler, Vector3 center, double radius)
        {
            var axis = Vector3.UnitZ;
            var refaxis = Vector3.UnitY;
            var sphere = (ISurface)modeler.CreateSphericalSurface2(center.ToDoubles(), axis.ToDoubles(), refaxis.ToDoubles(), radius);

            var swSurfPara = sphere.Parameterization2();

            var uvrange = new double[]
            {
                swSurfPara.UMin,
                swSurfPara.UMax,
                swSurfPara.VMin,
                swSurfPara.VMax
            };


            var sphereBody = (IBody2) modeler.CreateSheetFromSurface(sphere, uvrange);
            return sphereBody;
        }
        /// <summary>
        /// Create a bounded sheet.
        /// </summary>
        /// <param name="modeler"></param>
        /// <param name="center">Center of the surface</param>
        /// <param name="vNormal">Direction of the surface</param>
        /// <param name="p0">Point to project onto surface to find UV bounds</param>
        /// <param name="p1">Point to project onto surface to find UV bounds</param>
        /// <returns></returns>
        public static IBody2 CreateSheet(this IModeler modeler, Vector3 center, Vector3 vNormal, double r)
        {
            var surf = (Surface) modeler.CreatePlanarSurface(center.ToDoubles(), vNormal.ToDoubles());
            var mid = surf.GetClosestPointOnTs(center);
            var midPoint = mid.Point.ToVector3();
            var upVector = (surf.PointAt(mid.U, mid.V + 1) - midPoint).Unit();
            var rightVector = (surf.PointAt(mid.U + 1, mid.V) - midPoint).Unit();


            var low = midPoint - upVector*r - rightVector*r;
            var high = midPoint + upVector*r + rightVector*r;

            var uvLow = surf.GetClosestPointOnTs(low);
            var uvHigh = surf.GetClosestPointOnTs(high);
            return modeler.CreateSheetFromSurface(surf, uvLow, uvHigh);
        }