예제 #1
0
 private void Init()
 {
     if (m_Hermite == null)
     {
         m_Hermite = new Hermite();
     }
 }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            try
            {
                var data = new Fraction[this.DataGrid.RowDefinitions.Count, this.DataGrid.ColumnDefinitions.Count - 1];
                foreach (var box in this.DataGrid.Children)
                {
                    var tbox = box as TextBox;
                    if (tbox == null)
                    {
                        continue;
                    }
                    var column = Grid.GetColumn(tbox) - 1;
                    var row    = Grid.GetRow(tbox);
                    data[row, column] = new Fraction {
                        Counter = int.Parse(tbox.Text), Denominator = 1
                    };
                }

                var hermite = new Hermite(data);
                this.polynominal                 = hermite.Calculate();
                this.Polynominal.Content         = this.polynominal.PolynominalToString();
                this.PolynominalStack.Visibility = Visibility.Visible;
                this.IntegralStack.Visibility    = Visibility.Visible;
            }
            catch
            {
            }
        }
예제 #3
0
    // Update is called once per frame
    private void Update()
    {
        float stepLength = 1.0f / Segments;
        float step;

        _animCounter += Time.deltaTime;
        // Animate the tangents to move around in cycles
        TangentOne.Translate(Mathf.Cos(_animCounter) * 0.1f, Mathf.Sin(_animCounter) * 0.05f, -Mathf.Sin(_animCounter) * 0.1f, Space.Self);
        TangentTwo.Translate(Mathf.Sin(_animCounter) * 0.1f, Mathf.Cos(_animCounter) * 0.03f, Mathf.Cos(_animCounter) * 0.1f, Space.Self);
        // Build the line segments of the curve
        for (var i = 0; i < Segments; i++)
        {
            step = i * stepLength;
            // Use the Hermite class to get the start and end points of the current segment
            var prevPosition = Hermite.GetVector3AtStep(StartPosition.position, EndPosition.position,
                                                        (TangentOne.position - StartPosition.position) * TangentOneWeight,
                                                        -(TangentTwo.position - EndPosition.position) * TangentTwoWeight,
                                                        step);
            var nextPosition = Hermite.GetVector3AtStep(StartPosition.position, EndPosition.position,
                                                        (TangentOne.position - StartPosition.position) * TangentTwoWeight,
                                                        -(TangentTwo.position - EndPosition.position) * TangentTwoWeight,
                                                        step + stepLength);
            // Move the segment to the starting point
            _lines[i].transform.position = prevPosition;
            // Rotate towards the endpoint
            _lines[i].transform.LookAt(nextPosition, Vector3.up);
            // Scale the cube to match length
            _lines[i].transform.localScale = new Vector3(0.2f, 0.2f, (prevPosition - nextPosition).magnitude);
        }
        // Debug Draw methods only show up when Editor is playing and paused
        Hermite.DrawVector3(StartPosition.position, EndPosition.position, TangentOne.position,
                            -TangentTwo.position, Segments);
        Debug.DrawLine(StartPosition.position, TangentOne.position, Color.cyan);
        Debug.DrawLine(EndPosition.position, TangentTwo.position, Color.magenta);
    }
    // Update is called once per frame
    private void Update()
    {
        float stepLength = 1.0f / Segments;
        float step;

        _animCounter += Time.deltaTime;
        // Animate the tangents to move around in cycles
        TangentOne.Translate(Mathf.Cos(_animCounter) * 0.1f, 0, 0, Space.Self);
        TangentTwo.Translate(Mathf.Sin(_animCounter) * 0.1f, 0, 0, Space.Self);
        // Turn GameObject positions into Vector2 objects
        _startPosition = new Vector2(StartPosition.position.x, StartPosition.position.y);
        _endPosition   = new Vector2(EndPosition.position.x, EndPosition.position.y);
        _tangentOne    = new Vector2(TangentOne.position.x, TangentOne.position.y);
        _tangentTwo    = new Vector2(TangentTwo.position.x, TangentTwo.position.y);
        // Build the line segments of the curve
        for (var i = 0; i < Segments; i++)
        {
            step = i * stepLength;
            var prevPosition = Hermite.GetVector2AtStep(_startPosition, _endPosition,
                                                        (_tangentOne - _startPosition) * TangentOneWeight,
                                                        -(_tangentTwo - _endPosition) * TangentTwoWeight,
                                                        step);
            var nextPosition = Hermite.GetVector2AtStep(_startPosition, _endPosition,
                                                        (_tangentOne - _startPosition) * TangentTwoWeight,
                                                        -(_tangentTwo - _endPosition) * TangentTwoWeight,
                                                        step + stepLength);
            _lines[i].transform.position = new Vector3(prevPosition.x, prevPosition.y, 0);
            _lines[i].transform.LookAt(new Vector3(nextPosition.x, nextPosition.y, 0), Vector3.up);
            _lines[i].transform.localScale = new Vector3(0.2f, 0.2f, (prevPosition - nextPosition).magnitude);
        }
        // Debug Draw methods only show up when Editor is playing and paused
        Hermite.DrawVector2(_startPosition, _endPosition, (_tangentOne - _startPosition), -(_tangentTwo - _endPosition), Segments);
        Debug.DrawLine(_startPosition, _tangentOne, Color.cyan);
        Debug.DrawLine(_endPosition, _tangentTwo, Color.magenta);
    }
예제 #5
0
    public bool GetPointByLenght(ref Vector3 point, ref Vector3 direction, float len)
    {
        int count = curveLenght.Length;

        for (int i = 1; i < count;)
        {
            float curLen = curveLenght[i];
            if (len < curLen)
            {
                float   progress = len / curLen;
                Vector3 p0, p1, p2, p3;
                p0 = p1 = p2 = p3 = Vector3.zero;
                GetCurvePoint(i, ref p0, ref p1, ref p2, ref p3);

                point = Hermite.GetPoint(p0, p1, p2, p3, progress, tension, bias);

                return(true);
            }
            else
            {
                len -= curLen;
            }

            ++i;
            if (i >= count)
            {
                i = 1;
            }
        }

        return(false);
    }
예제 #6
0
 void Start()
 {
     xH = new Hermite(1, 1);
     yH = new Hermite(1, 1);
     zH = new Hermite(1, 1);
     lineRender.positionCount = count;
 }
예제 #7
0
    public static void gen_hermite_poly_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    GEN_HERMITE_POLY_TEST tests GEN_HERMITE_POLY.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    10 February 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N      = 10;
        const int N_TEST = 6;

        double[] c = new double[N + 1];
        int      i;

        double[] mu_test = { 0.0, 0.0, 0.1, 0.1, 0.5, 1.0 };
        double[] x_test  = { 0.0, 1.0, 0.0, 0.5, 0.5, 0.5 };

        Console.WriteLine("");
        Console.WriteLine("GEN_HERMITE_POLY_TEST");
        Console.WriteLine("  GEN_HERMITE_POLY evaluates the generalized Hermite");
        Console.WriteLine("  polynomial.");

        for (i = 0; i < N_TEST; i++)
        {
            double x  = x_test[i];
            double mu = mu_test[i];

            Console.WriteLine("");
            Console.WriteLine("  Table of H(N,MU)(X) for");
            Console.WriteLine("");
            Console.WriteLine("    N(max) = " + N + "");
            Console.WriteLine("    MU =     " + mu + "");
            Console.WriteLine("    X =      " + x + "");
            Console.WriteLine("");

            Hermite.gen_hermite_poly(N, x, mu, ref c);

            int j;
            for (j = 0; j <= N; j++)
            {
                Console.WriteLine("  "
                                  + j.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                                  + c[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
            }
        }
    }
예제 #8
0
    public static void hermite_poly_phys_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLY_PHYS_TEST tests HERMITE_POLY_PHYS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    23 May 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N_MAX = 12;

        double fx = 0;

        double[] fx2    = new double[N_MAX + 1];
        int      n      = 0;
        int      n_data = 0;
        double   x      = 0;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLY_PHYS_TEST:");
        Console.WriteLine("  HERMITE_POLY_PHYS evaluates the physicist's Hermite polynomial.");
        Console.WriteLine("");
        Console.WriteLine("     N      X        Exact F       H(N)(X)");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Burkardt.Values.Hermite.hermite_poly_phys_values(ref n_data, ref n, ref x, ref fx);

            if (n_data == 0)
            {
                break;
            }

            Hermite.hermite_poly_phys(n, x, ref fx2);

            Console.WriteLine("  "
                              + n.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(14) + "  "
                              + fx2[n].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
        }
    }
