Re: SVG Tiny 1.2 CR2006-08-10: path data

From: Dr. Olaf Hoffmann <Dr.O.Hoffmann@gmx.de>
Date: Wed, 8 Nov 2006 19:04:20 +0200

Message-Id: <200611081804.20933.Dr.O.Hoffmann@gmx.de>
```
> Now, how to convert T -> Q  and S -> C.
> And what about the relatives path data, can that also be converted
> from t -> q   and   s -> c.
> As I was doing T -> C which was giving wrong results.
> If T -> Q is done then I think my problem would be solved as I have api's
> for Q.

Parametrisation and Conversion
(of curve fragments/segments)

common parameter:
u from 0 to 1
c(u) Bezier curve

a) Linear Bezier
P(0), P(1) initial and final point

c(u) = (1-u)P(0) + u P(1)

P(0), P(1) initial and final point,
P(k) control point

c(u) = (1 - u)^2 P(0) + 2u(1-u) P(k) + u^2 P(1)

derivative

dc(u)/du = 2(u-1) P(0) + 2(1 -2u) P(k) + 2u P(1)

using this to get the same value for the derivative
for the next curve segment gives the following,
using points or control points a, b, c, d:

M a Q b c T d
is the same as
M a Q b c Q (2c-b) d

c) Cubic Bezier
P(0), P(3) initial and final point,
P(1), P(2) control points

c(u) = (1 - u)^3 P(0) + 3u(1-u)^2 P(1) + 3u^2 (1-u)P(2) + u^3 P(3)

derivative

dc(u)/du = -3(1 - u)^2 P(0) + 3(1-4u +3u^2) P(1) + 3(2u-3u^2) P(2) + 3u^2 P(3)

looking at the derivate for the curve segments
gives with the points or control points a, b, c, d, e, f:

M a C b c d S e f
is the same as
M a C b c d C (2d-c) e f

interesting for authors is a smooth closed curve
(continuous differentiable), for example:

M a C b c d ... S e (2a-b) a Z

d) Conversion small to large letters
for example for a qubic curve with
(control) points i,j,k,l,m,n,o:

M i c j k m s n o
is the same as
M i C (j+i) (k+i) (m+i) S (n+m+i) (o+m+i)

in general add the previous point in absolute
coordinates, but not a previous control point.

e) L -> C or Q -> C conversion

L to C conversion:
i, f initial and final point of the curve:
M i L f =
M i Q (i+f)/2, f =
M i C (2i+f)/3, (i+2f)/3 f

Q to C conversion (p control point):
M i Q p, f =
M i C (2p+i)/3, (2p+f)/3, f

f) Other conversions
reduce the problem to a combination of already solved problems.
For example t -> C use t -> T -> Q -> C

g) Not part of SVG tiny: A -> C?
Conversion from elliptical arcs to cubic Beziers is not exactly
possible and may cause nonsense if the path is animated - don't
do it or test it very carefully.
Ideas for this: Take a parametrisation of an elliptical arc,
compare with the parametrisation and derivative above to get
a useful approximation.

h) Test with non-trivial examples or better prove,
wether the given formulars are correct or not ;o)
```
Received on Wednesday, 8 November 2006 17:34:01 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:09 UTC