//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // void Note::SetEntry(const UnitQuaternion &value) { Check_Object(this); static char contents[32]; YawPitchRoll ypr(value); Verify(strlen(contents) < sizeof(contents)); sprintf( contents, "%f %f %f", ypr.yaw * Degrees_Per_Radian, ypr.pitch * Degrees_Per_Radian, ypr.roll * Degrees_Per_Radian ); SetEntry(contents); }
void jacTransform(MXD& J, const mtInput& input) const{ J.setZero(); rot::EulerAnglesYprPD ypr(input.template get<mtInput::_att>()); const double theta = ypr.pitch(); const double phi = ypr.roll(); const double t2 = cos(theta); const double t3 = 1.0/t2; const double t4 = cos(phi); const double t5 = sin(phi); const double t6 = sin(theta); J(0,0) = 0.0; J(0,1) = t3*t5; J(0,2) = t3*t4; J(1,0) = 0.0; J(1,1) = t4; J(1,2) = -t5; J(2,0) = 1.0; J(2,1) = t3*t5*t6; J(2,2) = t3*t4*t6; }
void MAIN(void) { Vector3D v(1 ,2 ,3); // from vector Vector3D w(0 , -1 , -4); // to vector double alpha ; Vector3D u; alpha = v.getAngle(w); // liefert winkel in rad u = v.cross (w).normalize(); AngleAxis u_phi(alpha, u); Quaternion q(u_phi); YPR ypr(q); PRINTF("Rotation q: "); q.print(); PRINTF("Rotation ypr: "); ypr.print(); PRINTF("----------- again --------------- \n"); q = Quaternion(cos(alpha/2), u.scale(sin(alpha/2))); ypr = YPR(q); PRINTF("Rotation q: "); q.print(); PRINTF("Rotation ypr: "); ypr.print(); }
int InternalScriptExports::CreateActor(const char* actorArchetype, LuaPlus::LuaObject luaPosition, LuaPlus::LuaObject luaYawPitchRoll) { if (!luaPosition.IsTable()) { GCC_ERROR("Invalid object passed to CreateActor(); type = " + std::string(luaPosition.TypeName())); return INVALID_ACTOR_ID; } if (!luaYawPitchRoll.IsTable()) { GCC_ERROR("Invalid object passed to CreateActor(); type = " + std::string(luaYawPitchRoll.TypeName())); return INVALID_ACTOR_ID; } Vec3 pos(luaPosition["x"].GetFloat(), luaPosition["y"].GetFloat(), luaPosition["z"].GetFloat()); Vec3 ypr(luaYawPitchRoll["x"].GetFloat(), luaYawPitchRoll["y"].GetFloat(), luaYawPitchRoll["z"].GetFloat()); Mat4x4 initialTransform; initialTransform.BuildYawPitchRoll(ypr.x, ypr.y, ypr.z); initialTransform.SetPosition(pos); TiXmlElement *overloads = NULL; StrongActorPtr pActor = g_pApp->m_pGame->VCreateActor(actorArchetype, overloads, &initialTransform); if (pActor) { shared_ptr<EvtData_New_Actor> pNewActorEvent(GCC_NEW EvtData_New_Actor(pActor->GetId())); IEventManager::Get()->VQueueEvent(pNewActorEvent); return pActor->GetId(); } return INVALID_ACTOR_ID; }