Find the oblique angle of the tangent of any point on the quadratic Bessel curve

2012101521423763.gif

given x coordinates, want to know the tilt angle of this blue line

Real demand: draw words close to the curve and find a train of thought


your image is a third-order Bezier curve

P0 = [0, 0]
P1 = [-1, 10]
P2 = [8, 10]
P3 = [12, 0]
//(1 - t)^3P0 + 3t(1- t)^2P1 + 3t^2(1 - t)P2 + t^3P3
//(P3 - 3P2 + 3P1 - P0)t^3 + (3P2 - 6P1 + 3P0)t^2 + (3P1 - 3P0)t + P0
a = P3[0] - 3 * P2[0] + 3 * P1[0] - P0[0]
b = 3 * P2[0] - 6 * P1[0] + 3 * P0[0]
c = 3 * P1[0] - 3 * P0[0]
d = P0[0]
function f(x){
    t = Math_yyz.getCubicRoot(a, b, c, d - x);
    realt = t.find((n) => n >= 0 && n <= 1 && n !== null)
    pm = f1(realt, P0, P1, P2);
    pn = f1(realt, P1, P2, P3);
    return (pm[1] - pn[1]) / (pm[0] - pn[0]);
}

function f1(t, p0, p1, p2){
    return [(1 - t) * (1 - t) * p0[0] + 2 * t * (1 - t) * p1[0] + t * t * p2[0], (1 - t) * (1 - t) * p0[1] + 2 * t * (1 - t) * p1[1] + t * t * p2[1]];
}

f(4)x=4
//
Math_yyz=(function(){ 
var module={}; 
function eqZero(x){ 
return Math.abs(x)<1e-6; 
} 
var abs=Math.abs; 
var pow=Math.pow; 
var sqrt=Math.sqrt; 
var sign=Math.sign; 
var cos=Math.cos; 
var acos=Math.acos; 
var TwoPi=Math.PI*2; 
function getCubicRoot(a,b,c,d){ 
a=a; 
b=b/(3*a); 
c=c/(6*a); 
d=d/(2*a); 

var solve=[null,null,null]; 
var Alph=-b*b*b+3*b*c-d; 
var Beta=b*b-2*c; 
var Delt=Alph*Alph-Beta*Beta*Beta; 
var R1,R2,tht; 

if (eqZero(Delt)){ 
R1=abs(pow(abs(Alph),1/3))*sign(Alph); 
if (eqZero(R1)){ 
solve[0]=-b; 
} 
else{ 
solve[0]=-b+2*R1; 
solve[1]=-b-R1; 
} 
} 
else if(Delt>0){ 
//var tht,R1,R2; 
tht=Alph+sqrt(Delt); 
R1=abs(pow(abs(tht),1/3))*sign(tht); 
tht=Alph-sqrt(Delt); 
R2=abs(pow(abs(tht),1/3))*sign(tht); 
solve[0]=-b+R1+R2; 
} 
else if(Delt<0){ 
//var tht; 
tht=acos(Alph/(sqrt(Beta)*Beta)); 
solve[0]=-b+2*sqrt(Beta)*cos(tht/3); 
solve[1]=-b+2*sqrt(Beta)*cos((tht+TwoPi)/3.0); 
solve[2]=-b+2*sqrt(Beta)*cos((tht-TwoPi)/3); 
} 
return solve; 
} 
module.getCubicRoot=getCubicRoot; 
return module; 
})();



:
Pm(t) = (1-t)P0 + tP1
Pn(t) = (1-t)P1 + tP2
B(t) = (1-t)Pm(t) + tPn(t) 
= (1-t)^2 P0 + 2(1-t)tP1+ t^2P2
XX0
Bx(t) = (1-t)^2 P0x + 2(1-t)tP1x+ t^2P2x = X0 t, Pm, Pn
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9ff4c-2f4cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9ff4c-2f4cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?