Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sshape.cpp
00001 #include "sshape.h" 00002 00003 shape::shape(double time){ 00004 time_c = time; 00005 } 00006 00007 int shape::pm(double num){ 00008 return (num>0)-(num<0); 00009 } 00010 double shape::start(){ 00011 start_m = clock(); 00012 return start_m; 00013 } 00014 double shape::shapeTime(double starttime){ 00015 return ((double)(clock() - starttime) / 100); 00016 } 00017 00018 double shape::compute(double stickpoints,double starttime,double add){ 00019 shapeS_m = kasokudo(time_c,starttime,stickpoints,add); 00020 if(pm(stickpoints - add_m)*shapeS_m <= pm(stickpoints - add)*stickpoints){ 00021 shapeS_m = kasokudo(time_c,starttime,stickpoints,add); 00022 }else{ 00023 add_m = stickpoints; 00024 return add_m; 00025 } 00026 return shapeS_m; 00027 } 00028 00029 double shape::kasokudo(double time_s,double start_s,double points_s,double add_s){ 00030 00031 if(points_s != 0){ 00032 if(points_s>add_s){ 00033 tmp = ((double)(clock() - start_s) / 100)/time_s; 00034 shapeSpeed = tmp*tmp*pm(points_s)*fabs(points_s-add_s)*pm(points_s)+add_s; 00035 }else{ 00036 tmp = ((double)(clock() - start_s) / 100)/time_s; 00037 shapeSpeed = tmp*tmp*pm(points_s)*-fabs(points_s-add_s)*pm(points_s)+add_s; 00038 } 00039 }else{ 00040 if(points_s>add_s){ 00041 tmp = ((double)(clock() - start_s) / 100)/time_s; 00042 shapeSpeed = tmp*tmp*-add_s + add_s; 00043 }else{ 00044 tmp = ((double)(clock() - start_s) / 100)/time_s; 00045 shapeSpeed = -tmp*tmp*add_s + add_s; 00046 } 00047 } 00048 00049 return shapeSpeed; 00050 00051 }
Generated on Wed Nov 16 2022 08:38:09 by
1.7.2