예제 #9
0
    private static void hpp_test015()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST015 tests HEP_COEFFICIENTS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int[]    e;
        int[]    f;
        int[]    l = new int[1];
        int      m;
        int      n;
        int      o;
        int      o_max;
        string   title;

        m = 1;

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST015:");
        Console.WriteLine("  HEP_COEFFICIENTS computes the coefficients and");
        Console.WriteLine("  exponents of the Hermite polynomial He(n,x).");

        for (n = 1; n <= 5; n++)
        {
            o = (n + 2) / 2;
            c = new double[o];
            e = new int[o];
            f = new int[o];

            Hermite.hep_coefficients(n, ref o, ref c, ref f);

            l[0]  = n;
            o_max = o;

            Hermite.hepp_to_polynomial(m, l, o_max, o, ref c, ref e);

            Console.WriteLine("");
            title = "  He(" + n + ",x) =";
            Polynomial.polynomial_print(m, o, c, e, title);
        }
    }
예제 #10
0
    public static void hermite_poly_phys_coef_test()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLY_PHYS_COEF_TEST tests HERMITE_POLY_PHYS_COEF.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    02 June 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        const int N = 5;

        double[] c = new double[(N + 1) * (N + 1)];
        int      i;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLY_PHYS_COEF_TEST");
        Console.WriteLine("  HERMITE_POLY_PHYS_COEF: physicist's Hermite polynomial coefficients.");

        Hermite.hermite_poly_phys_coef(N, ref c);

        for (i = 0; i <= N; i++)
        {
            Console.WriteLine("");
            Console.WriteLine("  H(" + i + ")");
            Console.WriteLine("");
            int j;
            for (j = i; 0 <= j; j--)
            {
                switch (j)
                {
                case 0:
                    Console.WriteLine(c[i + j * (N + 1)].ToString(CultureInfo.InvariantCulture).PadLeft(14) + "");
                    break;

                case 1:
                    Console.WriteLine(c[i + j * (N + 1)].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " * x");
                    break;

                default:
                    Console.WriteLine(c[i + j * (N + 1)].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " * x^" + j + "");
                    break;
                }
            }
        }
    }
예제 #11
0
    private float CalcCurveLenght(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3)
    {
        float       len       = 0;
        const float lineStep  = 1000;
        Vector3     lineStart = Hermite.GetPoint(p0, p1, p2, p3, 0, tension, bias);

        for (int i = 1; i <= lineStep; ++i)
        {
            Vector3 lineEnd = Hermite.GetPoint(p0, p1, p2, p3, i / (float)lineStep, tension, bias);
            len      += (lineEnd - lineStart).magnitude;
            lineStart = lineEnd;
        }
        return(len);
    }
예제 #12
0
    private void Awake()
    {
        if (m_Points.Count < 3 || m_InTangents.Count != m_Points.Count - 1 ||
            m_OutTangents.Count != m_Points.Count - 1)
        { // (re)initialize
            m_Points.Clear();
            m_InTangents.Clear();
            m_OutTangents.Clear();
            m_Times.Clear();

            AddNewPointInternal();
            LastPoint.position = transform.position;
            AddNewPointInternal();
            LastPoint.position = transform.position + Vector3.forward;                     // TODO: make own monobehaviour with cached
            AddNewPointInternal();
            LastPoint.position = transform.position + 2 * Vector3.forward + Vector3.right; // TODO: make own monobehaviour with cached

            m_Times.Add(0.0f);
            m_Times.Add(0.5f);
            m_Times.Add(1.0f);

            m_Hermite = new Hermite();
            m_Hermite.InitializeNatural(m_Points.Select(p => p.position).ToArray(), m_Times.ToArray(), m_Points.Count);

            AddNewIntagentInternal(1);
            AddNewIntagentInternal(2);
            AddNewOutTangentInternal(0);
            AddNewOutTangentInternal(1);

//            // create intangents
//            for (int i = 0; i < m_Hermite.InTangents.Count; i++)
//            {
//                var inTangent = new GameObject(m_Points[i+1].name + "_inTangent");
//                inTangent.transform.SetParent(m_Points[i+1].transform);
//                m_InTangents.Add(inTangent.transform);
//                inTangent.transform.position = m_Hermite.InTangents[i];
//            }
//
//            // create outtangents
//            for (int i = 0; i < m_Hermite.OutTangents.Count; i++)
//            {
//                var outTangent = new GameObject(m_Points[i].name + "_outTangent");
//                outTangent.transform.SetParent(m_Points[i].transform);
//                m_OutTangents.Add(outTangent.transform);
//                outTangent.transform.position = m_Hermite.OutTangents[i];
//            }
        }
    }
