Пример #1
0
        /// <summary>
        /// Retourne le point discrétisé
        /// </summary>
        private Vector3 ReturnPointFromSpline(float delta)
        {
            float x = 0.0f;
            float y = 0.0f;

            for (int i = 0; i < m_controlpoints.Count; i++)
            {
                float polynomResult = ( float )MathStuffs.PolynomeBernstein(m_controlpoints.Count - 1, i, delta);
                x += polynomResult * m_controlpoints[i].X;
                y += polynomResult * m_controlpoints[i].Y;
            }

            return(new Vector3(x, y, 0.0f));
        }
Пример #2
0
        private Vector3 ComputeBSlineVertex(int idSegment, float t)
        {
            Vector3 vertex = new Vector3();


            for (int i = idSegment; i <= idSegment + Degree; i++)
            {
                double riesenfeld = MathStuffs.PolynomeRiesenfeld(i - idSegment, Degree, t);

                int val = i;
                if (i <= 0)
                {
                    if (Clamp)
                    {
                        val = 0;
                    }
                    else
                    {
                        val = m_controlpoints.Count + i;
                    }
                }
                if (i >= m_controlpoints.Count)
                {
                    if (Clamp)
                    {
                        val = m_controlpoints.Count - 1;
                    }
                    else
                    {
                        val = i - m_controlpoints.Count;
                    }
                }
                vertex.X += ( float )riesenfeld * m_controlpoints[val].X;
                vertex.Y += ( float )riesenfeld * m_controlpoints[val].Y;
                vertex.Z += ( float )riesenfeld * m_controlpoints[val].Z;
            }
            return(vertex);
        }