public bool Evaluate( AgAccessConstraintPluginResultEval Result, AgAccessConstraintPluginObjectData baseObj, AgAccessConstraintPluginObjectData targetObj) { if (Result != null) { Result.Value = 0.0; if (baseObj != null) { double range = baseObj.Range( AGI.Access.Constraint.Plugin.AgEAccessApparentPositionType.eProperApparentPosition); double detectability = -1.0, relX = 0.0, relY = 0.0, relZ = 0.0; baseObj.RelativePosition( AGI.Access.Constraint.Plugin.AgEAccessApparentPositionType.eProperApparentPosition, AGI.Plugin.AgEUtFrame.eUtFrameFixed, ref relX, ref relY, ref relZ); bool usePosToComputeImageDetection = true; AgAccessConstraintPluginObjectDescriptor baseDesc = baseObj.Descriptor; string basePath = baseDesc.ObjectPath; if (basePath != "" && m_AxesHash.ContainsKey(basePath)) { AgCrdnConfiguredAxes topoAxes = (AgCrdnConfiguredAxes)m_AxesHash[basePath]; if (topoAxes != null) { topoAxes.TransformComponents(baseObj, ref relX, ref relY, ref relZ); double sinElev = relZ / range; detectability = computeDetectability(range, sinElev, m_size); usePosToComputeImageDetection = false; } } if (usePosToComputeImageDetection) { // will only work with Facility/Targets on Earth double x = 0.0, y = 0.0, z = 0.0; baseObj.Position(AGI.Plugin.AgEUtFrame.eUtFrameFixed, ref x, ref y, ref z); detectability = computeImageDetectionFromPos(range, x, y, z, relX, relY, relZ); } Result.Value = detectability; } } return(true); }
public bool Evaluate( AgAccessConstraintPluginResultEval Result, AgAccessConstraintPluginObjectData baseObj, AgAccessConstraintPluginObjectData targetObj) { if (Result != null) { Result.Value = 0.0; if (baseObj != null) { // Get teh grid point location double lat = 0, lon = 0, alt = 0; baseObj.LatLonAlt(ref lat, ref lon, ref alt); // convert from Rad to Deg lat = lat * 180.0 / Math.PI; lon = lon * 180.0 / Math.PI; //Capture as a string for the lookuptable string ID = lat.ToString("f3") + "," + lon.ToString("f3"); // Check to see if this location is already in teh lookup table if (s_cataloguedValues.ContainsKey(ID)) { // if it is, get the value and return Result.Value = s_cataloguedValues[ID]; return(true); } // if we havent found the closest point yet, check the external data var topFour = s_externalValues.AsParallel().Where(v => v.Value != -9999).OrderBy(v => Math.Sqrt(Math.Pow(lat - v.Latitude, 2) + Math.Pow(lon - v.Longitude, 2))).Take(4); var sum = topFour.Sum(v => v.Value / Math.Sqrt(Math.Pow(lat - v.Latitude, 2) + Math.Pow(lon - v.Longitude, 2))); var denominator = topFour.Sum(v => 1 / Math.Sqrt(Math.Pow(lat - v.Latitude, 2) + Math.Pow(lon - v.Longitude, 2))); var weightedGridValue = sum / denominator; // Return the value of the closest point in the external data set Result.Value = weightedGridValue; // store the value of the clsoest point in a lookup for quicker retrieval next time s_cataloguedValues.Add(ID, weightedGridValue); } } return(true); }
public bool Evaluate( AgAccessConstraintPluginResultEval Result, AgAccessConstraintPluginObjectData baseObj, AgAccessConstraintPluginObjectData targetObj) { if (Result != null) { Result.Value = 0.0; if (baseObj != null) { // Get the Relative position between objects Array targetRelPositionArray = baseObj.RelativePosition_Array(AgEAccessApparentPositionType.eProperApparentPosition, AgEUtFrame.eUtFrameFixed); var targetRelPositionList = targetRelPositionArray.Cast <double>().ToList(); // Capture the relative sun vector form the observer Array sunPositionArray = baseObj.ApparentSunPosition_Array(AgEUtFrame.eUtFrameFixed); var sunPositionList = sunPositionArray.Cast <double>().ToList(); //Instantiate the external model ThePayload payload = new ThePayload { TargetCrossSection_SqMeters = TargetCrossSectionSqMeters }; // Execute some portion of the external model at the current evaluation step // with the mission information pulled from the scenario var detectability = payload.ComputeTargetDetectionProbability( targetRelPositionList[0], targetRelPositionList[1], targetRelPositionList[2], sunPositionList[0], sunPositionList[1], sunPositionList[2]); if (m_Site != null && m_DebugMode) { Message(AgEUtLogMsgType.eUtLogMsgInfo, m_DisplayName + " Detectability value: " + detectability.ToString()); } Result.Value = Math.Min(detectability, 100); } } return(true); }
public bool Evaluate( AgAccessConstraintPluginResultEval Result, AgAccessConstraintPluginObjectData fromObject, AgAccessConstraintPluginObjectData toObject) { if (Result != null) { var satToSun = new double[] { 0, 0, 0 }; var satToFac = new double[] { 0, 0, 0 }; toObject.ApparentSunPosition(AgEUtFrame.eUtFrameFixed, ref satToSun[0], ref satToSun[1], ref satToSun[2]); toObject.RelativePosition(AgEAccessApparentPositionType.eLightPathApparentPosition, AgEUtFrame.eUtFrameFixed, ref satToFac[0], ref satToFac[1], ref satToFac[2]); if (useEquatorialAngle) { satToFac[2] = 0; satToSun[2] = 0; } Result.Value = AngleBetween(satToSun, satToFac); } return(true); }