Example #1
0
        public static string EdgeSphereSweep( Vector3D[] points, Func<Vector3D,Sphere> sphereFunc, Vector3D color = new Vector3D() )
        {
            if( points.Length < 2 )
                throw new System.ArgumentException();

            // For the cubic spline, repeat the first and last points.
            List<Vector3D> appended = new List<Vector3D>();
            appended.Add( points.First() );
            appended.AddRange( points );
            appended.Add( points.Last() );

            Func<Vector3D,string> formatVecAndSize = v =>
            {
                Sphere s = sphereFunc( v );
                return string.Format( "<{0:G6},{1:G6},{2:G6}>,{3:G6}", s.Center.X, s.Center.Y, s.Center.Z, s.Radius );
            };

            // b_spline seems best overall http://bugs.povray.org/task/81
            // options: b_spline, linear_spline, cubic_spline

            string formattedPoints = string.Join( ",", appended.Select( formatVecAndSize ).ToArray() );
            //return string.Format( "sphere_sweep {{ b_spline {0}, {1} texture {{tex}} }}", points.Length + 2, formattedPoints );
            //return string.Format( "sphere_sweep {{ linear_spline {0}, {1} texture {{tex}} }}", points.Length + 2, formattedPoints );

            // With color included.
            return string.Format( "sphere_sweep {{ b_spline {0}, {1} finish {{fin}} pigment {{color rgb {2}}} }}",
                points.Length + 2, formattedPoints, FormatVec( CHSL2RGB( color ) ) );
            //return string.Format( "sphere_sweep {{ b_spline {0}, {1} finish {{fin}} pigment {{color CHSL2RGB({2})}} }}",
            //	points.Length + 2, formattedPoints, FormatVec( color ) );
        }
Example #2
0
        public void AddCurve( Vector3D[] points, double[] radii )
        {
            if( points.Length < 2 )
                throw new System.ArgumentException( "AddCurve requires at least two input points." );

            List<Vector3D[]> disks = CalcDisks( points, radii );
            AddCurve( disks, points, points.First(), points.Last() );
        }
Example #3
0
 /// <summary>
 /// Add a curve with a constant radius size.
 /// </summary>
 public void AddCurve( Vector3D[] points, double size )
 {
     System.Func<Vector3D, double> sizeFunc = vector => size;
     AddCurve( points, sizeFunc, points.First(), points.Last() );
 }