Yes,

I see what you're saying -- just go ahead and actually draw the curve from p0 
to s and measure it -- then, of course! We will then know how long the curve 
is, and from that we can figure out just when a SMIL animation will traverse 
that point as it traverses the parent Bezier curve.

clever!

thanks
David


  ----- Original Message ----- 
  From: Frank Bruder 
  To: svg-developers@yahoogroups.com 
  Sent: Wednesday, October 29, 2008 6:46 PM
  Subject: [svg-developers] Re: midpoint(s) of a Bezier curve


  Let p0, p1, p2, p3 denote the control points of a cubic Bezier curve.
  p0 and p3 are the start and end point respectively. To get a better
  idea of the following, you should take paper and pencil and draw a
  sketch. Connect the control points with lines.

  Now place three points, q0, q1, q2, halfway between each two
  consecutive control points. That it,
  q0 = (p0 + p1) / 2
  q1 = (p1 + p2) / 2
  q3 = (p2 + p3) / 2

  Now place two points, r0, r1, halfway between the q_s.
  r0 = (q0 + q1) / 2
  r1 = (q1 + q2) / 2

  Finally place a point, s, halfway between r0 and r1.
  s = (r0 + r1) / 2

  This s is the midpoint in terms of the curve's parametrization. If you
  just want to find s you could calculate it more simply as
  s = (p0 + 3*p1 + 3*p2 + p3) / 8

  But the intermediate steps of the above construction can be used if
  you want to split the curve up.
  The Bezier curve defined by the control points
  p0, q0, r0, s
  is exactly the first half of the original curve, up to the point s.
  The Bezier curve defined by
  s, r1, q2, p3
  is the second half.

  Now you can create a new path element and use the control points for
  the first half to draw the segment of the original curve from p0 to s.
  getTotalLength(), called on the half curve, gives you the arc length
  at which s is on the original curve.

  Calculating arc lengths of cubic curves would require integrating the
  square root of a quartic polynomial. I suppose user agents implement
  getTotalLength() by measuring closely approximating polylines. There
  is no analytical solution for the general case. Arc length and the
  polynomial parametrization aren't linked by an easily computable
  function, so you should rely on the user agent's implementation of
  getArcLength() for this task.

  Note that it's easy to see now that the point s is not generally the
  point of maximum curvature. If it is for the curve with control points
  p0, p1, p2, p3 then we've just constructed two curves - given by p0,
  q0, r0, s; and s, r1, q2, p3 - which attain their maximum curvature at
  their end and start point respectively. The same goes for any local
  geometric property of the curve.

  Regards
  Frank

  --- In svg-developers@yahoogroups.com, "ddailey" <[EMAIL PROTECTED]> wrote:
  >
  > I've seen that some folks who pay attention to this list, also
  happen to be relatively comfortable with the math of Bezier curves.
  > 
  > Suppose we have a path, P (involving a cubic Bezier : d="M x y C cx
  cy dx dy ex ey"), then we can use
  P.getPointAtLength(P.getTotalLength()/2) to get the point which is
  halfway, in terms of arc length, from start to finish. Let's call
  that point H.
  > 
  > We may also calculate a (usually) different point M, defined by a
  weighted average of the end points with the control points as shown in
  [1]. 
  > 
  > That M and H are both points on the curve follows from the midpoint
  theorem and from the definition of getPointAtLength() . That they need
  not be the same can be verified by inspection of few examples.
  > 
  > I would be curious to know the arc length [2] of the curve from
  (x,y) to M (so that I might figure out when a SMIL animation will
  actually pass that point). I can tell by looking at the form of the
  parametric equation integrated over a radical involving its
  derivative, that my calculus is way too many decades old to even begin
  to work on it. Since M is sort of a special point, its arc length may
  also be special.
  > 
  > Alternatively does anyone know where getPointAtLength is defined?
  I'm assuming it uses some numerical approximation? Is that function
  invertible (since I'd like to do just the opposite of what the
  JavaScript function does)?
  > 
  > Ultimately I'm interested in the length of the arc to M since I'd
  like to use it as a point at which to place a bud for a new sprout on
  a branch -- it is also a point of sort of maximum curvature so it
  seems like a likely point for a bud to happen in a biological system.
  I can resort to using H instead -- since I can find it easily and I
  can presumably differentiate the curve at the point H, so as to
  generate a new sprout at some given angle relative to its parent
  branch. But M just seems more interesting, being in the center of the
  action, so to speak.
  > 
  > David
  > 
  > [1] http://homepage.smc.edu/kennedy_john/BEZIER.PDF
  > [2] http://en.wikipedia.org/wiki/Arc_length
  > 
  > [Non-text portions of this message have been removed]
  >



   

[Non-text portions of this message have been removed]


------------------------------------

-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
----Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to