Exemple #1
0
 /// <summary>
 /// Default constructor, just initializes the data storage.
 /// </summary>
 private CPointFunction2D()
 {
     this.values            = new Matrix();
     this.coordinatesX      = new Vector();
     this.coordinatesY      = new Vector();
     this.interpolationType = EInterpolationType.LINEAR;
     this.extrapolationType = ExtrapolationType.CONSTANT;
 }
 /// <summary>
 /// Initializes the object based on the serialized data.
 /// </summary>
 /// <param name="info">The SerializationInfo that holds the serialized object data.</param>
 /// <param name="context">The StreamingContext that contains contextual
 /// information about the source.</param>
 public PFunction2D(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.coordinatesX             = (IRightValue[])ObjectSerialization.GetValue2(info, "_coordinatesX", typeof(IRightValue[]));
     this.coordinatesY             = (IRightValue[])ObjectSerialization.GetValue2(info, "_coordinatesY", typeof(IRightValue[]));
     this.values                   = (IRightValue[, ])ObjectSerialization.GetValue2(info, "_Values", typeof(IRightValue[, ]));
     this.interpolationType        = (EInterpolationType)ObjectSerialization.GetValue2(info, "_InterpolationType", typeof(EInterpolationType));
     this.extrapolationType        = (ExtrapolationType)ObjectSerialization.GetValue2(info, "_ExtrapolationType", typeof(ExtrapolationType));
     this.leastSquaresCoefficients = (int)ObjectSerialization.GetValue2(info, "_LeastSquaresCoefficients", typeof(int));
 }
        /// <summary>
        /// Basic constructor to make a new object of type, in a similar
        /// means to other functions.
        /// </summary>
        /// <param name="context">The project this function is created in, if available.</param>
        public PFunction2D(Project context)
            : base(EModelParameterType.POINT_FUNCTION, context)
        {
            // Set some default values.
            this.interpolationType        = EInterpolationType.LINEAR;
            this.extrapolationType        = ExtrapolationType.CONSTANT;
            this.leastSquaresCoefficients = 2;

            // We make a function with coordinates 0 1 and all values to 0 by default.
            FillWithDefaultData();
        }
