void view_turn(view *V, const double *w) { #if 0 double M[16], T[16], q[4], a[3], b[3], c[3], t[3]; assert(V); /* Transform the mark and drag vectors from eye space into the world */ /* space current at the time of the mark. */ state_matrix(M, &V->mark); mtranspose(T, M); vnormalize(t, V->a); vtransform(a, T, t); vnormalize(t, w); vtransform(b, T, t); /* These determine the axis and angle of rotation. Find the quaternion. */ vcrs(t, a, b); vnormalize(c, t); qrotate(q, c, acos(vdot(a, b))); /* Accumulate this quaternion with the view state, rotating the view. */ qmultiply(view_curr(V)->q, V->mark.q, q); #endif }
void sph_model::zoom(double *w, const double *v) { double d = vdot(v, zoomv); if (-1 < d && d < 1) { double b = scale(zoomk, acos(d) / M_PI) * M_PI; double y[3]; double x[3]; vcrs(y, v, zoomv); vnormalize(y, y); vcrs(x, zoomv, y); vnormalize(x, x); vmul(w, zoomv, cos(b)); vmad(w, w, x, sin(b)); } else vcpy(w, v); }