Mercurial > hg > Members > kono > Cerium
changeset 414:b24ea9ca59fd
ChainCal.cpp indent-region
author | kazz@henri.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Wed, 23 Sep 2009 20:42:10 +0900 |
parents | 97e661a69cc0 |
children | 5e09f0fdab88 |
files | TaskManager/Test/test_render/spe/ChainCal.cpp |
diffstat | 1 files changed, 45 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/Test/test_render/spe/ChainCal.cpp Wed Sep 23 19:05:15 2009 +0900 +++ b/TaskManager/Test/test_render/spe/ChainCal.cpp Wed Sep 23 20:42:10 2009 +0900 @@ -37,54 +37,54 @@ //CHAIN_VARS* o_property = (CHAIN_VARS*)wbuf; for(int cnt = 0; cnt < 600; cnt++) { - for(int i = 0; i < CHAIN_LEN; i++) { - if(property[i].can_move) { - double dx = property[i-1].x - property[i].x; - double dy = property[i-1].y - property[i].y; - double l = sqrt(dx * dx + dy * dy); - double a = k * (l - chain_width) / m; - double ax = a * dx / l; - double ay = a * dy / l; - if(i < CHAIN_LEN - 1) { - dx = property[i+1].x - property[i].x; - dy = property[i+1].y - property[i].y; - l = sqrt(dx * dx + dy * dy); - a = k * (l - chain_width) / m; - ax += a * dx / l; - ay += a * dy / l; + for(int i = 0; i < CHAIN_LEN; i++) { + if(property[i].can_move) { + double dx = property[i-1].x - property[i].x; + double dy = property[i-1].y - property[i].y; + double l = sqrt(dx * dx + dy * dy); + double a = k * (l - chain_width) / m; + double ax = a * dx / l; + double ay = a * dy / l; + if(i < CHAIN_LEN - 1) { + dx = property[i+1].x - property[i].x; + dy = property[i+1].y - property[i].y; + l = sqrt(dx * dx + dy * dy); + a = k * (l - chain_width) / m; + ax += a * dx / l; + ay += a * dy / l; + } + ay += g; + property[i].vx *= safe; + property[i].vy *= safe; + property[i].next_vx = property[i].vx + ax * dt; + property[i].next_vy = property[i].vy + ay * dt; + property[i].next_x = property[i].x + property[i].vx * dt; + property[i].next_y = property[i].y + property[i].vy * dt; + } else { + property[i].next_x = property[i].x; + property[i].next_y = property[i].y; + } } - ay += g; - property[i].vx *= safe; - property[i].vy *= safe; - property[i].next_vx = property[i].vx + ax * dt; - property[i].next_vy = property[i].vy + ay * dt; - property[i].next_x = property[i].x + property[i].vx * dt; - property[i].next_y = property[i].y + property[i].vy * dt; - } else { - property[i].next_x = property[i].x; - property[i].next_y = property[i].y; - } - } - for(int i = 0; i < CHAIN_LEN; i++) { - property[i].vx = property[i].next_vx; - property[i].vy = property[i].next_vy; - property[i].x = property[i].next_x; - property[i].y = property[i].next_y; - } + for(int i = 0; i < CHAIN_LEN; i++) { + property[i].vx = property[i].next_vx; + property[i].vy = property[i].next_vy; + property[i].x = property[i].next_x; + property[i].y = property[i].next_y; + } } - + for (int j = 0; j < CHAIN_LEN; j++) { - int p, n; - id = property[j].id; - p = n = id; - if(p != 0) { - p--; - } - if(n != CHAIN_LEN - 1) { - n++; - } - property[j].angle[2-(id%2)*2] - = 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI; + int p, n; + id = property[j].id; + p = n = id; + if(p != 0) { + p--; + } + if(n != CHAIN_LEN - 1) { + n++; + } + property[j].angle[2-(id%2)*2] + = 90 + atan((property[p].next_y - property[n].next_y) / (property[p].next_x - property[n].next_x)) * 180 / M_PI; } return 0;