|
|
"kendfrey" <nomail@nomail> wrote:
> WolframAlpha has suggested the expression 8*sqrt(2)-9 based on my approximation,
> and it seems accurate to 10 digits, so I'll use it. I have no idea where the
> expression comes from, though.
The Bezier spline is based on the identity ((1-t) + t)^3 = 1
Given two endpoints, p_0 and p_3 and two "direction" points, p_1 and p_2 which
give the tangents at the end points in the directions of p_1-p_0 and p_3-p_2.
The actual tangents are 3(p_1 - p_0) and 3(p_3 - p_2),
p(t) = (1-t)^3xp_0 + 3(1-t)^2txp_1 + 3(1-t)t^2xp_2 + t^3xp_3
For an approximation to a circle,
p_0 = (1,0), p_1 = (1,a), p_2 = (a,1), p_3 = (0,1)
A simple determination of a comes from putting p(1/2) = (1/sqrt(2),1/sqrt(2)),
though this isn't the best least squares approximation.
Just calculating the x component,
1/sqrt(2) = 1/8 + 3/8 + 3a/8, a = 8(sqrt(2) - 1)/6 = 0.5522847498
A Catmull-Rom spline sets the first direction point of an equivalent Bezier
spline at p_i to be p_i + (p_(i+1) - p_(i-1))/6 (this sets the tangent
to be (p_(i+1) - p_(i-1))/2 which is more believable) so the 4 points for
POV-Ray's sphere sweep are, as you say,
p_(-1) = (0,-k), p_0 = (1,0), p_1 = (0,1) and p_2 = (-k,0). The spline
goes from p_0 to p_1. Thus the direction point for the equivalent Bezier
spline will be (1,(1+k)/6).
Setting the y component, (1+k)/6 equal to the y component of the Bezier
direction point, which is just a = 0.5522847498, we get k = 2.313708499
I use single Bezier spline segments quite a lot since I find the placement
of the direction points at least partly intuitive.
Post a reply to this message
|
|