title: De Casteljau algorithm ignore a control point
body: <p>I wrote an implementation of the De Casteljau algorithm to create a Bezier curve. My problem is the function ignores the second control point, it does calculate some kind of curve, but it is not correct. </p>
  
  <pre><code>def DeCasteljau(CNTRL_P, t):
      ReP = points.point()
      Ret = points.point()
  
      n = len(CNTRL_P)
      k = 0
      tmp = 0
  
      while k &lt; n:
          tmp = (((1 - t)**((n-1) - k))  *  (t**k))
          ReP.addP(CNTRL_P[k])
          #ReP.Prnt()
          ReP.mulP(tmp)   
          Ret.addP(ReP)
          ReP.Clr() #ReP =&gt; (0,0)
          tmp = 0
          k = k + 1
  
      return Ret
  </code></pre>
  
  <p>For example: CNTRL_P = [P0, P1, P2]
  It ignores P1</p>
  
  <pre><code>class point():
      def __init__(self, X = 0, Y = 0):
          self.x = X
          self.y = Y
  
      def addP(self, P1):
          self.x = self.x + (P1.getX()) 
          self.y = self.y + (P1.getY())
  
      def subP(self, C = 0, D = 0):
          self.x = self.x - C
          self.y = self.y - D
  
      def mulP(self, C):
          self.x = self.x * C
          self.y = self.y * C
  
      def getX(self):
          a = self.x
          return a
  
      def getY(self):
          a = self.y
          return a
  
      def Prnt(self):
          print "X:", self.x,"Y:", self.y
  
      def Clr(self):
          self.x = 0
          self.y = 0
  </code></pre>