Skip to content

Commit

Permalink
Merge pull request #1289 from indy91/VECPOINT
Browse files Browse the repository at this point in the history
RTCC MFD: Improve VECPOINT display
  • Loading branch information
indy91 authored Aug 10, 2024
2 parents 968b6ee + f8a6522 commit 9bcc9d6
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 67 deletions.
89 changes: 53 additions & 36 deletions Orbitersdk/samples/ProjectApollo/src_rtccmfd/ARCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ ARCore::ARCore(VESSEL* v, AR_GCore* gcin)
VECdirection = 0;
VECbody = NULL;
VECangles = _V(0, 0, 0);
VECBodyVector = _V(0, 0, 0);

TPI_Mode = 0;
dt_TPI_sunrise = 16.0*60.0;
Expand Down Expand Up @@ -2435,56 +2436,72 @@ void ARCore::VecPointCalc(bool IsCSM)

if (v == NULL) return;

VECTOR3 vPos, pPos, relvec, UX, UY, UZ, loc;
MATRIX3 M, M_R;
double p_T, y_T;
OBJHANDLE gravref = GC->rtcc->AGCGravityRef(v);

p_T = 0;
y_T = 0;
EphemerisData sv;
MATRIX3 MAT, REFSMMAT;
VECTOR3 POINTVSM, vPos, pPos, dPos, U_LOS, UNITY, SCAXIS, UTSA, UTSB, UTSAP, UTSBP;
double UTPIT, UTYAW, OMICRON;

if (VECdirection == 1)
{
p_T = PI;
y_T = 0;
}
else if (VECdirection == 2)
{
p_T = 0;
y_T = PI05;
}
else if (VECdirection == 3)
if (IsCSM)
{
p_T = 0;
y_T = -PI05;
REFSMMAT = GC->rtcc->EZJGMTX1.data[0].REFSMMAT;
}
else if (VECdirection == 4)
else
{
p_T = -PI05;
y_T = 0;
REFSMMAT = GC->rtcc->EZJGMTX3.data[0].REFSMMAT;
}
else if (VECdirection == 5)

switch (VECdirection)
{
p_T = PI05;
y_T = 0;
case 0: //+X
UTYAW = 0;
UTPIT = 0;
break;
case 1: //-X
UTYAW = 0;
UTPIT = PI;
break;
case 2: //Optics
UTYAW = 0;
UTPIT = -(PI05 - 0.5676353234);
break;
case 3: //SIM Bay
UTYAW = PI05;
UTPIT = 52.25*RAD;
break;
default: //Selectable
UTYAW = VECBodyVector.x;
UTPIT = VECBodyVector.y;
break;
}

//State vector used in calculation
sv = GC->rtcc->StateVectorCalcEphem(v);
POINTVSM = unit(crossp(sv.V, sv.R));

//Pointing vector
v->GetGlobalPos(vPos);
oapiGetGlobalPos(VECbody, &pPos);
v->GetRelativePos(gravref, loc);
dPos = pPos - vPos;
dPos = mul(GC->rtcc->SystemParameters.MAT_J2000_BRCS, _V(dPos.x, dPos.z, dPos.y));
U_LOS = unit(dPos);

//Artemis calculations
OMICRON = VECBodyVector.z;
UNITY = _V(0, 1, 0);
SCAXIS = _V(cos(UTYAW)*cos(UTPIT), sin(UTYAW)*cos(UTPIT), -sin(UTPIT));

relvec = unit(pPos - vPos);
relvec = mul(GC->rtcc->SystemParameters.MAT_J2000_BRCS, _V(relvec.x, relvec.z, relvec.y));
loc = mul(GC->rtcc->SystemParameters.MAT_J2000_BRCS, _V(loc.x, loc.z, loc.y));
UTSAP = crossp(SCAXIS, UNITY);
if (length(UTSAP) == 0.0) return;
UTSAP = unit(UTSAP);

UX = relvec;
UY = unit(crossp(UX, -loc));
UZ = unit(crossp(UX, crossp(UX, -loc)));
POINTVSM = unit(crossp(U_LOS, POINTVSM));

