File:Sinus par Bezier cubique.svg
![File:Sinus par Bezier cubique.svg](https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/Sinus_par_Bezier_cubique.svg/320px-Sinus_par_Bezier_cubique.svg.png?20181201003355)
Original file (SVG file, nominally 320 × 200 pixels, file size: 1 KB)
Captions
Captions
Summary
[edit]DescriptionSinus par Bezier cubique.svg |
Français : Fonction sinusoïdale approchée par une courbe de Bézier cubique (chemin SVG).
English: Sinus function approximated by a cubic Bézier curve (SVG path). |
Date | |
Source | Own work |
Author | Cdang |
Other versions | File:sinus_par_Bezier_quadratique.svg |
![](https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Notepad_icon_wide.svg/22px-Notepad_icon_wide.svg.png)
![](https://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Stop_hand_octagon.svg/22px-Stop_hand_octagon.svg.png)
![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/29/Simple_exclamation_mark.svg/8px-Simple_exclamation_mark.svg.png)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="320px" height="200px" version="1.1"
viewBox="0 0 320 200"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title> Titre </title>
<desc> Description </desc>
<defs>
<style type="text/css"><![CDATA[
path {
fill: none;
stroke: black;
stroke-width: 1
}
]]></style>
</defs>
<g id="sinus" transform="scale(0.5093, -1) translate(0, -100)">
<path
id="c1"
d="M0 0
C51.3 51.3, 100 100, 157.1 100"
/>
<use xlink:href="#c1"
transform="translate(314.2, 0) scale(-1, 1)" />
<use xlink:href="#c1"
transform="translate(314.2, 0) scale(1, -1)" />
<use xlink:href="#c1"
transform="translate(628.3, 0) scale(-1, -1)" />
</g>
</svg>
The control points are obtained by optimisation, using Scilab :
n=10;
t = linspace(0, 1, n);
x = %pi/2*t;
y = sin(x);
P0Q = [x(1) ; y(1)] ;
P2Q = [x($) ; y($)];
P1initQ = 0.5*(P0 + P2);
P0C = [x(1) ; y(1)] ;
P3C = [x($) ; y($)];
P1initC = 1/3*(P0 + P2);
P2initC = 2/3*(P0 + P2);
P12initC = [P1initC, P2initC];
// ********************************
// * Courbe de Bézier quadratique *
// ********************************
function [X] = bezierQ(P, t)
unMoinsT = [1 ; 1]*(1 - t);
tMat = [1 ; 1]*t;
unVec = ones(t);
P0 = P(:, 1)*unVec;
P1 = P(:, 2)*unVec;
P2 = P(:, 3)*unVec;
X = (P0.*unMoinsT + 2*P1.*tMat).*unMoinsT + P2.*tMat.*tMat;
endfunction
function [f] = diffquadQ(P)
X = bezierQ(P, t);
x = X(1, :); ybez = X(2, :); ysin = sin(x);
difference = ybez-ysin;
f = sum(difference.*difference);
endfunction
function [f, g, ind] = costfQ(P1, ind)
epsilon = 1e-3;
P = [P0Q, P1, P2Q];
f = diffquadQ(P);
g = zeros(P1);
for i = 1:2;
epsilonMat = zeros(P);
epsilonMat(i, 2) = epsilon;
dP = P + epsilonMat;
g(i) = diffquadQ(dP)-f;
end
endfunction
// ****************************
// * Courbe de Bézier cubique *
// ****************************
function [X] = bezierC(P, t)
unMoinsT = [1 ; 1]*(1 - t);
tMat = [1 ; 1]*t;
tMat2 = tMat.*tMat;
tMat3 = tMat2.*tMat;
unVec = ones(t);
P0 = P(:, 1)*unVec;
P1 = P(:, 2)*unVec;
P2 = P(:, 3)*unVec;
P3 = P(:, 4)*unVec;
X = ((P0.*unMoinsT + 3*P1.*tMat).*unMoinsT + 3*P2.*tMat2).*unMoinsT...
+ P3.*tMat3;
endfunction
function [f] = diffquadC(P)
X = bezierC(P, t);
x = X(1, :); ybez = X(2, :); ysin = sin(x);
difference = ybez-ysin;
f = sum(difference.*difference);
endfunction
function [f, g, ind] = costfC(P12, ind)
epsilon = 1e-3;
P = [P0C, P12, P3C];
f = diffquadC(P);
g = zeros(P1);
for i = 1:4;
epsilonMat = zeros(P12);
epsilonMat(i) = epsilon;
dP = P + [[0 ; 0], epsilonMat, [0 ; 0]];
g(i) = diffquadC(dP)-f;
end
endfunction
// ***********************
// * programme principal *
// ***********************
[foptQ, P1optQ] = optim(costfQ, P1initQ);
PoptQ = [P0Q, P1optQ, P2Q];
X = bezierQ(PoptQ, t);
scf(0);
clf();
plot(X(1 ,:), X(2, :), "+");
plot(x, y);
[foptC, P12optC] = optim(costfC, P12initC);
PoptC = [P0C, P12optC, P3C];
X = bezierC(PoptC, t);
scf(1);
clf();
plot(X(1 ,:), X(2, :), "+");
plot(x, y);
Licensing
[edit]![]() ![]() |
This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication. |
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 00:33, 1 December 2018 | ![]() | 320 × 200 (1 KB) | Cdang (talk | contribs) | +axis |
17:00, 29 November 2018 | ![]() | 320 × 200 (980 bytes) | Cdang (talk | contribs) | better orientation | |
23:22, 26 November 2018 | ![]() | 320 × 200 (978 bytes) | Cdang (talk | contribs) | User created page with UploadWizard |
You cannot overwrite this file.
File usage on Commons
The following page uses this file:
- File:Sinusoide par Bezier.svg (file redirect)
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Short title | Sinus par Bézier cubique |
---|---|
Image title | Courbe de bézier cubique approchant au mieux une fonction sinus |
Width | 320px |
Height | 200px |