// ============================================================================================================================================== // void Orbit::Ecliptic() { if (EclipticPlane) return; EclipticPlane=true; Reset(); myy = 1.327e20; ecc = 0; sma = AU; rad = AU; inc = 0; lan = 0; agp = 0; tra = 0; par = sma; mna = 0; mnm = MeanMotion(); ang = sqrt(myy*par); lpe = 0; trl = 0; majv = _V(1,0,0); minv = _V(0,0,1); norv = _V(0,-1,0); Xmajv = majv * sma; Xminv = minv * sma; Xcv = _V(0,0,0); SetProjection(this); }
void Dragonfly::LoadState (FILEHANDLE scn, void *vs) { char *line; while (oapiReadScenario_nextline (scn, line)) { if (!strnicmp (line, "UPPERANT", 8)) { sscanf (line+8, "%f %f %i %i %i", &UP_pos ,&UY_pos,&UP_handle, &UY_handle,&UAnt_handle); } else if (!strnicmp (line, "LOWERANT", 8)) { sscanf (line+8, "%f %f %i %i %i", &LP_pos, &LY_pos,&LP_handle,&LY_handle,&LAnt_handle); //SetGearParameters (gear_proc); } else if (!strnicmp (line, "HATCH", 5)) { sscanf (line+5, "%f %i", &dock_latched, &latch_handle); } else if (!strnicmp (line, "ANTTRG", 6)) { Dock_target_object=oapiGetObjectByName(line+7); //sscanf (line+5, "%f %i", &dock_latched, &latch_handle); } else { ParseScenarioLineEx (line, vs); // unrecognised option - pass to Orbiter's generic parser } } SetAnimState (anim_UY_ant, UY_pos); float ang=(150-UY_pos*300.0)/180.0*acos(-1); Upper_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); SetAnimState (anim_UP_ant, UP_pos); SetAnimState (anim_LY_ant, LY_pos); ang=(150-LY_pos*300.0)/180.0*acos(-1); Lower_ant_pitch.trans.P.rotparam.axis=_V(cos(ang),0,-sin(ang)); SetAnimState (anim_LP_ant, LP_pos); SetAnimState (anim_latch, dock_latched); };
/*Construtor da camera*/ mCamera(float px, float py, float pz, float centerx,float centery, float centerz, float upx, float upy, float upz) { Matriz<4,1> _mp; _mp.setZero(); _mp(0,0) = px; _mp(1,0) = py; _mp(2,0) = pz; _mp(3,0) = 1; _p = _mp; _V.setZero(); _V(0,0) = upx; _V(1,0) = upy; _V(2,0) = upz; _V(3,0) = 1; _V = mat.normalizeVector3D(_V); _N.setZero(); _N(0,0) = centerx - px; _N(1,0) = centery - py; _N(2,0) = centerz - pz; _N = mat.normalizeVector3D(_N); _U = mat.normalizeVector3D(mat.crossProduct3D(_V,_N)); _V = mat.normalizeVector3D(mat.crossProduct3D(_U,_N)); tipo_de_projecao = 1; graus = 0.02f; }
void LEM::SeparateStage (UINT stage) { ResetThrusters(); VESSELSTATUS vs1; VECTOR3 ofs1 = _V(0,-5,0); VECTOR3 vel1 = _V(0,0,0); if (stage == 1) { GetStatus (vs1); vs1.eng_main = vs1.eng_hovr = 0.0; VECTOR3 rofs1, rvel1 = {vs1.rvel.x, vs1.rvel.y, vs1.rvel.z}; Local2Global (ofs1, vs1.rpos); GlobalRot (vel1, rofs1); vs1.rvel.x = rvel1.x+rofs1.x; vs1.rvel.y = rvel1.y+rofs1.y; vs1.rvel.z = rvel1.z+rofs1.z; vs1.vrot.x = 0.0; vs1.vrot.y = 0.0; vs1.vrot.z = 0.0; GetStatus (vs1); // Wrong sound, is Saturn staging // StageS.play(NOLOOP, 150); char VName[256]; strcpy (VName, GetName()); strcat (VName, "-DESCENTSTG"); hdsc = oapiCreateVessel(VName, "ProjectApollo/sat5LMDSC", vs1); SetLmAscentHoverStage(); } }
void h_Vent::ProcessShip(VESSEL *vessel,PROPELLANT_HANDLE ph) {ph_vent=ph; v=vessel; for (int i=0;i<Num_Vents;i++) { thg[i]=v->CreateThruster (_V(pos[i].x,pos[i].y,pos[i].z), _V(dir[i].x,dir[i].y,dir[i].z), 50, ph,50); v->AddExhaust (thg[i], size[i]*1000,size[i]*50); v->SetThrusterLevel(thg[i],1.0);}; };
void LVRG::Timestep(double simdt) { rates = _V(0,0,0); if (sat != NULL) { VECTOR3 orbiter_rates = _V(0,0,0); sat->GetAngularVel(orbiter_rates); // From those, generate ROTATION RATE data. rates.x = -orbiter_rates.z; rates.y = orbiter_rates.x; rates.z = -orbiter_rates.y; } }
TEST(FrSkySPORT, StrangeCellsBug) { TELEMETRY_RESET(); uint8_t pkt[] = { 0x7E, 0x48, 0x10, 0x00, 0x03, 0x30, 0x15, 0x50, 0x81, 0xD5 }; EXPECT_EQ(checkSportPacket(pkt+1), true); frskySportProcessPacket(pkt+1); EXPECT_EQ(frskyData.hub.cellsCount, 3); EXPECT_EQ(frskyData.hub.cellVolts[0], _V(000)); // now we ignore such low values EXPECT_EQ(frskyData.hub.cellVolts[1], _V(413)); }
void scoll_up(struct TTY_t *tty, uint8_t num) { cli(); int8_t x, y; for(y = num; y < TTY_HEIGHT; ++y) { for(x = 0; x < TTY_WIDTH; ++x) _V(x, y - num) = _V(x, y); } for(x = 0; x < TTY_WIDTH; ++x) _V(x, tty->cur_y) = 0x0700 | ' '; sti(); }
ADIBall::ADIBall (VESSEL3 *v, AttitudeReference *attref): PanelElement (v) { aref = attref; layout = 0; rho_curr = tht_curr = phi_curr = 0.0; tgtx_curr = tgty_curr = 0.0; ballvtx0 = 0; peuler = _V(0,0,0); vrot = _V(0,0,0); euler_t = 0; rate_local = true; }
// -------------------------------------------------------------- // Implement effects of radiation pressure // -------------------------------------------------------------- void SolarSail::clbkGetRadiationForce (const VECTOR3 &mflux, VECTOR3 &F, VECTOR3 &pos) { mf = mflux; // store flux value const double albedo = 2.0; // fully reflective const double area = SAIL_RADIUS*SAIL_RADIUS*PI; // The sail is oriented normal to the vessel z-axis. // Therefore only the z-component of the radiation momentum flux contributes // to change the sail's momentum (Fresnel reflection) double mom = mflux.z * albedo *area; F = _V(0,0,mom); pos = _V(0,0,0); // don't induce torque }
void LVIMU::Init() { Operate = false; TurnedOn = false; Initialized = false; Caged = false; ZeroIMUCDUFlag = false; CoarseAlignEnableFlag = false; RemainingPIPA.X = 0; RemainingPIPA.Y = 0; RemainingPIPA.Z = 0; Gimbal.X = 0; Gimbal.Y = 0; Gimbal.Z = 0; Orbiter.Attitude.X = 0; Orbiter.Attitude.Y = 0; Orbiter.Attitude.Z = 0; Orbiter.LastAttitude.X = 0; Orbiter.LastAttitude.Y = 0; Orbiter.LastAttitude.Z = 0; Orbiter.AttitudeReference.m11 = 0; Orbiter.AttitudeReference.m12 = 0; Orbiter.AttitudeReference.m13 = 0; Orbiter.AttitudeReference.m21 = 0; Orbiter.AttitudeReference.m22 = 0; Orbiter.AttitudeReference.m23 = 0; Orbiter.AttitudeReference.m31 = 0; Orbiter.AttitudeReference.m32 = 0; Orbiter.AttitudeReference.m33 = 0; LastWeightAcceleration = _V(0, 0, 0); LastGlobalVel = _V(0, 0, 0); OurVessel = 0; CDURegisters[LVRegCDUX]=0; CDURegisters[LVRegCDUY]=0; CDURegisters[LVRegCDUZ]=0; CDURegisters[LVRegPIPAX]=0; CDURegisters[LVRegPIPAY]=0; CDURegisters[LVRegPIPAZ]=0; ZeroIMUCDUs(); LastTime = -1; }
void find_post_variable_value_fluid(np_t *np, long l, gl_t *gl, long varnum, double *varvalue){ spec_t w,nu; double eta,kappa; *varvalue=0.0; if (is_node_valid(np[l],TYPELEVEL_FLUID)){ if (varnum<ns) *varvalue=_w(np[l],varnum); if (varnum>=ns && varnum<ns+nd) *varvalue=_V(np[l],varnum-ns); //assert(is_node_resumed(np[l])); find_w(np[l],w); find_nuk_eta_kappa(w, _rho(np[l]), _T(np[l],gl), nu, &eta, &kappa); switch (varnum) { case nd+ns+0: *varvalue=_rho(np[l]); break; case nd+ns+1: *varvalue=_P(np[l],gl); break; case nd+ns+2: *varvalue=_Pstar(np[l],gl); break; case nd+ns+3: *varvalue=_T(np[l],gl); break; case nd+ns+4: *varvalue=_Tv(np[l]); break; case nd+ns+5: *varvalue=_a(np[l],gl); break; case nd+ns+6: *varvalue=_eta(np[l],gl); break; case nd+ns+7: *varvalue=_etastar(np,l,gl); break; case nd+ns+8: *varvalue=_kappastar(np,l,gl); break; case nd+ns+9: *varvalue=_k(np[l]); break; case nd+ns+10: *varvalue=_eps(np[l],gl); break; case nd+ns+11: *varvalue=_omega(np[l],gl); break; case nd+ns+12: *varvalue=_gamma(np[l],gl); break; } } }
// ============================================================================================================================================== // void Orbit::CreateProjectionPlane(VECTOR3 normal, VECTOR3 zero) { Reset(); myy = 1.327e20; ecc = 0; sma = AU; rad = AU; inc = 0; lan = 0; agp = 0; tra = 0; par = sma; mna = 0; mnm = MeanMotion(); ang = sqrt(myy*par); lpe = 0; trl = 0; majv = unit(crossp(crossp(normal,zero),normal)); norv = unit(normal); minv = unit(crossp(norv,majv)); Xmajv = majv * sma; Xminv = minv * sma; Xcv = _V(0,0,0); SetProjection(this); }
AttitudeReference::AttitudeReference (const VESSEL *vessel) { v = vessel; projmode = 0; mode = 0; tgtmode = 0; navid = 0; valid_axes = false; valid_euler = false; valid_tgteuler = false; euler_offs = _V(0,0,0); tgt_offs = _V(0,0,0); tgt_rvel = _V(0,0,0); tgt_ppos = _V(0,0,0); tgt_ptime = 0; }
double AscentAP::GetTargetRollRate (double tgt, bool tgt_is_heading) const { double a, b, maxrate; if (tgt_is_heading) { // launch roll a = 0.60; b = 0.30; maxrate = 0.25; } else { // post launch roll a = 0.15; b = 0.075; maxrate = 0.15; } VECTOR3 avel, yh; vessel->GetAngularVel (avel); double dh, droll = avel.z; if (tgt_is_heading) { vessel->HorizonRot (_V(0,1,0), yh); double yhdg = atan2(yh.x, yh.z); dh = yhdg-tgt; if (dh > PI) dh -= PI2; else if (dh < -PI) dh += PI2; } else { double bank = vessel->GetBank(); dh = bank-tgt; if (dh >= PI) dh -= PI2; else if (dh < -PI) dh += PI2; } double rate = min (maxrate, max (-maxrate, a*dh + b*droll)); return rate; }
// Finish setup void Atlantis_SRB::clbkPostCreation () { // find out which side of the ET we are attached to OBJHANDLE hTank = GetDockStatus (GetDockHandle (0)); if (hTank) { for (UINT i = 1; i <= 2; i++) { OBJHANDLE hSRB = oapiGetDockStatus (oapiGetDockHandle (hTank, i)); if (hSRB == GetHandle()) { srbpos = (i == 1 ? SRB_LEFT : SRB_RIGHT); break; } } } if (srbpos != SRB_UNDEFINED) SetThrusterDir(th_bolt, srbpos == SRB_LEFT ? _V(-0.4,-0.9165,0) : _V(-0.4,0.9165,0)); }
inline VECTOR3 Nml (const NTVERTEX *v1, const NTVERTEX *v2, const NTVERTEX *v3) { float dx1 = v2->x - v1->x, dx2 = v3->x - v1->x; float dy1 = v2->y - v1->y, dy2 = v3->y - v1->y; float dz1 = v2->z - v1->z, dz2 = v3->z - v1->z; return _V(dy1*dz2 - dy2*dz1, dz1*dx2 - dz2*dx1, dx1*dy2 - dx2*dy1); }
static void update_bdry_outflow_Mach(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, int ACCURACY){ long spec,dim; spec_t rhok; double P, Mdes, Mextr; double V_temp, Vmag; dim_t V; bool ref_flag; assert_np(np[lA],is_node_resumed(np[lA])); /* Store desired Mach number (Mdes) at C */ V_temp=0.0; for (dim=0; dim<nd; dim++){ V_temp=V_temp+sqr(_V(np[lA],dim)); } Vmag=sqrt(V_temp); Mdes=Vmag/_a(np[lA],gl); /* Extrapolate Mach number (Mextr) at C from A and B */ P=_f_extrapol(ACCURACY,_P(np[lB],gl), _P(np[lC],gl)); for (spec=0; spec<ns; spec++){ rhok[spec]=_f_extrapol(ACCURACY,_rhok(np[lB],spec),_rhok(np[lC],spec)); } reformat_rhok(gl,rhok,"_bdry",&ref_flag); for (dim=0; dim<nd; dim++){ V[dim]=_f_extrapol(ACCURACY,_V(np[lB],dim),_V(np[lC],dim)); } find_U_3(np, lA, gl, rhok, V, P); V_temp=0.0; for (dim=0; dim<nd; dim++){ V_temp=V_temp+sqr(_V(np[lA],dim)); } Vmag = sqrt(V_temp); Mextr=Vmag/_a(np[lA],gl); /* Modify velocity components to give Mdes */ for (dim=0; dim<nd; dim++){ V[dim]=( _V(np[lA],dim)*Mdes/Mextr ); } find_U_3(np, lA, gl, rhok, V, P); }
void AscentAP::GetTargetDirection (double met, VECTOR3 &dir, double &tgt_hdg) const { tgt_hdg = tgt.az; double tgt_pitch = tgt.pitch; double xz = cos(tgt_pitch); vessel->HorizonInvRot(_V(xz*sin(tgt_hdg), sin(tgt_pitch), xz*cos(tgt_hdg)), dir); }
bool MfdSubsystem::clbkLoadVC (int vcid) { if (vcid != 0) return false; vctex = oapiGetTextureHandle (DG()->vcmesh_tpl, 20); const double xofs = (mfdid == MFD_LEFT ? -0.2684 : 0.0616); oapiVCRegisterArea (ELID_BTNROW, PANEL_REDRAW_MOUSE, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNROW, _V(0.0840+xofs, 1.0745, 7.2238), _V(0.1228+xofs, 1.0745, 7.2238), _V(0.0840+xofs, 1.0587, 7.2180), _V(0.1228+xofs, 1.0587, 7.2180)); oapiVCRegisterArea (ELID_BTNCOL[0], PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNCOL[0], _V(0+xofs, 1.2155, 7.2751), _V(0.0168+xofs, 1.2155, 7.2751), _V(0+xofs, 1.0963, 7.2317), _V(0.0168+xofs, 1.0963, 7.2317)); oapiVCRegisterArea (ELID_BTNCOL[1], PANEL_REDRAW_MOUSE|PANEL_REDRAW_USER, PANEL_MOUSE_LBDOWN|PANEL_MOUSE_LBUP|PANEL_MOUSE_LBPRESSED|PANEL_MOUSE_ONREPLAY); oapiVCSetAreaClickmode_Quadrilateral (ELID_BTNCOL[1], _V(0.1900+xofs, 1.2155, 7.2751), _V(0.2068+xofs, 1.2155, 7.2751), _V(0.1900+xofs, 1.0963, 7.2317), _V(0.2068+xofs, 1.0963, 7.2317)); return true; }
void LEM::SetLmLandedMesh() { ClearMeshes(); VECTOR3 mesh_dir=_V(-0.003,-0.03,0.004); UINT meshidx = AddMesh (hLMLanded, &mesh_dir); SetMeshVisibilityMode (meshidx, MESHVIS_VCEXTERNAL); Landed = true; }
void tty_clear(struct TTY_t *tty) { int8_t x, y; for(y = 0; y < TTY_HEIGHT; ++y) { for(x = 0; x < TTY_WIDTH; ++x) _V(x, y) = 0x0700; } tty_move_cursor(tty, 0, 0); }
// ============================================================================================================================================== // void Orbit::Reset() { LeoRef=NULL; GeoRef=NULL; EclipticPlane=false; displacement=_V(0,0,0); intersection=NULL; node_trl_o=NULL; SetTime(0); }
// -------------------------------------------------------------- // Constructor // -------------------------------------------------------------- SolarSail::SolarSail (OBJHANDLE hVessel, int flightmodel) : VESSEL3 (hVessel, flightmodel) { int i; hMesh = NULL; mf = _V(0,0,0); DefineAnimations(); for (i = 0; i < 4; i++) paddle_rot[i] = paddle_vis[i] = 0.5; }
static void update_bdry_back_pressure(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, int ACCURACY){ long spec,dim; spec_t rhok; double P; dim_t V; bool ref_flag; assert_np(np[lA],is_node_resumed(np[lA])); P=_P(np[lA],gl); for (spec=0; spec<ns; spec++){ rhok[spec]=_f_extrapol(ACCURACY,_rhok(np[lB],spec),_rhok(np[lC],spec)); } for (dim=0; dim<nd; dim++){ V[dim]=_f_extrapol(ACCURACY,_V(np[lB],dim),_V(np[lC],dim)); } reformat_rhok(gl,rhok,"_bdry",&ref_flag); find_U_3(np, lA, gl, rhok, V, P); }
void AscentAP::SetLaunchAzimuth (double azimuth) { launch_azimuth = azimuth; // current launch location in local planet frame VECTOR3 pos, equ, dir, nml, ne, nd; double lng, lat, rad; double slng, clng, slat, clat; double saz = sin(azimuth), caz = cos(azimuth); OBJHANDLE hRef = vessel->GetGravityRef(); vessel->GetGlobalPos(pos); oapiGlobalToLocal (hRef, &pos, &equ); oapiLocalToEqu (hRef, equ, &lng, &lat, &rad); slng = sin(lng), clng = cos(lng), slat = sin(lat), clat = cos(lat); normalise(equ); // unit radius vector // launch direction in local planet frame dir = _V(-clng*slat*caz - slng*saz, clat*caz, -slng*slat*caz + clng*saz); // normal of orbital plane in local planet frame nml = crossp(dir, equ); // normal of equator plane in local planet frame ne = _V(0,1,0); // direction of ascending node nd = unit (crossp(nml, ne)); // orbit inclination tgt.inc = acos(dotp(nml, ne)); // longitude of ascending node tgt.lan = atan2(nd.z, nd.x); // rotation matrix from equator plane to target orbit plane double sinc = sin(tgt.inc), cinc = cos(tgt.inc); double slan = sin(tgt.lan), clan = cos(tgt.lan); MATRIX3 R1 = _M(1,0,0, 0,cinc,sinc, 0,-sinc,cinc); MATRIX3 R2 = _M(clan,0,-slan, 0,1,0, slan,0,clan); tgt.R = mul(R2,R1); }
static void update_bdry_outflow(np_t *np, gl_t *gl, long lA, long lB, long lC, long theta, long thetasgn, bool BDRYDIRECFOUND, int ACCURACY){ double P,T; spec_t w; dim_t V; long spec,dim; bool ref_flag; assert_np(np[lA],is_node_resumed(np[lA])); P=_f_extrapol(ACCURACY,_P(np[lB],gl),_P(np[lC],gl)); T=_f_extrapol(ACCURACY,_T(np[lB],gl),_T(np[lC],gl)); for (spec=0; spec<ns; spec++){ w[spec]=_f_extrapol(ACCURACY,_w(np[lB],spec),_w(np[lC],spec)); } for (dim=0; dim<nd; dim++){ V[dim]=_f_extrapol(ACCURACY,_V(np[lB],dim),_V(np[lC],dim)); } reformat_w(gl,w,"_bdry",&ref_flag); find_U_2(np, lA, gl, w, V, P, T); }
void EVA::init () { GoDock1 = false; SetSize (3.5); SetEmptyMass (115); SetMaxFuelMass (10); SetFuelMass (10); SetISP(10000); SetMaxThrust (ENGINE_ATTITUDE, 5); SetEngineLevel(ENGINE_MAIN, 0.0); SetPMI (_V(5,5,5)); SetRotDrag (_V(0.7,0.7,1.2)); SetPitchMomentScale (0); SetBankMomentScale (0); SetLiftCoeffFunc (0); ClearMeshes(); ClearExhaustRefs(); ClearAttExhaustRefs(); VECTOR3 mesh_dir=_V(0,0,0); AddMesh (hCMPEVA, &mesh_dir); }
void RMANAGER::CreateResourceAndStreams(VOBJ * vbj) { if (!oapiIsVessel(vbj->hook)) return; VESSEL * vessel = oapiGetVesselInterface(vbj->hook); PROPELLANT_HANDLE hpr = vessel->CreatePropellantResource(1); vbj->th = vessel->CreateThruster(_V(0,0,0),vbj->dir,1e0,hpr,500000e50); for (int i = 0; i < vbj->streams.size(); i++) { vessel->AddExhaustStream(vbj->th,vbj->streams[i]->pos,vbj->streams[i]->stream); } }
void SetMMU (VESSEL *vessel) { VECTOR3 mesh_pos; // ============================================================== // These numbers are based off of the MS Space Simulator MMU vessel->SetSize (1.25); vessel->SetCOG_elev (0.75); vessel->SetEmptyMass (200.0); // vessel->SetMaxFuelMass (200.0); // vessel->SetFuelMass(200.0); // vessel->SetISP (350.0*9.8); // vessel->SetMaxThrust (ENGINE_MAIN, 31.5); // vessel->SetMaxThrust (ENGINE_RETRO, 31.5); // vessel->SetMaxThrust (ENGINE_HOVER, 0); // vessel->SetMaxThrust (ENGINE_ATTITUDE, 31.5); // ============================================================== vessel->SetPMI (_V(.35,.13,0.35)); vessel->SetCrossSections (_V(1.64,.77,1.64)); // ============================================================== vessel->SetCW (0.3, 0.3, .3, .3); vessel->SetRotDrag (_V(0.7,0.7,1.2)); vessel->SetPitchMomentScale (0); vessel->SetYawMomentScale (0); vessel->SetLiftCoeffFunc (0); vessel->SetDockParams (_V(0,0,.44), _V(0,0,1), _V(0,1,0)); // ============================================================== vessel->ClearMeshes(); vessel->ClearExhaustRefs(); vessel->ClearAttExhaustRefs(); vessel->ClearPropellantResources(); vessel->ClearThrusterDefinitions(); mesh_pos = _V(0,-0.24,0.16); vessel->AddMesh("mmu", &mesh_pos); AddAttitudeJets(vessel); vessel->SetDockParams(_V(0,0,0.5),_V(0,0,1),_V(0,1,0)); //vessel->SetDockParams(_V(0,0,0),_V(0,-1,0),_V(0,0,1)); //vessel->CreateDock(_V(0,0,0.22),_V(0,0,1),_V(0,1,0)); }