M_R = _M(UX.x, UX.y, UX.z, UY.x, UY.y, UY.z, UZ.x, UZ.y, UZ.z);
M = _M(cos(y_T)*cos(p_T), sin(y_T), -cos(y_T)*sin(p_T), -sin(y_T)*cos(p_T), cos(y_T), sin(y_T)*sin(p_T), sin(p_T), 0.0, cos(p_T));
UTSA = POINTVSM * cos(OMICRON) + unit(crossp(U_LOS, POINTVSM))*sin(OMICRON);
UTSB = U_LOS;
UTSBP = SCAXIS;

VECangles = OrbMech::CALCGAR(GC->rtcc->EZJGMTX1.data[0].REFSMMAT, mul(OrbMech::tmat(M), M_R));
MAT = OrbMech::AXISGEN(UTSAP, UTSBP, UTSA, UTSB);
VECangles = OrbMech::CALCGAR(REFSMMAT, MAT);
}
else if (VECoption == 1)
{
Expand Down
3 changes: 2 additions & 1 deletion Orbitersdk/samples/ProjectApollo/src_rtccmfd/ARCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ class ARCore {

//VECPOINT PAGE
int VECoption; //0 = Point SC at body, 1 = Open hatch thermal control
int VECdirection; //0 = +X, 1 = -X, 2 = +Y,3 = -Y,4 = +Z, 5 = -Z
int VECdirection; //0 = +X, 1 = -X, 2 = Optics, 3 = SIM Bay, 4 = Selectable
VECTOR3 VECBodyVector; //Yaw, pitch for option 7 and Omicron
OBJHANDLE VECbody; //handle for the desired body
VECTOR3 VECangles; //IMU angles

Expand Down
19 changes: 16 additions & 3 deletions Orbitersdk/samples/ProjectApollo/src_rtccmfd/ApolloRTCCMFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6395,7 +6395,7 @@ void ApolloRTCCMFD::TwoImpulseOffset()

void ApolloRTCCMFD::cycleVECDirOpt()
{
if (G->VECdirection < 5)
if (G->VECdirection < 4)
{
G->VECdirection++;
}
Expand All @@ -6405,6 +6405,19 @@ void ApolloRTCCMFD::cycleVECDirOpt()
}
}

void ApolloRTCCMFD::menuVECPOINTSelectAttitude()
{
if (G->VECdirection == 4)
{
GenericDouble2Input(&G->VECBodyVector.x, &G->VECBodyVector.y, "Select body yaw and pitch:", RAD, RAD);
}
}

void ApolloRTCCMFD::menuVECPOINTOmicron()
{
GenericDoubleInput(&G->VECBodyVector.z, "Select omicron (SEF = 180, BEF = 0):", RAD);
}

void ApolloRTCCMFD::cycleVECPOINTOpt()
{
if (G->VECoption < 1)
Expand All @@ -6425,9 +6438,9 @@ void ApolloRTCCMFD::vecbodydialogue()

bool VECbodyInput(void *id, char *str, void *data)
{
if (oapiGetGbodyByName(str) != NULL)
if (oapiGetObjectByName(str) != NULL)
{
((ApolloRTCCMFD*)data)->set_vecbody(oapiGetGbodyByName(str));
((ApolloRTCCMFD*)data)->set_vecbody(oapiGetObjectByName(str));
return true;
}
return false;
Expand Down
2 changes: 2 additions & 0 deletions Orbitersdk/samples/ProjectApollo/src_rtccmfd/ApolloRTCCMFD.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ class ApolloRTCCMFD: public MFD2 {
void cycleVECDirOpt();
void vecbodydialogue();
void set_vecbody(OBJHANDLE body);
void menuVECPOINTSelectAttitude();
void menuVECPOINTOmicron();
void menuVECPOINTCalc();
void menuSetLDPPVectorTime();
void menuLSRadius();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1821,30 +1821,30 @@ bool ApolloRTCCMFD::Update(oapi::Sketchpad *skp)
skp->Text(1 * W / 16, 6 * H / 14, Buffer, strlen(Buffer));
}

if (G->VECdirection == 0)
switch (G->VECdirection)
{
case 0:
skp->Text(1 * W / 16, 8 * H / 14, "+X", 2);
}
else if (G->VECdirection == 1)
{
break;
case 1:
skp->Text(1 * W / 16, 8 * H / 14, "-X", 2);
break;
case 2:
skp->Text(1 * W / 16, 8 * H / 14, "Optics", 6);
break;
case 3:
skp->Text(1 * W / 16, 8 * H / 14, "SIM Bay", 7);
break;
default:
skp->Text(1 * W / 16, 8 * H / 14, "Selectable", 10);
sprintf(Buffer, "Y: %+07.2lf�", G->VECBodyVector.x*DEG);
skp->Text(1 * W / 16, 10 * H / 14, Buffer, strlen(Buffer));
sprintf(Buffer, "P: %+07.2lf�", G->VECBodyVector.y*DEG);
skp->Text(1 * W / 16, 11 * H / 14, Buffer, strlen(Buffer));
break;
}
else if (G->VECdirection == 2)
{
skp->Text(1 * W / 16, 8 * H / 14, "+Y", 2);
}
else if (G->VECdirection == 3)
{
skp->Text(1 * W / 16, 8 * H / 14, "-Y", 2);
}
else if (G->VECdirection == 4)
{
skp->Text(1 * W / 16, 8 * H / 14, "+Z", 2);
}
else if (G->VECdirection == 5)
{
skp->Text(1 * W / 16, 8 * H / 14, "-Z", 2);
}
sprintf(Buffer, "O: %+07.2lf�", G->VECBodyVector.z*DEG);
skp->Text(1 * W / 16, 12 * H / 14, Buffer, strlen(Buffer));
}

sprintf(Buffer, "%+07.2f R", G->VECangles.x*DEG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -517,11 +517,11 @@ ApolloRTCCMFDButtons::ApolloRTCCMFDButtons()
static const MFDBUTTONMENU mnu15[] =
{
{ "CSM or LM", 0, 'P' },
{ "Pointing body", 0, 'P' },
{ "Object to point at", 0, 'P' },
{ "Vessel axis", 0, 'D' },
{ "", 0, ' ' },
{ "", 0, ' ' },
{ "", 0, ' ' },
{ "Choose the direction", 0, 'D' },
{ "Choose pitch and yaw", 0, 'E' },
{ "Choose omicron angle", 0, 'F' },

{ "Select Vessel", 0, 'T' },
{ "Calculate attitude", 0, 'C' },
Expand All @@ -535,10 +535,10 @@ ApolloRTCCMFDButtons::ApolloRTCCMFDButtons()

RegisterFunction("VES", OAPI_KEY_P, &ApolloRTCCMFD::CycleCSMOrLMSelection);
RegisterFunction("OPT", OAPI_KEY_G, &ApolloRTCCMFD::cycleVECPOINTOpt);
RegisterFunction("BOD", OAPI_KEY_P, &ApolloRTCCMFD::vecbodydialogue);
RegisterFunction("OBJ", OAPI_KEY_P, &ApolloRTCCMFD::vecbodydialogue);
RegisterFunction("DIR", OAPI_KEY_D, &ApolloRTCCMFD::cycleVECDirOpt);
RegisterFunction("", OAPI_KEY_E, &ApolloRTCCMFD::menuVoid);
RegisterFunction("", OAPI_KEY_F, &ApolloRTCCMFD::menuVoid);
RegisterFunction("PY", OAPI_KEY_E, &ApolloRTCCMFD::menuVECPOINTSelectAttitude);
RegisterFunction("OMI", OAPI_KEY_F, &ApolloRTCCMFD::menuVECPOINTOmicron);

RegisterFunction("SEL", OAPI_KEY_T, &ApolloRTCCMFD::set_Vessel);
RegisterFunction("CLC", OAPI_KEY_C, &ApolloRTCCMFD::menuVECPOINTCalc);
Expand Down

0 comments on commit 9bcc9d6

Please sign in to comment.