예제 #13
0
    public static void hermite_function_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_FUNCTION_VALUES_TEST tests HERMITE_FUNCTION_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    13 February 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double fx = 0;
        int    n  = 0;
        double x  = 0;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_FUNCTION_VALUES_TEST");
        Console.WriteLine("  HERMITE_FUNCTION_VALUES stores values of");
        Console.WriteLine("  the Hermite function.");
        Console.WriteLine("");
        Console.WriteLine("     N      X            Hf(N,X)");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Hermite.hermite_function_values(ref n_data, ref n, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + n.ToString(CultureInfo.InvariantCulture).PadLeft(6) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + fx.ToString("0.################").PadLeft(24) + "");
        }
    }
예제 #14
0
    private static void hermite_polynomial_test13(int p, int e)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLYNOMIAL_TEST13 tests HF_POWER_PRODUCT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    26 February 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int P, the maximum degree of the polynomial
    //    factors.
    //
    //    Input, int E, the exponent of X.
    //
    {
        double[] table;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLYNOMIAL_TEST13");
        Console.WriteLine("  Compute a Hermite function product table.");
        Console.WriteLine("");
        Console.WriteLine("  Tij = integral ( -oo < X < +oo ) X^E Hf(I,X) Hf(J,X) exp(-X*X) dx");
        Console.WriteLine("");
        Console.WriteLine("  where Hf(I,X) = Hermite function of \"degree\" I.");

        Console.WriteLine("");
        Console.WriteLine("  Maximum degree P = " + p + "");
        Console.WriteLine("  Exponent of X, E = " + e + "");

        table = Hermite.hf_power_product(p, e);

        typeMethods.r8mat_print(p + 1, p + 1, table, "  Power product table:");
    }
예제 #15
0
    private static void hermite_polynomial_test12(int p, double b)

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLYNOMIAL_TEST12 tests HF_EXPONENTIAL_PRODUCT.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    26 February 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, int P, the maximum degree of the polynomial
    //    factors.
    //
    //    Input, double B, the coefficient of X in the exponential factor.
    //
    {
        double[] table;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLYNOMIAL_TEST12");
        Console.WriteLine("  Compute a Hermite function exponential product table.");
        Console.WriteLine("");
        Console.WriteLine("  Tij = integral ( -oo < X < +oo ) exp(B*X) Hf(I,X) Hf(J,X) dx");
        Console.WriteLine("");
        Console.WriteLine("  where Hf(I,X) = Hermite function of \"degree\" I.");

        Console.WriteLine("");
        Console.WriteLine("  Maximum degree P = " + p + "");
        Console.WriteLine("  Exponential argument coefficient B = " + b + "");

        table = Hermite.hf_exponential_product(p, b);

        typeMethods.r8mat_print(p + 1, p + 1, table, "  Exponential product table:");
    }
예제 #16
0
    private static void hermite_polynomial_test05()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLYNOMIAL_TEST05 tests HE_POLYNOMIAL_ZEROS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    26 February 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int degree;

        double[] hz;
        string   title;

        double[] z;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLYNOMIAL_TEST05:");
        Console.WriteLine("  HE_POLYNOMIAL_ZEROS computes the zeros of He(n,x)");
        Console.WriteLine("  Check by calling HE_POLYNOMIAL there.");

        for (degree = 1; degree <= 5; degree++)
        {
            z     = Hermite.he_polynomial_zeros(degree);
            title = "  Computed zeros for He(" + degree + ",z):";
            typeMethods.r8vec_print(degree, z, title);

            hz    = Hermite.he_polynomial_value(degree, degree, z);
            title = "  Evaluate He(" + degree + ",z):";
            typeMethods.r8vec_print(degree, hz, title, aIndex: +degree * degree);
        }
    }
    public static float Evaluate(float time, Keyframe lhs, Keyframe rhs)
    {
        float dx = rhs.time - lhs.time;
        float m0;
        float m1;
        float t;

        if (dx != 0.0f)
        {
            t  = (time - lhs.time) / dx;
            m0 = lhs.outTangent * dx;
            m1 = rhs.inTangent * dx;
        }
        else
        {
            t  = 0.0f;
            m0 = 0;
            m1 = 0;
        }

        return(Hermite.Evaluate(t, lhs.value, m0, m1, rhs.value));
    }
