mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-01 12:23:19 +02:00
Automated build
This commit is contained in:
19
docs/index.html
generated
19
docs/index.html
generated
@@ -38,7 +38,7 @@
|
||||
<meta property="og:locale" content="en-GB" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:published_time" content="2013-06-13T12:00:00+00:00" />
|
||||
<meta property="og:updated_time" content="2021-08-25T14:37:34+00:00" />
|
||||
<meta property="og:updated_time" content="2021-08-26T16:34:14+00:00" />
|
||||
<meta property="og:author" content="Mike 'Pomax' Kamermans" />
|
||||
<meta property="og:section" content="Bézier Curves" />
|
||||
<meta property="og:tag" content="Bézier Curves" />
|
||||
@@ -1688,21 +1688,24 @@ function RationalBezier(3,t,w[],r[]):
|
||||
</graphics-element>
|
||||
<div class="howtocode">
|
||||
<h3>How to implement de Casteljau's algorithm</h3>
|
||||
<p>Let's just use the algorithm we just specified, and implement that:</p>
|
||||
<p>
|
||||
Let's just use the algorithm we just specified, and implement that as a function that can take a list of curve-defining points, and a
|
||||
<code>t</code> value, and draws the associated point on the curve for that <code>t</code> value:
|
||||
</p>
|
||||
|
||||
<table class="code">
|
||||
<tr>
|
||||
<td>1</td>
|
||||
<td rowspan="8">
|
||||
<textarea disabled rows="8" role="doc-example">
|
||||
function drawCurve(points[], t):
|
||||
function drawCurvePoint(points[], t):
|
||||
if(points.length==1):
|
||||
draw(points[0])
|
||||
else:
|
||||
newpoints=array(points.size-1)
|
||||
for(i=0; i<newpoints.length; i++):
|
||||
newpoints[i] = (1-t) * points[i] + t * points[i+1]
|
||||
drawCurve(newpoints, t)</textarea
|
||||
drawCurvePoint(newpoints, t)</textarea
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1730,8 +1733,8 @@ function drawCurve(points[], t):
|
||||
</table>
|
||||
|
||||
<p>
|
||||
And done, that's the algorithm implemented. Except usually you don't get the luxury of overloading the "+" operator, so let's also give
|
||||
the code for when you need to work with <code>x</code> and <code>y</code> values:
|
||||
And done, that's the algorithm implemented. Although: usually you don't get the luxury of overloading the "+" operator, so let's also
|
||||
give the code for when you need to work with <code>x</code> and <code>y</code> values separately:
|
||||
</p>
|
||||
|
||||
<table class="code">
|
||||
@@ -1739,7 +1742,7 @@ function drawCurve(points[], t):
|
||||
<td>1</td>
|
||||
<td rowspan="10">
|
||||
<textarea disabled rows="10" role="doc-example">
|
||||
function drawCurve(points[], t):
|
||||
function drawCurvePoint(points[], t):
|
||||
if(points.length==1):
|
||||
draw(points[0])
|
||||
else:
|
||||
@@ -1748,7 +1751,7 @@ function drawCurve(points[], t):
|
||||
x = (1-t) * points[i].x + t * points[i+1].x
|
||||
y = (1-t) * points[i].y + t * points[i+1].y
|
||||
newpoints[i] = new point(x,y)
|
||||
drawCurve(newpoints, t)</textarea
|
||||
drawCurvePoint(newpoints, t)</textarea
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
|
Reference in New Issue
Block a user