/*! Return the angular velocity at the specified time (TDB). The default * implementation computes the angular velocity via differentiation. */ Vector3d RotationModel::angularVelocityAtTime(double tdb) const { double dt = chooseDiffTimeDelta(*this); Quaterniond q0 = orientationAtTime(tdb); Quaterniond q1 = orientationAtTime(tdb + dt); Quaterniond dq = q1.conjugate() * q0; if (std::abs(dq.w()) > 0.99999999) return Vector3d::Zero(); return dq.vec().normalized() * (2.0 * acos(dq.w()) / dt); #ifdef CELVEC Vector3d v(dq.x, dq.y, dq.z); v.normalize(); return v * (2.0 * acos(dq.w) / dt); #endif }
Vector3d CachingRotationModel::computeAngularVelocity(double tjd) const { double dt = chooseDiffTimeDelta(*this); Quaterniond q0 = orientationAtTime(tjd); // Call computeSpin/computeEquatorOrientation instead of orientationAtTime // in order to avoid affecting the cache. Quaterniond spin = computeSpin(tjd + dt); Quaterniond equator = computeEquatorOrientation(tjd + dt); Quaterniond q1 = spin * equator; Quaterniond dq = q1.conjugate() * q0; if (std::abs(dq.w()) > 0.99999999) return Vector3d::Zero(); return dq.vec().normalized() * (2.0 * acos(dq.w()) / dt); #ifdef CELVEC Vec3d v(dq.x, dq.y, dq.z); v.normalize(); return v * (2.0 * acos(dq.w) / dt); #endif }