<?xml version="1.0" standalone="no"?>
SVGは、2次および3次多項式に十分に適した2次および3次のベジェ曲線を提供します。
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="20cm" height="20cm" viewBox="0 0 1000 1000"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<style type="text/css"><![CDATA[
.axis { fill: none; stroke: black; stroke-width: 3; }
.tick { fill: none; stroke: black; stroke-width: 1; }
.fun1 { fill: none; stroke: blue; stroke-width: 2; }
.fun2 { fill: none; stroke: red; stroke-width: 2; }
]]></style>
<polyline class="axis" points="0,500 1000,500" />
<polyline class="tick" points="0,490 0,510" />
<polyline class="tick" points="100,490 100,510" />
<polyline class="tick" points="200,490 200,510" />
<polyline class="tick" points="300,490 300,510" />
<polyline class="tick" points="400,490 400,510" />
<polyline class="tick" points="600,490 600,510" />
<polyline class="tick" points="700,490 700,510" />
<polyline class="tick" points="800,490 800,510" />
<polyline class="tick" points="900,490 900,510" />
<polyline class="tick" points="1000,490 1000,510" />
<polyline class="axis" points="500,0 500,1000" />
<polyline class="tick" points="490,0 510,0" />
<polyline class="tick" points="490,100 510,100" />
<polyline class="tick" points="490,200 510,200" />
<polyline class="tick" points="490,300 510,300" />
<polyline class="tick" points="490,400 510,400" />
<polyline class="tick" points="490,600 510,600" />
<polyline class="tick" points="490,700 510,700" />
<polyline class="tick" points="490,800 510,800" />
<polyline class="tick" points="490,900 510,900" />
<polyline class="tick" points="490,1000 510,1000" />
エンドポイント(-3,5)および(3,5)でy =x² - 4とする。接線はy = -6x-13、y = 6x-13です。両方の接線上に1つの制御点を(0、-13)にします。これは任意の二次関数に対して簡単に動作するはずです。
<path class="fun1" d="M200,0 Q500,1800 800,0" />
キュービックは少しトリッキーです。 (-5、-5)から(5,5)までのy =(x3 - 9x)/ 16の場合、接線はy =(33x + 125)/ 8、y =(33x - 125)/ 8です。曲線は-9/16のスロープで(0、0)を通過しなければなりません。C
制御点(-5/3,35/4)と(5/3,35/4)を見つけるための簡単な計算です。ほとんどの場合、おそらく手で行うことはできませんが、このアプローチは、制御点がどれほど接線に沿ってどれほど離れているか、そして特定の点と方向を強制する2つの制約の他の3次変数に対して数値的に実行可能でなければならないと思います。
<path class="fun2" d="M0,1000 C333,-375 667,1375 1000,0" />
(私はこれらを働いていたときAnimated Bézier Curvesはとても役に立ちました。)
</svg>
![](https://i.imgur.com/kmGMA.png)
私はあなたが*正確に*のベジェ曲線と多項式を記述することができるかどうかわからないんだけど同じ程度。 – CodesInChaos
@CodeInChaos好奇心の渦中から人々はSVGで多項式をどのようにグラフ化するのですか?私はそれが終わったのを見たことがありますが、人々が関数からグラフにどのように移行するかは不明です。正確なフィットは厳密な要件ではありませんが、グラフは合理的に正確でなければなりません。 –
私はグラフを他の関数と同じようにグラフ化すると仮定します。曲線上の多くの点(1000程度)で関数値を計算し、その関数を関数にフィットさせます。線で最も単純なケースですが、ベジエ曲線が高いほど確かに良く見えますが、コントロールポイントを計算する便利な方法は覚えていません。 – CodesInChaos