public static Dictionary <string, object> CurveSinusoidalPoints(
            Autodesk.DesignScript.Geometry.Curve _Curve,
            double WaveLength = 5.0,
            double Amplitude  = 1.0,
            double Resolution = 2.0)
        {
            double n     = (_Curve.Length / WaveLength) * 4 * Resolution;
            double _Span = _Curve.Length / n;
            List <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>();
            List <double> ks = new List <double>();

            for (int i = 0; i < n; i++)
            {
                double k = Amplitude * Math.Sin(i * _Span * Math.PI * 2 / WaveLength + Math.PI * 2);
                Autodesk.DesignScript.Geometry.Plane pl = _Curve.PlaneAtParameter(_Curve.ParameterAtSegmentLength(i * _Span));
                Autodesk.DesignScript.Geometry.Point p  = _Curve.PointAtSegmentLength(i * _Span);
                points.Add((Autodesk.DesignScript.Geometry.Point)p.Translate(pl.YAxis, k));
                ks.Add(k);
            }

            return(new Dictionary <string, object>
            {
                { "Points", points },
                { "k", ks }
            });
        }
        public static Dictionary <string, object> CurveSinusoidalPointsWithVoxel(
            Autodesk.DesignScript.Geometry.Curve _Curve,
            VoxelImage Voxel,
            double WaveLength = 5.0,
            double Amplitude  = 1.0,
            double Resolution = 2.0)
        {
            VoxelChannel _VoxelChannel = Voxel.GetChannel(VoxelImageLayout.SHAPECHANNEL);

            double n     = (_Curve.Length / WaveLength) * 4 * Resolution;
            double _Span = _Curve.Length / n;
            List <Autodesk.DesignScript.Geometry.Point> points = new List <Autodesk.DesignScript.Geometry.Point>();
            List <double> ks = new List <double>();

            for (int i = 0; i < n; i++)
            {
                Autodesk.DesignScript.Geometry.Plane pl = _Curve.PlaneAtParameter(_Curve.ParameterAtSegmentLength(i * _Span));
                Autodesk.DesignScript.Geometry.Point p  = _Curve.PointAtSegmentLength(i * _Span);
                double FieldValue = V2GVoxel.GetVoxelFieldValue(_VoxelChannel, p.X, p.Y, p.Z);

                double k = FieldValue * Amplitude * Math.Sin(i * _Span * Math.PI * 2 / WaveLength + Math.PI * 2);

                points.Add((Autodesk.DesignScript.Geometry.Point)p.Translate(pl.YAxis, k));
                ks.Add(k);
            }

            return(new Dictionary <string, object>
            {
                { "Points", points },
                { "k", ks }
            });
        }
Beispiel #3
0
        /// <summary>
        /// Constructors a plane at a point on the curve by given paramater and 
        /// use the tangent at the point as Normal of the plane
        /// </summary>
        /// <param name="contextCurve"></param>
        /// <param name="t"></param>
        /// <returns></returns>
        public static Plane AtParameter(Curve contextCurve, double t)
        {
            if (null == contextCurve)
                throw new ArgumentNullException("contextCurve");

            return contextCurve.PlaneAtParameter(t);
        }