Пример #1
0
        private void GenerateDataByte()
        {
            if (InterpolationSpline == null)
            {
                InterpolationSpline = Interpolation.CreateRational(new double[] { 0, 0.5, 1 }, new double[] { 1, FallOff, 0 });
            }
            mDataByte = new byte[Width * Height];
            PointF midPoint = new PointF(Width / 2.0f, Height / 2.0f);

            for (uint i = 0; i < Width; ++i)
            {
                for (uint j = 0; j < Height; ++j)
                {
                    byte   value  = 0;
                    PointF curPos = new PointF(i, j);

                    double distance = Math.Sqrt(Math.Pow(curPos.X - midPoint.X, 2) + Math.Pow(curPos.Y - midPoint.Y, 2));
                    if (distance < InnerRadius)
                    {
                        double coeff = InterpolationSpline.Interpolate(distance / InnerRadius);
                        if (coeff < 0)
                        {
                            coeff = 0;
                        }

                        int curValue = (int)(mRandom.Next(0, 255) * coeff);

                        value = (byte)curValue;
                    }

                    mDataByte[j * Height + i] = value;
                }
            }
        }
Пример #2
0
        public void SplineTest()
        {
            Vector2[] points = new Vector2[] { new NumMath.Vector2(-1, -1),
                                               new NumMath.Vector2(-0.75, -0.5625),
                                               new NumMath.Vector2(-0.5, -0.25),
                                               new NumMath.Vector2(-0.25, -0.0625) };

            InterpolationSpline s = new InterpolationSpline();

            s.CreateSpline(points);
        }