// PROGRAM wheel #include "TrueBASIC.h" int main(); void initial(double *r, double *omega, double *vcm, double *t, double *dt, double *xmax); int main() { double dt, omega, r, t, vcm, x = 0, xmax, y; GWopen(0); initial(&r, &omega, &vcm, &t, &dt, &xmax); GWsetpen(-1, -1, -1, -1); while(x <= xmax) { x = -r*cos(omega*t) + vcm*t; y = r*sin(omega*t); GWline2((float)(x), (float)(y)); t += dt; } GWquit(); return 0; } void initial(double *r, double *omega, double *vcm, double *t, double *dt, double *xmax) { float mx, xmin; (*t) = 0; (*r) = 1; // 車輪の半径 (*omega) = 1; // 車輪の角速度 (*vcm) = (*r)*(*omega); // 質量中心の速度 (*dt) = 0.01; // 時間の増分 xmin = -1; (*xmax) = 50; mx = 0.01*((*xmax) - xmin); GWindow(xmin-mx, -4.0f, (float)((*xmax)+mx), 4.0f); // y = -r (車輪の最下部) の位置に地面を描く GWline(xmin, (float)(-(*r)), (float)((*xmax)), (float)(-(*r))); }