예제 #18
0
    public Vector3 GetPoint(float t)
    {
        int i;

        if (t >= 1f)
        {
            t = 1f;
            i = splineControlPoints.Count - 2;
        }
        else
        {
            t  = Mathf.Clamp01(t) * CurveCount;
            i  = (int)t;
            t -= i;
        }

        return(Hermite.GetPoint(t,
                                splineControlPoints[i].Position,
                                splineControlPoints[i].Tangent,
                                splineControlPoints[i + 1].Position,
                                splineControlPoints[i + 1].Tangent));
    }
예제 #19
0
    void OnDrawGizmos()
    {
        if (points == null)
        {
            InitPoints();
        }

        if (points == null)
        {
            return;
        }

        int count = points.Length;

        if (count < 4)
        {
            return;
        }

        Vector3 p0, p1, p2, p3;

        p0           = p1 = p2 = p3 = Vector3.zero;
        Gizmos.color = new Color(1, 0, 0, 1);
        for (int i = 1; i < count; ++i)
        {
            GetCurvePoint(i, ref p0, ref p1, ref p2, ref p3);

            const float lineStep  = 100;
            Vector3     lineStart = Hermite.GetPoint(p0, p1, p2, p3, 0, tension, bias);
            for (int index = 1; index <= lineStep; ++index)
            {
                Vector3 lineEnd = Hermite.GetPoint(p0, p1, p2, p3, index / (float)lineStep, tension, bias);
                Gizmos.DrawLine(lineStart, lineEnd);
                lineStart = lineEnd;
            }
        }
    }
예제 #20
0
    private static void hermite_polynomial_test15()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLYNOMIAL_TEST15 tests HE_POLYNOMIAL_COEFFICIENTS.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 March 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int      i;
        int      j;
        int      n = 10;

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLYNOMIAL_TEST15");
        Console.WriteLine("  HE_POLYNOMIAL_COEFFICIENTS determines probabilist's Hermite polynomial coefficients.");

        c = Hermite.he_polynomial_coefficients(n);

        for (i = 0; i <= n; i++)
        {
            Console.WriteLine("");
            Console.WriteLine("  He(" + i + ") =");
            Console.WriteLine("");
            for (j = i; 0 <= j; j--)
            {
                switch (c[i + j * (n + 1)])
                {
                case 0.0:
                    break;

                default:
                    switch (j)
                    {
                    case 0:
                        Console.WriteLine(c[i + j * (n + 1)].ToString().PadLeft(14) + "");
                        ;
                        break;

                    case 1:
                        Console.WriteLine(c[i + j * (n + 1)].ToString().PadLeft(14) + " * x");
                        break;

                    default:
                        Console.WriteLine(c[i + j * (n + 1)].ToString().PadLeft(14) + " * x^" + j + "");
                        break;
                    }

                    break;
                }
            }
        }
    }
예제 #21
0
    private static void hpp_test04()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST04 tests HEPP_TO_POLYNOMIAL.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int[]    e;
        int      i;

        int[]  l;
        string label;
        int    m = 2;
        int    o = 0;
        int    o_max;
        int    rank;

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST04:");
        Console.WriteLine("  HEPP_TO_POLYNOMIAL is given a Hermite product polynomial");
        Console.WriteLine("  and determines its polynomial representation.");

        Console.WriteLine("");
        Console.WriteLine("  Using spatial dimension M = " + m + "");

        for (rank = 1; rank <= 11; rank++)
        {
            l = Comp.comp_unrank_grlex(m, rank);

            o_max = 1;
            for (i = 0; i < m; i++)
            {
                o_max = o_max * (l[i] + 2) / 2;
            }

            c = new double[o_max];
            e = new int[o_max];

            Hermite.hepp_to_polynomial(m, l, o_max, o, ref c, ref e);

            label = "  HePP #" + rank
                    + " = He(" + l[0]
                    + ",X)*He(" + l[1]
                    + ",Y) =";

            Console.WriteLine("");
            Polynomial.polynomial_print(m, o, c, e, label);
        }
    }
예제 #22
0
 protected override Vector3 Interpolate(HermiteKey lower, HermiteKey upper, float scale)
 {
     return(Hermite.Interpolate(lower.Value, lower.In, upper.Value, upper.Out, scale));
 }
예제 #23
0
    void Update()
    {
        switch (St)
        {
        case State.standbyMove:
            // 進行率を更新
            float befRatio = moveRatio;
            moveRatio = ((Time.time - actionBeginTime) / StandbyMoveTime);
            moveRatio = Mathf.Clamp(moveRatio, 0.0f, 1.0f);

            // 進行率から位置と向きを求める
            transform.position = Hermite.GetPoint(moveRatio);
            if (befRatio != moveRatio)
            {
                transform.rotation = Quaternion.LookRotation(Hermite.GetPoint(moveRatio) - Hermite.GetPoint(befRatio));
            }

            if (moveRatio >= 1.0f)
            {
                St = State.aim;

                // 待機モーション開始
                motion.StartAnimation(HumanMotion.AnimaList.Wait);

                ThrowStandby();
            }

            break;

        case State.aim:
            // ターゲットに向く
            transform.LookAt(targetPoint);

            if ((Time.time - actionBeginTime) >= aimTime)
            {
                St = State.actionBefore;

                // 的の移動を終了
                Destroy(targetPoint.GetComponent <FollowTarget>());

                // 投げモーション開始
                motion.StartAnimation(HumanMotion.AnimaList.Throw);
            }
            break;

        case State.actionBefore:
            // actionAfterへはアニメーションイベントでThrowActionを呼び出して遷移
            //			if ((Time.time - actionBeginTime) >= actionBeforeStanbdyTime) {
            //			// 投げる
            //			ThrowObject(throwVec);
            //			St = State.actionAfter;
            //
            //			// 待機モーション開始
            //			motion.StartAnimation(HumanMotion.AnimaList.Wait);
            //			}
            break;

        case State.actionAfter:
            if ((Time.time - actionBeginTime) >= actionAfterStanbdyTime)
            {
                St = State.aim;

                // 古い的を削除
                FadeColor destroyFade = targetPoint.gameObject.AddComponent <FadeColor>();
                destroyFade.ColList.Add(new Color(0.0f, 0.0f, 0.0f, 0.0f));
                destroyFade.DestroyOnLastFadeEnd = true;
                destroyFade.LoopFade             = false;

                ThrowStandby();
            }
            break;

        case State.damage:
            if ((Time.time - actionBeginTime) >= damageStanTime)
            {
                St = State.actionBefore;
            }
            break;
        }
    }
예제 #24
0
    private static void hpp_test02()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST02 tests HEP_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double e;
        int    n;
        int    n_data;
        int    o = 0;
        double x = 0;

        double[] xvec = new double[1];
        double   fx1  = 0;

        double[] fx2;

        n = 1;

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST02:");
        Console.WriteLine("  HEP_VALUES stores values of");
        Console.WriteLine("  the Hermite polynomial He(o,x).");
        Console.WriteLine("  HEP_VALUE evaluates a Hermite polynomial.");
        Console.WriteLine("");
        Console.WriteLine("                        Tabulated                 Computed");
        Console.WriteLine("     O        X          He(O,X)                   He(O,X)" +
                          "                   Error");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Burkardt.Values.Hermite.hep_values(ref n_data, ref o, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            xvec[0] = x;

            fx2 = Hermite.hep_value(n, o, ref xvec);

            e = fx1 - fx2[0];

            Console.WriteLine(o.ToString().PadLeft(6) + "  "
                              + x.ToString().PadLeft(12) + "  "
                              + fx1.ToString().PadLeft(24) + "  "
                              + fx2[0].ToString().PadLeft(24) + "  "
                              + e.ToString().PadLeft(8) + "");
        }
    }
