/// <summary>
 /// Initializes a new instance of <see cref="Spline"/> class.
 /// </summary>
 /// <param name="controlPoints">Optional Bezier control points for first curve segment.</param>
 /// <param name="maximumDegree">Maximum degree of all Bezier curve segments for this spline.
 /// If new curve segments' degree exceeds this maximum, they will be split up and form separate curve segments.</param>
 /// <param name="minimumDegree">Minimum degree of all Bezier curve segments for this spline.
 /// If new curve segments' degree fall below this minimum, additional control points will be added between last two points.</param>
 public Spline(Vector3[] controlPoints = null, int maximumDegree = 4, int minimumDegree = 4, int NSamplesPerControlPoint = 20)
 {
     nControlPoints               = 0;
     nCurveSegments               = 0;
     curveSegments                = new List <BezierCurveSegment>();
     this.maximumDegree           = maximumDegree;
     this.minimumDegree           = minimumDegree;
     this.NSamplesPerControlPoint = NSamplesPerControlPoint;
     if (controlPoints != null)
     {
         this.AddSegment(controlPoints);
         this.rotationMinimizingFrames = new RotationMinimizingFrames(NSamplesToUse, this.GetPointOnSpline, this.GetTangentToPointOnSpline);
     }
     DefaultGetNormalAtT = this.GetMinimallyRotatingNormalToPointOnSpline;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Return the cumulative distribution function (CDF)
        /// for normal standard distribution with mean 0, standard
        /// deviation 1 and Z has a value less than z
        /// </summary>
        /// <param name="z">
        /// double. z is standard value where Z ~ N(0, 1)
        /// </param>
        /// <returns>
        /// The cumulative distribution function for normal
        /// standard distribution has a value less then z
        /// </returns>
        public static double CDF(double z)
        {
            // The CDF value for z < -10 --> 0
            if (z < -10.0)
            {
                return(double.Epsilon);
            }
            // The CDF value for z > 10 --> 1
            if (z > 10.0)
            {
                return(1.0 - double.Epsilon);
            }
            NormalFunction function = new NormalFunction(0.0, 1.0);

            // accuracy of the integration method is 1.0e-6
            if (z < 0)
            {
                return(0.5 - Integrator.GaussLegendre(function, z, 0, 1.0e-6));
            }
            else
            {
                return(0.5 + Integrator.GaussLegendre(function, 0, z, 1.0e-6));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This function return the value of probability density
        /// function(PDF) for normal standard distribution with Z=z
        /// and Z ~ N(0,1)
        /// </summary>
        /// <param name="z">double. z is standard value</param>
        /// <returns>
        /// The value of probability density function (PDF) for x
        /// where Z ~ N(0, 1)
        /// </returns>
        public static double PDF(double z)
        {
            NormalFunction function = new NormalFunction();

            return(function.Value(z));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This function return the value of probability density
        /// function(PDF) for normal distribution with X=x, mean mu,
        /// and standard deviation sig.
        /// </summary>
        /// <param name="x">double. x is observing data</param>
        /// <param name="mu">double. mu is mean of data</param>
        /// <param name="sig">double. sig is standard deviation data</param>
        /// <returns>
        /// The value of probability density function (PDF) for x
        /// where X ~ N(mu, sig)
        /// </returns>
        public static double PDF(double x, double mu, double sig)
        {
            NormalFunction function = new NormalFunction(mu, sig);

            return(function.Value(x));
        }