From 0ab39eec0788630d1b99a72aa34c244440a93c2e Mon Sep 17 00:00:00 2001
From: Pomax
Let's start with the good stuff: when we're talking about Bézier
curves, we're talking about the things that you can see in the
@@ -529,7 +529,7 @@
Playing with the points for curves may have given you a feel for how
Bézier curves behave, but what are Bézier curves, really?
@@ -607,7 +607,7 @@
Bézier curves are a form of "parametric" function. Mathematically
speaking, parametric functions are cheats: a "function" is actually
@@ -782,9 +782,9 @@
@@ -893,7 +893,7 @@ function Bezier(3,t):
Bézier curves are, like all "splines", interpolation functions. This
means that they take a set of points, and generate values somewhere
@@ -961,8 +961,8 @@ function Bezier(3,t):
We can further control Bézier curves by "rationalising" them: that
is, adding a "ratio" value in addition to the weight value discussed
@@ -1028,8 +1032,8 @@ function Bezier(3,t,w[]):
The function for rational Bézier curves has two more terms:
Now that we know the mathematics behind Bézier curves, there's one
curious thing that you may have noticed: they always run from
@@ -1206,7 +1210,7 @@ function RationalBezier(3,t,w[],r[]):
We can also represent Bézier curves as matrix operations, by
expressing the Bézier formula as a polynomial basis function and a
@@ -1339,7 +1343,7 @@ function RationalBezier(3,t,w[],r[]):
If we want to draw Bézier curves, we can run through all values of
We can also simplify the drawing process by "sampling" the curve at
certain points, and then joining those points up with straight
@@ -1509,7 +1513,7 @@ function RationalBezier(3,t,w[],r[]):
Using de Casteljau's algorithm, we can also find all the points we
need to split up a Bézier curve into two, smaller curves, which
@@ -1571,7 +1575,7 @@ function drawCurve(points[], t):
/>
Another way to split curves is to exploit the matrix representation
of a Bézier curve. In the section on matrices,
@@ -1871,7 +1875,7 @@ function drawCurve(points[], t):
One interesting property of Bézier curves is that an
nth order curve can always be perfectly
@@ -2110,7 +2114,7 @@ function drawCurve(points[], t):
There's a number of useful things that you can do with Bézier curves
based on their derivative, and one of the more amusing observations
@@ -2235,8 +2239,8 @@ function drawCurve(points[], t):
A lightning introduction
+ A lightning introduction
So what makes a Bézier Curve?
+ So what makes a Bézier Curve?
The mathematics of Bézier curves
+ The mathematics of Bézier curves
Controlling Bézier curvatures
+ Controlling Bézier curvatures
@@ -1007,7 +1007,11 @@ function Bezier(3,t,w[]):
Controlling Bézier curvatures, part 2: Rational Béziers
+
+ Controlling Bézier curvatures, part 2: Rational Béziers
+
@@ -1114,7 +1118,7 @@ function RationalBezier(3,t,w[],r[]):
The Bézier interval [0,1]
+ The Bézier interval [0,1]
Bézier curvatures as matrix operations
+ Bézier curvatures as matrix operations
de Casteljau's algorithm
+ de Casteljau's algorithm
t
from 0 to 1 and then compute the weighted basis
@@ -1439,7 +1443,7 @@ function RationalBezier(3,t,w[],r[]):
Simplified drawing
+ Simplified drawing
Splitting curves
+ Splitting curves
Splitting curves using matrices
+ Splitting curves using matrices
Lowering and elevating curve order
+ Lowering and elevating curve order
Derivatives
+ Derivatives
@@ -2254,16 +2258,16 @@ function drawCurve(points[], t):
And that's just a summation of lower order curves:
If you want to move objects along a curve, or "away from" a curve, the two vectors you're most interested in are the tangent vector and @@ -2460,7 +2464,7 @@ function drawCurve(points[], t):
Before we move on to the next section we need to spend a little bit of time on the difference between 2D and 3D. While for many things @@ -2721,7 +2725,7 @@ function drawCurve(points[], t):
One of the first things people run into when they start using Bézier curves in their own programs is "I know how to draw the curve, but @@ -2766,7 +2770,7 @@ function drawCurve(points[], t): />
Now that we understand (well, superficially anyway) the component functions, we can find the extremities of our Bézier curve by @@ -3100,7 +3104,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
If we have the extremities, and the start/end points, a simple for loop that tests for min/max values for x and y means we have the @@ -3147,7 +3151,7 @@ function getCubicRoots(pa, pb, pc, pd) {
While there are an incredible number of curves we can define by varying the x- and y-coordinates for the control points, not all @@ -3169,8 +3173,8 @@ function getCubicRoots(pa, pb, pc, pd) {
If we drop all the zero-terms, this gives us:
With our knowledge of bounding boxes, and curve alignment, We can now form the "tight" bounding box for curves. We first align our @@ -3258,7 +3262,7 @@ function getCubicRoots(pa, pb, pc, pd) {
Now that we know how to align a curve, there's one more thing we can calculate: inflection points. Imagine we have a variable size circle @@ -3417,7 +3421,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
While quadratic curves are relatively simple curves to analyze, the same cannot be said of the cubic curve. As a curvature is controlled @@ -3794,7 +3798,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
One common task that pops up in things like CSS work, or parametric equalisers, or image leveling, or any other number of applications @@ -3919,7 +3923,7 @@ if (roots.length > 0) { />
How long is a Bézier curve? As it turns out, that's not actually an easy question, because the answer requires maths that —much like @@ -4135,7 +4139,7 @@ if (roots.length > 0) { />
Sometimes, we don't actually need the precision of a true arc length, and we can get away with simply computing the approximate @@ -4173,7 +4177,7 @@ if (roots.length > 0) {
Imagine we have two curves, and we want to line them in up in a way that "looks right". What would we use as metric to let a computer @@ -4372,7 +4376,9 @@ if (roots.length > 0) { />
Say you want to draw a curve with a dashed line, rather than a solid line, or you want to move something along the curve at fixed @@ -4457,7 +4463,7 @@ if (roots.length > 0) {
Let's look at some more things we will want to do with Bézier curves. Almost immediately after figuring out how to get bounding @@ -4567,7 +4573,7 @@ lli = function(line1, line2):
Using de Casteljau's algorithm to split the curve we can now implement curve/curve intersection finding using a "divide and @@ -4652,7 +4658,7 @@ lli = function(line1, line2):
De Casteljau's algorithm is the pivotal algorithm when it comes to Bézier curves. You can use it not just to split curves, but also to @@ -4852,7 +4858,7 @@ lli = function(line1, line2):
Armed with knowledge of the "ABC" relation, we can now update a curve interactively, by letting people click anywhere on the curve, @@ -4938,7 +4944,7 @@ lli = function(line1, line2):
And that's cubic curve manipulation.
Given the preceding section on curve manipulation, we can also generate quadratic and cubic curves from any three points. However, @@ -4999,7 +5005,7 @@ lli = function(line1, line2):
Given the previous section, one question you might have is "what if
I don't want to guess t
values?". After all, plenty of
@@ -5460,7 +5466,9 @@ lli = function(line1, line2):
Taking an excursion to different splines, the other common design curve is the @@ -5815,7 +5823,11 @@ lli = function(line1, line2): />
Now, we saw how to fit a Bézier curve to three points, but if Catmull-Rom curves go through points, why can't we just use those to @@ -5869,7 +5881,7 @@ lli = function(line1, line2):
Much like lines can be chained together to form polygons, Bézier curves can be chained together to form poly-Béziers, and the only @@ -6039,7 +6051,7 @@ lli = function(line1, line2):
We can apply the topics covered so far in this primer to effect boolean shape operations: getting the union, intersection, or @@ -6177,7 +6189,9 @@ lli = function(line1, line2):
Say we have a Bézier curve and some point, not on the curve, of
which we want to know which t
value on the curve gives
@@ -6242,7 +6256,7 @@ lli = function(line1, line2):
/>
Perhaps you're like me, and you've been writing various small programs that use Bézier curves in some way or another, and at some @@ -6450,7 +6464,7 @@ lli = function(line1, line2):
What if we want to do graduated offsetting, starting at some
distance s
but ending at some other distance
@@ -6517,7 +6531,7 @@ lli = function(line1, line2):
/>
Circles and Bézier curves are very different beasts, and circles are infinitely easier to work with than Bézier curves. Their formula is @@ -6755,7 +6769,7 @@ lli = function(line1, line2):
In the previous section we tried to approximate a circular arc with a quadratic curve, and it mostly made us unhappy. Cubic curves are @@ -7090,7 +7104,11 @@ lli = function(line1, line2): />
Let's look at doing the exact opposite of the previous section: rather than approximating circular arc using Bézier curves, let's @@ -7274,7 +7292,7 @@ lli = function(line1, line2):
No discussion on Bézier curves is complete without also giving mention of that other beast in the curve design space: B-Splines. @@ -7825,12 +7843,12 @@ for(let L = 1; L <= order; L++) { * PLEASE DO NOT LOCALISE THIS FILE * * I can't respond to questions that aren't asked in English, so this is one of - * the few cases where there is a content.en-GB.md but you shouldn't change it. + * the few cases where there is a content.en-GB.md but you should not localize it. * * ----------------------------------------------------------------------------- */ -
First off, if you enjoyed this book, or you simply found it useful for something you were trying to get done, and you were wondering diff --git a/ja-JP/index.html b/ja-JP/index.html index 0a0e432c..575b89f1 100644 --- a/ja-JP/index.html +++ b/ja-JP/index.html @@ -399,7 +399,7 @@
まずは良い例から始めましょう。ベジエ曲線というのは、下の図に表示されているもののことです。ベジエ曲線はある始点からある終点へと延びており、その曲率は1個以上の「中間」制御点に左右されています。さて、このページの図はどれもインタラクティブになっていますので、ここで曲線をちょっと操作してみましょう。点をドラッグしたとき、曲線の形がそれに応じてどう変化するのか、確かめてみてください。
@@ -447,7 +447,9 @@ベジエ曲線がどのように動くのか、点を触ってみて感覚が摑めたかもしれません。では、実際のところベジエ曲線とはいったい何でしょうか?これを説明する方法は2通りありますが、どちらの説明でも行き着く先はまったく同じです。一方は複雑な数学を使うのに対し、もう一方はとても簡単です。というわけで……簡単な説明の方から始めましょう。
@@ -496,7 +498,7 @@ベジエ曲線は「パラメトリック」関数の一種です。数学的に言えば、パラメトリック関数というのはインチキです。というのも、「関数」はきっちり定義された用語であり、いくつかの入力を1つの出力に対応させる写像を表すものだからです。いくつかの数値を入れると、1つの数値が出てきます。入れる数値が変わっても、出てくる数値はやはり1つだけです。パラメトリック関数はインチキです。基本的には「じゃあわかった、値を複数個出したいから、関数を複数個使うことにするよ」ということです。例として、ある値xに何らかの操作を行い、別の値へと写す関数があるとします。
@@ -607,9 +609,9 @@@@ -693,7 +695,7 @@ function Bezier(3,t):
ベジエ曲線は(すべての「スプライン」と同様に)補間関数です。これは点の集合を受け取って、それらの点のどこか「内側」の値を生成するということです。(このことから、制御点同士を結んで輪郭をつくったとき、その外側に位置する点は決して生成されないことがわかります。なお、この輪郭を曲線の「包」と呼びます。お役立ち情報でした!)実際に、補間関数によって生成された値に対する、各点の寄与の大きさを可視化することができますが、これを見れば、ベジエ曲線のどの場所でどの点が重要になるのかがわかります。
@@ -736,8 +738,8 @@ function Bezier(3,t):We can further control Bézier curves by "rationalising" them: that is, adding a "ratio" value in addition to the weight value discussed @@ -800,8 +806,8 @@ function Bezier(3,t,w[]):
The function for rational Bézier curves has two more terms:
ここまでの説明で、ベジエ曲線の裏側にある数学がわかりました。しかし、気づいているかもしれませんが、ひとつ引っかかる点があります。ベジエ曲線はいつもt=0
からt=1
の間を動いていますが、どうしてこの特定の区間なのでしょう?
ベジエ曲線は、行列演算の形でも表現することができます。ベジエ曲線の式を多項式基底と係数行列で表し、実際の座標も行列として表現するのです。これがどういうことを意味しているのか、3次ベジエ曲線について見てみましょう。
@@ -1063,7 +1069,7 @@ function RationalBezier(3,t,w[],r[]):
ベジエ曲線を描く場合は、t
の値を0から1まで動かしながら重みつき基底関数を計算し、プロットに必要なx/y
の値を求めます。しかし、曲線が複雑になればなるほど、計算コストがかかるようになってしまいます。そこでその代わりに、「ド・カステリョのアルゴリズム」を使って曲線を描くこともできます。こちらは幾何学的に曲線を描く方法で、実装も非常に簡単です。実際、鉛筆と定規を使って手描きすることもできるほど、とても簡単な方法なのです。
曲線を複数点で「サンプリング」し、さらにそれを直線で繫げてしまえば、描画の手順を簡略化することができます。単なる一連の直線、つまり「平坦」な線へと曲線を単純化するので、この処理は「平坦化」という名前で知られています。
@@ -1185,7 +1191,7 @@ function RationalBezier(3,t,w[],r[]):
ベジエ曲線を分割して、繫ぎ合わせたときに元に戻るような小さい2曲線にしたい場合にも、ド・カステリョのアルゴリズムを使えば、これに必要な点をすべて求めることができます。ある値t
に対してド・カステリョの骨格を組み立てると、そのt
で曲線を分割する際に必要になる点がすべて得られます。骨格内部の点のうち、曲線上の点から見て手前側にある点によって一方の曲線が定義され、向こう側にある点によってもう一方の曲線が定義されます。
ベジエ曲線のおもしろい性質のひとつに、「n次の曲線は常に、n+1次の曲線で完璧に表すことができる」というものがあります。このとき、制御点は新しいものになります。
@@ -1526,7 +1532,7 @@ function drawCurve(points[], t):There's a number of useful things that you can do with Bézier curves based on their derivative, and one of the more amusing observations @@ -1651,8 +1657,8 @@ function drawCurve(points[], t):
And that's just a summation of lower order curves:
If you want to move objects along a curve, or "away from" a curve, the two vectors you're most interested in are the tangent vector and @@ -1876,7 +1882,7 @@ function drawCurve(points[], t):
Before we move on to the next section we need to spend a little bit of time on the difference between 2D and 3D. While for many things @@ -2137,7 +2143,7 @@ function drawCurve(points[], t):
One of the first things people run into when they start using Bézier curves in their own programs is "I know how to draw the curve, but @@ -2182,7 +2188,7 @@ function drawCurve(points[], t): />
Now that we understand (well, superficially anyway) the component functions, we can find the extremities of our Bézier curve by @@ -2516,7 +2522,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
If we have the extremities, and the start/end points, a simple for loop that tests for min/max values for x and y means we have the @@ -2563,7 +2569,7 @@ function getCubicRoots(pa, pb, pc, pd) {
While there are an incredible number of curves we can define by varying the x- and y-coordinates for the control points, not all @@ -2585,8 +2591,8 @@ function getCubicRoots(pa, pb, pc, pd) {
If we drop all the zero-terms, this gives us:
With our knowledge of bounding boxes, and curve alignment, We can now form the "tight" bounding box for curves. We first align our @@ -2674,7 +2680,7 @@ function getCubicRoots(pa, pb, pc, pd) {
Now that we know how to align a curve, there's one more thing we can calculate: inflection points. Imagine we have a variable size circle @@ -2833,7 +2839,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
While quadratic curves are relatively simple curves to analyze, the same cannot be said of the cubic curve. As a curvature is controlled @@ -3210,7 +3216,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
One common task that pops up in things like CSS work, or parametric equalisers, or image leveling, or any other number of applications @@ -3335,7 +3341,7 @@ if (roots.length > 0) { />
How long is a Bézier curve? As it turns out, that's not actually an easy question, because the answer requires maths that —much like @@ -3551,7 +3557,7 @@ if (roots.length > 0) { />
Sometimes, we don't actually need the precision of a true arc length, and we can get away with simply computing the approximate @@ -3589,7 +3595,7 @@ if (roots.length > 0) {
Imagine we have two curves, and we want to line them in up in a way that "looks right". What would we use as metric to let a computer @@ -3788,7 +3794,9 @@ if (roots.length > 0) { />
Say you want to draw a curve with a dashed line, rather than a solid line, or you want to move something along the curve at fixed @@ -3873,7 +3881,7 @@ if (roots.length > 0) {
Let's look at some more things we will want to do with Bézier curves. Almost immediately after figuring out how to get bounding @@ -3983,7 +3991,7 @@ lli = function(line1, line2):
Using de Casteljau's algorithm to split the curve we can now implement curve/curve intersection finding using a "divide and @@ -4068,7 +4076,7 @@ lli = function(line1, line2):
De Casteljau's algorithm is the pivotal algorithm when it comes to Bézier curves. You can use it not just to split curves, but also to @@ -4268,7 +4276,7 @@ lli = function(line1, line2):
Armed with knowledge of the "ABC" relation, we can now update a curve interactively, by letting people click anywhere on the curve, @@ -4354,7 +4362,7 @@ lli = function(line1, line2):
And that's cubic curve manipulation.
Given the preceding section on curve manipulation, we can also generate quadratic and cubic curves from any three points. However, @@ -4415,7 +4423,7 @@ lli = function(line1, line2):
Given the previous section, one question you might have is "what if
I don't want to guess t
values?". After all, plenty of
@@ -4876,7 +4884,9 @@ lli = function(line1, line2):
Taking an excursion to different splines, the other common design curve is the @@ -5231,7 +5241,11 @@ lli = function(line1, line2): />
Now, we saw how to fit a Bézier curve to three points, but if Catmull-Rom curves go through points, why can't we just use those to @@ -5285,7 +5299,7 @@ lli = function(line1, line2):
Much like lines can be chained together to form polygons, Bézier curves can be chained together to form poly-Béziers, and the only @@ -5455,7 +5469,7 @@ lli = function(line1, line2):
We can apply the topics covered so far in this primer to effect boolean shape operations: getting the union, intersection, or @@ -5593,7 +5607,9 @@ lli = function(line1, line2):
Say we have a Bézier curve and some point, not on the curve, of
which we want to know which t
value on the curve gives
@@ -5658,7 +5674,7 @@ lli = function(line1, line2):
/>
Perhaps you're like me, and you've been writing various small programs that use Bézier curves in some way or another, and at some @@ -5866,7 +5882,7 @@ lli = function(line1, line2):
What if we want to do graduated offsetting, starting at some
distance s
but ending at some other distance
@@ -5933,7 +5949,7 @@ lli = function(line1, line2):
/>
Circles and Bézier curves are very different beasts, and circles are infinitely easier to work with than Bézier curves. Their formula is @@ -6171,7 +6187,7 @@ lli = function(line1, line2):
In the previous section we tried to approximate a circular arc with a quadratic curve, and it mostly made us unhappy. Cubic curves are @@ -6506,7 +6522,11 @@ lli = function(line1, line2): />
Let's look at doing the exact opposite of the previous section: rather than approximating circular arc using Bézier curves, let's @@ -6690,7 +6710,7 @@ lli = function(line1, line2):
No discussion on Bézier curves is complete without also giving mention of that other beast in the curve design space: B-Splines. @@ -7241,12 +7261,12 @@ for(let L = 1; L <= order; L++) { * PLEASE DO NOT LOCALISE THIS FILE * * I can't respond to questions that aren't asked in English, so this is one of - * the few cases where there is a content.en-GB.md but you shouldn't change it. + * the few cases where there is a content.en-GB.md but you should not localize it. * * ----------------------------------------------------------------------------- */ -
First off, if you enjoyed this book, or you simply found it useful for something you were trying to get done, and you were wondering diff --git a/placeholder-style.css b/placeholder-style.css index 942d161a..806fc1c6 100644 --- a/placeholder-style.css +++ b/placeholder-style.css @@ -29,6 +29,11 @@ h1 { margin-right: 1em; } +#chapters section > h1 > a { + text-decoration: none; + color: inherit; +} + graphics-element { background: #e8e8e8; } diff --git a/tools/build/create-index-page.js b/tools/build/create-index-page.js index 075a20ca..ec5bb450 100644 --- a/tools/build/create-index-page.js +++ b/tools/build/create-index-page.js @@ -29,7 +29,10 @@ export default async function createIndexPages( if (content) { let title = content.match(/
让我们有个好的开始:当我们在谈论贝塞尔曲线的时候,所指的就是你在如下图像看到的东西。它们从某些起点开始,到终点结束,并且受到一个或多个的“中间”控制点的影响。本页面上的图形都是可交互的,你可以拖动这些点,看看这些形状在你的操作下会怎么变化。
@@ -434,7 +434,7 @@操作点的移动,看看曲线的变化,可能让你感受到了贝塞尔曲线是如何表现的。但贝塞尔曲线究竟是什么呢?有两种方式来解释贝塞尔曲线,并且可以证明它们完全相等,但是其中一种用到了复杂的数学,另外一种比较简单。所以...我们先从简单的开始吧:
@@ -483,7 +483,7 @@贝塞尔曲线是“参数”方程的一种形式。从数学上讲,参数方程作弊了:“方程”实际上是一个从输入到唯一输出的、良好定义的映射关系。几个输入进来,一个输出返回。改变输入变量,还是只有一个输出值。参数方程在这里作弊了。它们基本上干了这么件事,“好吧,我们想要更多的输出值,所以我们用了多个方程”。举个例子:假如我们有一个方程,通过一些计算,将假设为x的一些值映射到另外的值:
@@ -592,9 +592,9 @@@@ -676,7 +676,7 @@ function Bezier(3,t):
贝塞尔曲线是插值方程(就像所有曲线一样),这表示它们取一系列的点,生成一些处于这些点之间的值。(一个推论就是你永远无法生成一个位于这些控制点轮廓线外面的点,更普遍是称为曲线的外壳。这信息很有用!)实际上,我们可以将每个点对方程产生的曲线做出的贡献进行可视化,因此可以看出曲线上哪些点是重要的,它们处于什么位置。
@@ -719,8 +719,8 @@ function Bezier(3,t):We can further control Bézier curves by "rationalising" them: that is, adding a "ratio" value in addition to the weight value discussed @@ -783,8 +787,8 @@ function Bezier(3,t,w[]):
The function for rational Bézier curves has two more terms:
既然我们知道了贝塞尔曲线背后的数学原理,你可能会注意到一件奇怪的事:它们都是从t=0
到t=1
。为什么是这个特殊区间?
通过将贝塞尔公式表示成一个多项式基本方程、系数矩阵以及实际的坐标,我们也可以用矩阵运算来表示贝塞尔。让我们看一下这对三次曲线来说有什么含义:
@@ -1037,7 +1041,7 @@ function RationalBezier(3,t,w[],r[]):
要绘制贝塞尔曲线,我们可以从0
到1
遍历t
的所有值,计算权重函数,得到需要画的x/y
值。但曲线越复杂,计算量也变得越大。我们可以利用“de
Casteljau算法",这是一种几何画法,并且易于实现。实际上,你可以轻易地用笔和尺画出曲线。
@@ -1103,7 +1107,7 @@ function RationalBezier(3,t,w[],r[]):
我们可以简化绘制的过程,先在具体的位置“采样”曲线,然后用线段把这些点连接起来。由于我们是将曲线转换成一系列“平整的”直线,故将这个过程称之为“拉平(flattening)”。
@@ -1150,7 +1154,7 @@ function RationalBezier(3,t,w[],r[]):使用 de Casteljau 算法我们也可以将一条贝塞尔曲线分割成两条更小的曲线,二者拼接起来即可形成原来的曲线。当采用某个 @@ -1204,7 +1208,7 @@ function drawCurve(points[], t): />
Another way to split curves is to exploit the matrix representation of a Bézier curve. In the section on matrices, @@ -1504,7 +1508,7 @@ function drawCurve(points[], t):
One interesting property of Bézier curves is that an nth order curve can always be perfectly @@ -1743,7 +1747,7 @@ function drawCurve(points[], t):
There's a number of useful things that you can do with Bézier curves based on their derivative, and one of the more amusing observations @@ -1868,8 +1872,8 @@ function drawCurve(points[], t):
And that's just a summation of lower order curves:
If you want to move objects along a curve, or "away from" a curve, the two vectors you're most interested in are the tangent vector and @@ -2093,7 +2097,7 @@ function drawCurve(points[], t):
Before we move on to the next section we need to spend a little bit of time on the difference between 2D and 3D. While for many things @@ -2354,7 +2358,7 @@ function drawCurve(points[], t):
One of the first things people run into when they start using Bézier curves in their own programs is "I know how to draw the curve, but @@ -2399,7 +2403,7 @@ function drawCurve(points[], t): />
Now that we understand (well, superficially anyway) the component functions, we can find the extremities of our Bézier curve by @@ -2733,7 +2737,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
If we have the extremities, and the start/end points, a simple for loop that tests for min/max values for x and y means we have the @@ -2780,7 +2784,7 @@ function getCubicRoots(pa, pb, pc, pd) {
While there are an incredible number of curves we can define by varying the x- and y-coordinates for the control points, not all @@ -2802,8 +2806,8 @@ function getCubicRoots(pa, pb, pc, pd) {
If we drop all the zero-terms, this gives us:
With our knowledge of bounding boxes, and curve alignment, We can now form the "tight" bounding box for curves. We first align our @@ -2891,7 +2895,7 @@ function getCubicRoots(pa, pb, pc, pd) {
Now that we know how to align a curve, there's one more thing we can calculate: inflection points. Imagine we have a variable size circle @@ -3050,7 +3054,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
While quadratic curves are relatively simple curves to analyze, the same cannot be said of the cubic curve. As a curvature is controlled @@ -3427,7 +3431,7 @@ function getCubicRoots(pa, pb, pc, pd) { />
One common task that pops up in things like CSS work, or parametric equalisers, or image leveling, or any other number of applications @@ -3552,7 +3556,7 @@ if (roots.length > 0) { />
How long is a Bézier curve? As it turns out, that's not actually an easy question, because the answer requires maths that —much like @@ -3768,7 +3772,7 @@ if (roots.length > 0) { />
Sometimes, we don't actually need the precision of a true arc length, and we can get away with simply computing the approximate @@ -3806,7 +3810,7 @@ if (roots.length > 0) {
Imagine we have two curves, and we want to line them in up in a way that "looks right". What would we use as metric to let a computer @@ -4005,7 +4009,9 @@ if (roots.length > 0) { />
Say you want to draw a curve with a dashed line, rather than a solid line, or you want to move something along the curve at fixed @@ -4090,7 +4096,7 @@ if (roots.length > 0) {
Let's look at some more things we will want to do with Bézier curves. Almost immediately after figuring out how to get bounding @@ -4200,7 +4206,7 @@ lli = function(line1, line2):
Using de Casteljau's algorithm to split the curve we can now implement curve/curve intersection finding using a "divide and @@ -4285,7 +4291,7 @@ lli = function(line1, line2):
De Casteljau's algorithm is the pivotal algorithm when it comes to Bézier curves. You can use it not just to split curves, but also to @@ -4485,7 +4491,7 @@ lli = function(line1, line2):
Armed with knowledge of the "ABC" relation, we can now update a curve interactively, by letting people click anywhere on the curve, @@ -4571,7 +4577,7 @@ lli = function(line1, line2):
And that's cubic curve manipulation.
Given the preceding section on curve manipulation, we can also generate quadratic and cubic curves from any three points. However, @@ -4632,7 +4638,7 @@ lli = function(line1, line2):
Given the previous section, one question you might have is "what if
I don't want to guess t
values?". After all, plenty of
@@ -5093,7 +5099,9 @@ lli = function(line1, line2):
Taking an excursion to different splines, the other common design curve is the @@ -5448,7 +5456,11 @@ lli = function(line1, line2): />
Now, we saw how to fit a Bézier curve to three points, but if Catmull-Rom curves go through points, why can't we just use those to @@ -5502,7 +5514,7 @@ lli = function(line1, line2):
Much like lines can be chained together to form polygons, Bézier curves can be chained together to form poly-Béziers, and the only @@ -5672,7 +5684,7 @@ lli = function(line1, line2):
We can apply the topics covered so far in this primer to effect boolean shape operations: getting the union, intersection, or @@ -5810,7 +5822,9 @@ lli = function(line1, line2):
Say we have a Bézier curve and some point, not on the curve, of
which we want to know which t
value on the curve gives
@@ -5875,7 +5889,7 @@ lli = function(line1, line2):
/>
Perhaps you're like me, and you've been writing various small programs that use Bézier curves in some way or another, and at some @@ -6083,7 +6097,7 @@ lli = function(line1, line2):
What if we want to do graduated offsetting, starting at some
distance s
but ending at some other distance
@@ -6150,7 +6164,7 @@ lli = function(line1, line2):
/>
Circles and Bézier curves are very different beasts, and circles are infinitely easier to work with than Bézier curves. Their formula is @@ -6388,7 +6402,7 @@ lli = function(line1, line2):
In the previous section we tried to approximate a circular arc with a quadratic curve, and it mostly made us unhappy. Cubic curves are @@ -6723,7 +6737,11 @@ lli = function(line1, line2): />
Let's look at doing the exact opposite of the previous section: rather than approximating circular arc using Bézier curves, let's @@ -6907,7 +6925,7 @@ lli = function(line1, line2):
No discussion on Bézier curves is complete without also giving mention of that other beast in the curve design space: B-Splines. @@ -7458,12 +7476,12 @@ for(let L = 1; L <= order; L++) { * PLEASE DO NOT LOCALISE THIS FILE * * I can't respond to questions that aren't asked in English, so this is one of - * the few cases where there is a content.en-GB.md but you shouldn't change it. + * the few cases where there is a content.en-GB.md but you should not localize it. * * ----------------------------------------------------------------------------- */ -
First off, if you enjoyed this book, or you simply found it useful for something you were trying to get done, and you were wondering