Exemple #4
0
        /// <summary>
        /// Constructs a new CPointFunction2D through evaluation of IRightValues
        /// in order to fill the data used to evaluate the function.
        /// </summary>
        /// <param name="coordinatesX">
        /// An array of <see cref="IRightValue"/> whose result is ordered from
        /// lower to greater and will represent the x parameter of the function.
        /// </param>
        /// <param name="coordinatesY">
        /// An array of <see cref="IRightValue"/> whose result is ordered from
        /// lower to greater and will represent the y parameter of the function.
        /// </param>
        /// <param name="values">
        /// A bi-dimensional array containing the defined data points for
        /// all the coordinates specified by coordinatesX and coordinatesY.
        /// </param>
        /// <param name="interpolationType">
        /// The interpolation to apply when evaluating the function
        /// in case the requested coordinates aren't represented, but inside them.
        /// </param>
        /// <param name="extrapolationType">
        /// The extrapolation to apply when evaluating the function,
        /// in case the requested coordinates are outside the represented ones.
        /// </param>
        public CPointFunction2D(IRightValue[] coordinatesX,
                                IRightValue[] coordinatesY,
                                IRightValue[,] values,
                                EInterpolationType interpolationType,
                                ExtrapolationType extrapolationType)
            : this()
        {
            this.interpolationType = interpolationType;
            this.extrapolationType = extrapolationType;

            // Check if the interpolation and extrapolation methods are available.
            if (extrapolationType == ExtrapolationType.USEMODEL &&
                interpolationType != EInterpolationType.LEAST_SQUARES)
            {
                throw new Exception("Use model extrapolation method is " +
                                    "supported only for Least Squares");
            }

            // Sets the sizes depending on the passed arrays length.
            SetSizes(coordinatesX.Length, coordinatesY.Length);

            // First copy the parsed elements for the x coordinates.
            for (int i = coordinatesX.Length - 1; i >= 0; i--)
            {
                this[i, -1] = coordinatesX[i].V();
            }

            // Then copy the parsed elements for the y coordinates.
            for (int i = coordinatesY.Length - 1; i >= 0; i--)
            {
                this[-1, i] = coordinatesY[i].V();
            }

            // Finally populate the values matrix with the provided data.
            for (int x = 0; x < values.GetLength(0); x++)
            {
                for (int y = 0; y < values.GetLength(1); y++)
                {
                    this[x, y] = values[x, y].V();
                }
            }

            UpdateModel();
        }
        /// <summary>
        /// Constructs a new CPointFunction2D through evaluation of IRightValues
        /// in order to fill the data used to evaluate the function.
        /// </summary>
        /// <param name="coordinatesX">
        /// An array of <see cref="IRightValue"/> whose result is ordered from
        /// lower to greater and will represent the x parameter of the function.
        /// </param>
        /// <param name="coordinatesY">
        /// An array of <see cref="IRightValue"/> whose result is ordered from
        /// lower to greater and will represent the y parameter of the function.
        /// </param>
        /// <param name="values">
        /// A bi-dimensional array containing the defined data points for
        /// all the coordinates specified by coordinatesX and coordinatesY.
        /// </param>
        /// <param name="interpolationType">
        /// The interpolation to apply when evaluating the function
        /// in case the requested coordinates aren't represented, but inside them.
        /// </param>
        /// <param name="extrapolationType">
        /// The extrapolation to apply when evaluating the function,
        /// in case the requested coordinates are outside the represented ones.
        /// </param>
        public CPointFunction2D(IRightValue[] coordinatesX,
                                IRightValue[] coordinatesY,
                                IRightValue[,] values,
                                EInterpolationType interpolationType,
                                ExtrapolationType extrapolationType)
            : this()
        {
            this.interpolationType = interpolationType;
            this.extrapolationType = extrapolationType;

            // Check if the interpolation and extrapolation methods are available.
            if (extrapolationType == ExtrapolationType.USEMODEL &&
               interpolationType != EInterpolationType.LEAST_SQUARES)
            {
                throw new Exception("Use model extrapolation method is " +
                                    "supported only for Least Squares");
            }

            // Sets the sizes depending on the passed arrays length.
            SetSizes(coordinatesX.Length, coordinatesY.Length);

            // First copy the parsed elements for the x coordinates.
            for (int i = coordinatesX.Length - 1; i >= 0; i--)
            {
                this[i, -1] = coordinatesX[i].V();
            }

            // Then copy the parsed elements for the y coordinates.
            for (int i = coordinatesY.Length - 1; i >= 0; i--)
            {
                this[-1, i] = coordinatesY[i].V();
            }

            // Finally populate the values matrix with the provided data.
            for (int x = 0; x < values.GetLength(0); x++)
            {
                for (int y = 0; y < values.GetLength(1); y++)
                {
                    this[x, y] = values[x, y].V();
                }
            }

            UpdateModel();
        }
 /// <summary>
 /// Default constructor, just initializes the data storage.
 /// </summary>
 private CPointFunction2D()
 {
     this.values = new Matrix();
     this.coordinatesX = new Vector();
     this.coordinatesY = new Vector();
     this.interpolationType = EInterpolationType.LINEAR;
     this.extrapolationType = ExtrapolationType.CONSTANT;
 }
        /// <summary>
        /// Constructs a new CPointFunction2D through evaluation of IRightValues
        /// in order to fill the data used to evaluate the function.
        /// </summary>
        /// <param name="cordinatesX">
        /// An array of IRightValue whose result is ordered from lower to greater and will
        /// represent the x parameter of the function.
        /// </param>
        /// <param name="cordinatesY">
        /// An array of IRightValue whose result is ordered from lower to greater and will
        /// represent the y parameter of the function.
        /// </param>
        /// <param name="values">
        /// A bi-dimensional array containing the defined data points for
        /// all the coordinates specified by cordinatesX and cordinatesY.
        /// </param>
        /// <param name="interpolationType">
        /// The interpolation to apply when evaluating the function
        /// in case the requested coordinates aren't represented, but inside them.
        /// </param>
        /// <param name="extrapolationType">
        /// The extrapolation to apply when evaluating the function,
        /// in case the requested coordinates are outside the represented ones.
        /// </param>
        public CPointFunction2D(IRightValue[] cordinatesX,
                                IRightValue[] cordinatesY,
                                IRightValue[,] values,
                                EInterpolationType interpolationType,
                                ExtrapolationType extrapolationType)
            : this()
        {
            this.interpolationType = interpolationType;
            this.extrapolationType = extrapolationType;

            // Sets the sizes depending on the passed arrays length.
            SetSizes(cordinatesX.Length, cordinatesY.Length);

            // First copy the parsed elements for the x coordinates.
            for (int i = cordinatesX.Length - 1; i >= 0; i--)
            {
                this[i, -1] = cordinatesX[i].V();
            }

            // Then copy the parsed elements for the y coordinates.
            for (int i = cordinatesY.Length - 1; i >= 0; i--)
            {
                this[-1, i] = cordinatesY[i].V();
            }

            // Finally populate the values matrix with the provided data.
            for (int x = 0; x < values.GetLength(0); x++)
            {
                for (int y = 0; y < values.GetLength(1); y++)
                {
                    this[x, y] = values[x, y].V();
                }
            }
        }
