private bool setSphericalReflectanceUsingFrame(AgAsLightReflectionResultEval ResultEval, double cr, AgEUtFrame frame) { double reflectanceMag; Tuple3 incidentVec = new Tuple3(); ResultEval.IncidentDirection((AgEUtFrame)frame, ref incidentVec.x, ref incidentVec.y, ref incidentVec.z); // reflectance is positive along the incident direction incidentVec.scaleBy(m_SRPArea); if (m_CrIndex > -1) { ResultEval.SetReflectanceParamPartials(m_CrIndex, frame, incidentVec.x, incidentVec.y, incidentVec.z); } incidentVec.scaleBy(cr); ResultEval.SetReflectance((AgEUtFrame)frame, incidentVec.x, incidentVec.y, incidentVec.z); double[,] incidentDirPosPartials, posPartials; incidentDirPosPartials = new double[3, 3]; posPartials = new double[3, 3]; ResultEval.IncidentDirectionCompPosPartials((AgEUtFrame)frame, ref incidentDirPosPartials[0, 0], ref incidentDirPosPartials[0, 1], ref incidentDirPosPartials[0, 2], ref incidentDirPosPartials[1, 0], ref incidentDirPosPartials[1, 1], ref incidentDirPosPartials[1, 2], ref incidentDirPosPartials[2, 0], ref incidentDirPosPartials[2, 1], ref incidentDirPosPartials[2, 2]); reflectanceMag = cr * m_SRPArea; posPartials[0, 0] = reflectanceMag * incidentDirPosPartials[0, 0]; posPartials[0, 1] = reflectanceMag * incidentDirPosPartials[0, 1]; posPartials[0, 2] = reflectanceMag * incidentDirPosPartials[0, 2]; posPartials[1, 0] = reflectanceMag * incidentDirPosPartials[1, 0]; posPartials[1, 1] = reflectanceMag * incidentDirPosPartials[1, 1]; posPartials[1, 2] = reflectanceMag * incidentDirPosPartials[1, 2]; posPartials[2, 0] = reflectanceMag * incidentDirPosPartials[2, 0]; posPartials[2, 1] = reflectanceMag * incidentDirPosPartials[2, 1]; posPartials[2, 2] = reflectanceMag * incidentDirPosPartials[2, 2]; ResultEval.SetReflectanceCompPosPartials((AgEUtFrame)frame, posPartials[0, 0], posPartials[0, 1], posPartials[0, 2], posPartials[1, 0], posPartials[1, 1], posPartials[1, 2], posPartials[2, 0], posPartials[2, 1], posPartials[2, 2]); // VelPartials are zero in inertial - we'll set this anyway to test it bool doVelPartials = true; if (doVelPartials) { double[,] incidentDirVelPartials, velPartials; incidentDirVelPartials = new double[3, 3]; velPartials = new double[3, 3];; ResultEval.IncidentDirectionCompVelPartials((AgEUtFrame)frame, ref incidentDirVelPartials[0, 0], ref incidentDirVelPartials[0, 1], ref incidentDirVelPartials[0, 2], ref incidentDirVelPartials[1, 0], ref incidentDirVelPartials[1, 1], ref incidentDirVelPartials[1, 2], ref incidentDirVelPartials[2, 0], ref incidentDirVelPartials[2, 1], ref incidentDirVelPartials[2, 2]); velPartials[0, 0] = reflectanceMag * incidentDirVelPartials[0, 0]; velPartials[0, 1] = reflectanceMag * incidentDirVelPartials[0, 1]; velPartials[0, 2] = reflectanceMag * incidentDirVelPartials[0, 2]; velPartials[1, 0] = reflectanceMag * incidentDirVelPartials[1, 0]; velPartials[1, 1] = reflectanceMag * incidentDirVelPartials[1, 1]; velPartials[1, 2] = reflectanceMag * incidentDirVelPartials[1, 2]; velPartials[2, 0] = reflectanceMag * incidentDirVelPartials[2, 0]; velPartials[2, 1] = reflectanceMag * incidentDirVelPartials[2, 1]; velPartials[2, 2] = reflectanceMag * incidentDirVelPartials[2, 2]; ResultEval.SetReflectanceCompVelPartials((AgEUtFrame)frame, velPartials[0, 0], velPartials[0, 1], velPartials[0, 2], velPartials[1, 0], velPartials[1, 1], velPartials[1, 2], velPartials[2, 0], velPartials[2, 1], velPartials[2, 2]); } Debug.WriteLine(m_MsgCntr + " " + cr + " : frame = Body : (" + incidentVec.x + "," + incidentVec.y + "," + incidentVec.z + ")"); return(true); }
public bool PostEvaluate(IAgAsHpopPluginResultPostEval ResultEval) { try { if (this.m_PostEvalCntr % this.m_PostEvalMsgInterval == 0) { Debug.WriteLine("--> Entered", this.m_Name + ".PostEvaluate( " + this.m_PostEvalCntr + " )"); } this.m_PostEvalCntr++; if (this.m_UPS != null) { if (this.m_Enabled) { if (this.m_MsgStatus) { if (this.m_PostEvalCntr % this.m_PostEvalMsgInterval == 0) { AgEUtFrame reportFrame = AgEUtFrame.eUtFrameNTC; string frameName = "NTC"; AgEAccelType accelType = AgEAccelType.eSRPAccel; double srpX = 0.0, srpY = 0.0, srpZ = 0.0, AltInKm; AltInKm = ResultEval.Altitude * 0.001; this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".PostEvaluate( " + this.m_PostEvalCntr + " ): SRPArea (" + ResultEval.SRPArea + " m^2), Altitude (" + AltInKm + " km)"); ResultEval.GetAcceleration(accelType, reportFrame, ref srpX, ref srpY, ref srpZ); this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".PostEvaluate( " + this.m_PostEvalCntr + " ): SRPAccel (" + frameName + ") is (" + srpX + ", " + srpY + ", " + srpZ + ") meters/secs^2"); // report out the added acceleration in NTC components double thrustX = 0.0, thrustY = 0.0, thrustZ = 0.0; accelType = AgEAccelType.eAddedAccel; ResultEval.GetAcceleration(accelType, reportFrame, ref thrustX, ref thrustY, ref thrustZ); this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".PostEvaluate( " + this.m_PostEvalCntr + " ): ThrustAccel (" + frameName + ") is (" + thrustX + ", " + thrustY + ", " + thrustZ + ") meters/secs^2"); } } } else { if (this.m_MsgStatus) { this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgDebug, this.m_Name + ".PostEvaluate(): Disabled"); } } } else { throw new Exception("UtPluginSite was null"); } } catch (Exception ex) { this.m_Enabled = false; if (this.m_UPS != null) { this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".PostEvaluate(): Exception Message( " + ex.Message + " )"); this.m_UPS.Message(AgEUtLogMsgType.eUtLogMsgAlarm, this.m_Name + ".PostEvaluate(): Exception StackTr( " + ex.StackTrace + " )"); } Debug.WriteLine("Exception Message( " + ex.Message + " )", this.m_Name + ".PostEvaluate()"); Debug.WriteLine("Exception StackTr( " + ex.StackTrace + " )", this.m_Name + ".PostEvaluate()"); } finally { if (this.m_PostEvalCntr % this.m_PostEvalMsgInterval == 0) { Debug.WriteLine("<-- Exited", this.m_Name + ".PostEvaluate( " + this.m_PostEvalCntr + " )"); } } return(this.m_Enabled); }