'How to use Cubic Hermite and Cubic Spline to interpolate Sine(x) with 4-5 non uniform samples?

Task is to draw a curve of Sin(x) and then use Cubic Hermite and Cubic Spline to interpolate the sine wave with 4-5 non-uniform samples.

I've written a code to draw a sine wave but now I'm stuck how to implement the cubic (Hermite and Spline interpolation).

#include <conio.h>
#include <graphics.h>
#include <math.h>

int main(){

initwindow(800,600);
int x,y;
line(0,300,getmaxx(),300);
line(400,0,400,getmaxy());
float pi = 3.14;

for(int i = -360; i < 360 ; i++){

x = (int) 400+i;
y = (int) 300 - sin(i*pi/100)*25;
putpixel(x,y,WHITE);

}

getch();
closegraph();

return 0;

}

Expected result is to calculate Cubic Hermite and Cubic Spline interpolation on the sine(x) wave.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source