#include #include #include #define NONE -1 /* その点は存在しない */ #define FIX 0 /* 固定 */ #define FREE 1 /* 動く*/ #define N 15 /* 点の数 */ #define L 250.0/N /* バネの自然長 (格子全体の大きさがウィンドウの大きさの半分ぐらい) */ /* 全体で使う変数 */ double px[N][N]; /* 点の位置の x 座標.*/ double py[N][N]; /* 点の位置の y 座標. */ double vx[N][N]; /* 速度ベクトルの x 成分. */ double vy[N][N]; /* 速度ベクトルの y 成分. */ int state[N][N]; /* 状態 NON, FIX, FREE のうちどれか */ /* 初期位置と初速の決定 */ void initPoints(){ int i, j; double x, y, d; for(i=0; i