Exemple #8
0
 /// <summary>
 /// Initializes the object based on the serialized data.
 /// </summary>
 /// <param name="info">The SerializationInfo that holds the serialized object data.</param>
 /// <param name="context">The StreamingContext that contains contextual
 /// information about the source.</param>
 public PFunction2D(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this.coordinatesX = (IRightValue[])ObjectSerialization.GetValue2(info, "_coordinatesX", typeof(IRightValue[]));
     this.coordinatesY = (IRightValue[])ObjectSerialization.GetValue2(info, "_coordinatesY", typeof(IRightValue[]));
     this.values = (IRightValue[,])ObjectSerialization.GetValue2(info, "_Values", typeof(IRightValue[,]));
     this.interpolationType = (EInterpolationType)ObjectSerialization.GetValue2(info, "_InterpolationType", typeof(EInterpolationType));
     this.extrapolationType = (ExtrapolationType)ObjectSerialization.GetValue2(info, "_ExtrapolationType", typeof(ExtrapolationType));
     this.leastSquaresCoefficients = (int)ObjectSerialization.GetValue2(info, "_LeastSquaresCoefficients", typeof(int));
 }
Exemple #9
0
        /// <summary>
        /// Basic constructor to make a new object of type, in a similar
        /// means to other functions.
        /// </summary>
        /// <param name="context">The project this function is created in, if available.</param>
        public PFunction2D(Project context)
            : base(EModelParameterType.POINT_FUNCTION, context)
        {
            // Set some default values.
            this.interpolationType = EInterpolationType.LINEAR;
            this.extrapolationType = ExtrapolationType.CONSTANT;
            this.leastSquaresCoefficients = 2;

            // We make a function with coordinates 0 1 and all values to 0 by default.
            FillWithDefaultData();
        }
Exemple #10
0
    private IEnumerator AnchoredPositionToCoroutine(RectTransform rectTransform, Vector3 anchoredPosition, float duration, float delay, EInterpolationType interpolation)
    {
        Vector3 startAnchoredPosition = rectTransform.anchoredPosition;

        AnimationCurve animationCurve = curves[(int)interpolation];

        for (float t = 0; t < duration; t += Time.deltaTime)
        {
            float nt = t / duration;
            rectTransform.anchoredPosition = Vector3.LerpUnclamped(startAnchoredPosition, anchoredPosition, animationCurve.Evaluate(nt));
            yield return(null);
        }

        rectTransform.anchoredPosition = anchoredPosition;
    }
 public CurveDto(IEnumerable <Tuple <double, object> > points, EInterpolationType type)
 {
     Points = points;
     Type   = type;
 }
Exemple #12
0
 /// <summary>
 /// Animates the anchored position of a rect transform to the destination value
 /// </summary>
 /// <param name="rectTransform"></param>
 /// <param name="anchoredPosition"></param>
 /// <param name="duration"></param>
 /// <param name="delay"></param>
 static public void AnchoredPositionTo(RectTransform rectTransform, Vector3 anchoredPosition, float duration, float delay, EInterpolationType interpolation)
 {
     Instance.StartCoroutine(Instance.AnchoredPositionToCoroutine(rectTransform, anchoredPosition, duration, delay, interpolation));
 }
Exemple #13
0
    private IEnumerator ScaleToCoroutine(Transform transform, Vector3 scale, float duration, float delay, EInterpolationType interpolation)
    {
        Vector3 startLocalScale = transform.localScale;

        AnimationCurve animationCurve = curves[(int)interpolation];

        for (float t = 0; t < duration; t += Time.deltaTime)
        {
            float nt = t / duration;
            transform.localScale = Vector3.LerpUnclamped(startLocalScale, scale, animationCurve.Evaluate(nt));
            yield return(null);
        }

        transform.localScale = scale;
    }
Exemple #14
0
 /// <summary>
 /// Animates the sacale of a transform to the destination value
 /// </summary>
 /// <param name="transform"></param>
 /// <param name="scale"></param>
 /// <param name="duration"></param>
 /// <param name="delay"></param>
 static public void ScaleTo(Transform transform, Vector3 scale, float duration, float delay, EInterpolationType interpolation)
 {
     Instance.StartCoroutine(Instance.ScaleToCoroutine(transform, scale, duration, delay, interpolation));
 }
Exemple #15
0
    private IEnumerator RotateToCoroutine(Transform transform, Vector3 eulerAngles, float duration, float delay, EInterpolationType interpolation)
    {
        Vector3 startEulerAngles = transform.localEulerAngles;

        AnimationCurve animationCurve = curves[(int)interpolation];

        for (float t = 0; t < duration; t += Time.deltaTime)
        {
            float nt = t / duration;
            transform.localEulerAngles = Vector3.Slerp(startEulerAngles, eulerAngles, animationCurve.Evaluate(nt));
            yield return(null);
        }

        transform.localEulerAngles = eulerAngles;
    }
Exemple #16
0
 /// <summary>
 /// Animates the rotation of a transform to the destination value
 /// </summary>
 /// <param name="transform"></param>
 /// <param name="eulerAngles"></param>
 /// <param name="duration"></param>
 /// <param name="delay"></param>
 static public void RotateTo(Transform transform, Vector3 eulerAngles, float duration, float delay, EInterpolationType interpolation)
 {
     Instance.StartCoroutine(Instance.RotateToCoroutine(transform, eulerAngles, duration, delay, interpolation));
 }