Can anyone help for a valid interpolation of an angle from -0.2 to 0.2 to give 1001 points in between? SLERP is not doing this range for me ?
Thank you
angleinterpolation
num2bin(0.3)ans = struct with fields: Class: 'double' Sign: 1 Exponent: -2 Mantissa: '10011001100110011001100110011001100110011001100110011' BinaryExpansion: [1×27 double] BiSci: '1.0011001100110011001100110011001100110011001100110011 B-2' BiCimal: '0.010011001100110011001100110011001100110011001100110011'
BE = num2bin(0.3).BinaryExpansionBE = Columns 1 through 21 -2 -5 -6 -9 -10 -13 -14 -17 -18 -21 -22 -25 -26 -29 -30 -33 -34 -37 -38 -41 -42 Columns 22 through 27 -45 -46 -49 -50 -53 -54
sum(2.^BE)ans = 0.3 sum(2.^BE) == 0.3ans = logical 1
[0.3 - 0.1 - 0.2, -0.1 - 0.2 + 0.3]ans = -2.77555756156289e-17 -5.55111512312578e-17
-2^-55ans = -2.77555756156289e-17 0.3 - 0.1 - 0.2ans = -2.77555756156289e-17
-0.1 -0.2 + 0.3ans = -5.55111512312578e-17
-0.1 -0.2 + 0.3ans = -5.55111512312578e-17 num2bin(-0.1 - 0.2 + 0.3).BinaryExpansionans = -54 -2^-54ans = -5.55111512312578e-17
(0.2 + 0.3 - 0.4) == (-0.4 + 0.2 + 0.3)ans = logical 1
-4/7 + 1/7 + 3/7 == 1/7 - 4/7 + 3/7ans = logical 1
12/13 - 3/13 - 9/13 == 12/13 - 9/13 - 3/13ans = logical 0
x0=0; x1=5; g0=0; g1=0;y0= 0; y1= 150;A1 = [x0^3,x0^2,x0,1; 3*x0^2,2*x0,1,0; x1^3,x1^2,x1,1; 3*x1^2,2*x1,1,0]; C1 = A1\[y0,g0,y1,g1]'; % Solve for the four cubic Hermite coefficients
n = 1000;X1 = linspace(x0,x1,n);Y1 = C1'*[X1.^3;X1.^2;X1;ones(1,n)];% second segment
x2=10; y2= 0; g1= 0; g2=0;A2 = [x1^3,x1^2,x1,1; 3*x1^2,2*x1,1,0; x2^3,x2^2,x2,1; 3*x2^2,2*x2,1,0]; C2 = A2\[y1,g1,y2,g2]';X2 = linspace(x1,x2,n);Y2 = C2'*[X2.^3;X2.^2;X2;ones(1,n)];dY1 = gradient(Y1, X1(2)-X1(1)); % Calculate Gradient
[Y1max,idxY1(1)] = max(dY1);[Y1min,idxY1(2)] = min(dY1);dY2 = gradient(Y2, X2(2)-X2(1)); % Calculate Gradient[Y2max,idxY2(1)] = max(dY2);[Y2min,idxY2(2)] = min(dY2);plot(X1,Y1)hold onplot(X2,Y2)plot(X1(idxY1(1)), Y1(idxY1(1)), '^')plot(X1(idxY1(2)), Y1(idxY1(2)), 'v')plot(X2(idxY2(1)), Y2(idxY2(1)), '^')plot(X2(idxY2(2)), Y2(idxY2(2)), 'v')hold offtitle('cubic hermite')xlabel('x')ylabel('y');
Best Answer