예제 #25
0
    private static void hermite_polynomial_test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HERMITE_POLYNOMIAL_TEST03 tests HF_FUNCTION_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    26 February 2012
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int    n_data;
        double e;
        double fx1 = 0;
        double fx2;

        double[] fx2_vec;
        int      n = 0;
        double   x = 0;

        double[] x_vec = new double[1];

        Console.WriteLine("");
        Console.WriteLine("HERMITE_POLYNOMIAL_TEST03:");
        Console.WriteLine("  HF_FUNCTION_VALUES stores values of");
        Console.WriteLine("  the Hermite function Hf(n,x).");
        Console.WriteLine("  HF_FUNCTION_VALUE evaluates the function.");
        Console.WriteLine("");
        Console.WriteLine("                        Tabulated                 Computed");
        Console.WriteLine("     N        X          Hf(N,X)                   Hf(N,X)                   Error");
        Console.WriteLine("");

        n_data = 0;

        for (;;)
        {
            Burkardt.Values.Hermite.hf_function_values(ref n_data, ref n, ref x, ref fx1);

            if (n_data == 0)
            {
                break;
            }

            x_vec[0] = x;
            fx2_vec  = Hermite.hf_function_value(1, n, x_vec);
            fx2      = fx2_vec[n];

            e = fx1 - fx2;

            Console.WriteLine("  " + n.ToString().PadLeft(4)
                              + "  " + x.ToString().PadLeft(12)
                              + "  " + fx1.ToString("0.################").PadLeft(24)
                              + "  " + fx2.ToString("0.################").PadLeft(24)
                              + "  " + e.ToString("0.######").PadLeft(14) + "");
        }
    }
예제 #26
0
    private static void hpp_test03()

    //****************************************************************************80
    //
    //  Purpose:
    //
    //    HPP_TEST03 tests HEPP_VALUE.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    22 October 2014
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double[] c;
        int[]    e;
        int      i;

        int[] l;
        int   m = 3;
        int   n = 1;
        int   o = 0;
        int   o_max;
        int   rank;
        int   seed;

        double[] v1;
        double[] v2;
        double[] x;
        double   xhi;
        double   xlo;
        string   cout = "";

        Console.WriteLine("");
        Console.WriteLine("HPP_TEST03:");
        Console.WriteLine("  HEPP_VALUE evaluates a Hermite product polynomial.");
        Console.WriteLine("  POLYNOMIAL_VALUE evaluates a polynomial.");

        xlo  = -1.0;
        xhi  = +1.0;
        seed = 123456789;
        x    = UniformRNG.r8vec_uniform_ab_new(m, xlo, xhi, ref seed);

        Console.WriteLine("");
        cout = "  Evaluate at X = ";
        for (i = 0; i < m; i++)
        {
            cout += "  " + x[i + 0 * m];
        }

        Console.WriteLine(cout);
        Console.WriteLine("");
        Console.WriteLine("  Rank  I1  I2  I3:  He(I1,X1)*He(I2,X2)*He(I3,X3)    P(X1,X2,X3)");
        Console.WriteLine("");

        for (rank = 1; rank <= 20; rank++)
        {
            l = Comp.comp_unrank_grlex(m, rank);
            //
            //  Evaluate the HePP directly.
            //
            v1 = Hermite.hepp_value(m, n, l, x);
            //
            //  Convert the HePP to a polynomial.
            //
            o_max = 1;
            for (i = 0; i < m; i++)
            {
                o_max = o_max * (l[i] + 2) / 2;
            }

            c = new double[o_max];
            e = new int[o_max];

            Hermite.hepp_to_polynomial(m, l, o_max, o, ref c, ref e);
            //
            //  Evaluate the polynomial.
            //
            v2 = Polynomial.polynomial_value(m, o, c, e, n, x);
            //
            //  Compare results.
            //
            Console.WriteLine(rank.ToString().PadLeft(6) + "  "
                              + l[0].ToString().PadLeft(2) + "  "
                              + l[1].ToString().PadLeft(2) + "  "
                              + l[2].ToString().PadLeft(2) + "  "
                              + v1[0].ToString().PadLeft(14) + "  "
                              + v2[0].ToString().PadLeft(14) + "");
        }
    }