Created
December 1, 2018 10:20
-
-
Save Yeaseen/952ba0f20a96eb8cf36d87904538c825 to your computer and use it in GitHub Desktop.
Forward diff method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//forward differencing method for rendering curve points | |
int t=20; | |
double space=0.05; | |
double fx,fy,f1x,f2x,f3x,f1y,f2y,f3y; | |
fx=ansMat[3][0]; | |
fy=ansMat[3][1]; | |
f1x= ansMat[0][0]*pow(space,3)+ ansMat[1][0]*pow(space,2)+ansMat[2][0]*space; | |
f2x=6*ansMat[0][0]*pow(space,3)+ 2*ansMat[1][0]*pow(space,2); | |
f3x=6*ansMat[0][0]*pow(space,3); | |
f1y= ansMat[0][1]*pow(space,3)+ ansMat[1][1]*pow(space,2)+ansMat[2][1]*space; | |
f2y=6*ansMat[0][1]*pow(space,3)+ 2*ansMat[1][1]*pow(space,2); | |
f3y=6*ansMat[0][1]*pow(space,3); | |
pointsOn[midx].x = (double)fx; | |
pointsOn[midx].y = (double)fy; | |
midx++; | |
for(int i=0; i<t; i++){ | |
fx+=f1x; | |
f1x+=f2x; | |
f2x+=f3x; | |
fy+=f1y; | |
f1y+=f2y; | |
f2y+=f3y; | |
pointsOn[midx].x = (double)fx; | |
pointsOn[midx].y = (double)fy; | |
midx++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment