diff -urN wf-/data.c wf/data.c --- wf-/data.c 2015-12-17 00:00:00.000000000 +0900 +++ wf/data.c 2015-12-19 00:00:00.000000000 +0900 @@ -212,6 +212,14 @@ } static void +op_data_timeshift(struct timeshift *ts, data_t *data, prm_t *prm) +{ + data_t op = { type_slide, &ts->slide }; + prm->sec += ts->sec; + op_data_draw(&op, data, prm); +} + +static void op_data_slide_way(struct way *slide, data_t *data, prm_t *prm) { affin_t af; @@ -224,6 +232,18 @@ } static void +op_data_rot_way(struct rot_way *rw, data_t *data, prm_t *prm) +{ + affin_t af; + struct way way = rw->deg_way; + + way_get(&way, prm->sec); + affin_rot(&af, &rw->l, way.ret_v); + affin_compo(&prm->af, &prm->af, &af); + data_draw(data, prm); +} + +static void op_data_copy(struct copy *copy, data_t *data, prm_t *prm) { int x, y, z; @@ -271,6 +291,20 @@ op_data_draw(&op, data, prm); } +static void +op_data_copy_timeshift(struct copy_timeshift *copy, data_t *data, prm_t *prm) +{ + int i; + struct timeshift ts = { .sec = copy->init_sec, .slide = copy->init }; + data_t op = { type_timeshift, &ts }; + + for(i=0; in; i++){ + op_data_draw(&op, data,prm); + ts.sec += copy->step_sec; + d3_add(&ts.slide, ©->step); + } +} + void op_data_draw(data_t *op, data_t *data, prm_t *prm) { @@ -299,15 +333,16 @@ case type_mirror: op_data_mirror(op->p, data, prm); break; + case type_timeshift: + op_data_timeshift(op->p, data, prm); + break; case type_slide_way: op_data_slide_way(op->p, data, prm); break; -#if 0 case type_rot_way: op_data_rot_way(op->p, data, prm); break; -#endif case type_copy: op_data_copy(op->p, data, prm); @@ -321,6 +356,9 @@ case type_copy_mirror: op_data_copy_mirror(op->p, data, prm); break; + case type_copy_timeshift: + op_data_copy_timeshift(op->p, data, prm); + break; case type_end: default: diff -urN wf-/data.h wf/data.h --- wf-/data.h 2015-12-17 00:00:00.000000000 +0900 +++ wf/data.h 2015-12-19 00:00:00.000000000 +0900 @@ -25,6 +25,7 @@ #define type_rot 103 #define type_point_symmetry 104 #define type_mirror 105 +#define type_timeshift 106 #define type_slide_way 120 #define type_rot_way 130 @@ -33,6 +34,7 @@ #define type_copy_rot 201 #define type_copy_point_symmetry 202 #define type_copy_mirror 203 +#define type_copy_timeshift 204 struct wire_frame{ @@ -53,6 +55,16 @@ double deg; }; +struct rot_way{ + line_t l; + struct way deg_way; +}; + +struct timeshift{ + double sec; + d3_t slide; +}; + struct copy{ struct { int x, y, z; } n; d3_t init, step; @@ -66,6 +78,12 @@ /* deg = init_deg + step_deg * i */ }; +struct copy_timeshift{ + int n; + double init_sec, step_sec; + d3_t init, step; +}; + typedef struct{ affin_t af; const eye_t *eye; diff -urN wf-/way.c wf/way.c --- wf-/way.c 2015-12-17 00:00:00.000000000 +0900 +++ wf/way.c 2015-12-19 00:00:00.000000000 +0900 @@ -37,7 +37,8 @@ sum += ts[i]; } *t -= sum; - *t /= ts[i]; + if(ts[i] == 0) *t = 0; + else *t /= ts[i]; return i; } @@ -66,10 +67,10 @@ for(i=0; i<3; i++) k[i] = way->vs[(idx+i)%n] - way->vs[(prv+i)%n]; - if(!is_repeat(ts, n) && idx == 0) ksp = NULL; + if((!is_repeat(ts, n) && idx == 0) || ts[prv] == 0) ksp = NULL; else ks = ( k[0] * ts[idx] / ts[prv] + k[1] ) * 0.5; - if(!is_repeat(ts, n) && idx == n-2) kep = NULL; + if((!is_repeat(ts, n) && idx == n-2) || ts[nxt] == 0) kep = NULL; else ke = ( k[1] + k[2] * ts[idx] / ts[nxt] ) * 0.5; way->ret_v = interp3(way->vs[idx], way->vs[nxt], ksp, kep, t); @@ -80,7 +81,7 @@ for(i=0; i<3; i++) vec_set(&k[i], &way->ps[(prv+i)%n], &way->ps[(idx+i)%n]); - if(!is_repeat(ts, n) && idx == 0) ksp = NULL; + if((!is_repeat(ts, n) && idx == 0) || ts[prv] == 0) ksp = NULL; else{ ks = k[0]; d3_mul(&ks, ts[idx] / ts[prv]); @@ -88,7 +89,7 @@ d3_mul(&ks, 0.5); } - if(!is_repeat(ts, n) && idx == n-2) kep = NULL; + if((!is_repeat(ts, n) && idx == n-2) || ts[nxt] == 0) kep = NULL; else{ ke = k[2]; d3_mul(&ke, ts[idx] / ts[nxt]); diff -urN wf-/wf_ex.c wf/wf_ex.c --- wf-/wf_ex.c 2015-12-18 00:00:00.000000000 +0900 +++ wf/wf_ex.c 2015-12-19 00:00:00.000000000 +0900 @@ -200,11 +200,16 @@ .ts = (double[]){1,1,1,1}, .dg = 3 }}, .data = &(data_t){ type_cube } }}; + data_t *cube3 = &(data_t){ type_op_data_set, &(struct op_data_set){ + .op = &(data_t){ type_copy_timeshift, &(struct copy_timeshift){ + .n = 3, .init_sec = 0, .step_sec = -0.3, .init = {0,0,0}, .step = {0,0,0} } }, + .data = cube2 }}; + data.type = type_arr; data.p = (data_t[]){ *axyz, *cross, - *cube, *cube2, + *cube, *cube3, { type_end } }; }