public Target(String name, TargetType type, DynamicState dynamicState, int value) { Name = name; Type = type; DynamicState = dynamicState; Value = value; }
/// <summary> /// Creates a new target from the xmlNode data /// </summary> /// <param name="targetXmlNode"></param> public Target(XmlNode targetXmlNode) { Name = targetXmlNode.Attributes["TargetName"].Value; string typeString = targetXmlNode.Attributes["TargetType"].Value.ToString(); Type = (TargetType)Enum.Parse(typeof(TargetType), typeString); DynamicState = new DynamicState(targetXmlNode.ChildNodes.Item(0)); Value = Convert.ToInt32(targetXmlNode.Attributes["Value"].Value); }
}//End getEarthSunVec method /** * Casts a shadow on the specified Position. * Computes whether the position matrix given is located in the shadow of * the Earth, and it determines which shadow: the Penumbra or Umbra. This * function calls the getEarSunVec function to retrieve the Earth-Sun vector. * Code from "Fundamentals of Astrodynamics and Applications" * @param time the simulation time that the shadow determination is requested * @returns UMBRA, PENUMBRA, or NO_SHADOW depending on the case. */ shadow_state castShadowOnPos(DynamicState pos, double simTime) { double penVert; double satHoriz; double satVert; double sigma; double umbVert; shadow_state shadow; const double alphaPen = 0.26900424; const double alphaUmb = 0.26411888; const double rad = Math.PI / 180; const double rEar = 6378.137; // Get earth-sun vector Matrix <double> rSun = getEarSunVec(simTime); // Get the vector from the earth to the object Matrix <double> assetPosAtTime = pos.PositionECI(simTime); //TODO: this method is not yet implemented double dot_p = Matrix <double> .Dot((-rSun), assetPosAtTime); // Calculate the cosine of the angle between the position vector // and the axis the earth-sun vector lies on double arg = (dot_p) / (Matrix <double> .Norm(-rSun) * Matrix <double> .Norm(assetPosAtTime)); //fix argument, must be between -1 and 1 if (Math.Abs(arg) > 1) { arg = arg / Math.Abs(arg) * Math.Floor(Math.Abs(arg)); } sigma = Math.Acos(arg); // Calculate the distance from the satHoriz = Matrix <double> .Norm(assetPosAtTime) * Math.Cos(sigma); satVert = Matrix <double> .Norm(assetPosAtTime) * Math.Sin(sigma); // Calculate distance away from earth-sun axis where penumbra ends penVert = rEar + Math.Tan(alphaPen * rad) * satHoriz; // determine the shadow state of the position if (dot_p > 0 && satVert <= penVert) { shadow = shadow_state.PENUMBRA; //Calculate distance away from earth-sun axis where umbra ends umbVert = rEar - Math.Tan(alphaUmb * rad) * satHoriz; if (satVert <= umbVert) { shadow = shadow_state.UMBRA; } } else { shadow = shadow_state.NO_SHADOW; } return(shadow); } //End castShadowOnPos method
public Asset(XmlNode assetXMLNode) { if (assetXMLNode.Attributes["assetName"] != null) Name = assetXMLNode.Attributes["assetName"].Value.ToString().ToLower(); else throw new MissingMemberException("Missing name for Asset!"); if (assetXMLNode["DynamicState"] != null) AssetDynamicState = new DynamicState(assetXMLNode["DynamicState"]); IsTaskable = false; }
public void PositionECIUnitTest() { StateSpaceEOMS msd = new StateSpaceEOMS(); var initialConditions = new Matrix<double>(); DynamicState dynamicState = new DynamicState(DynamicStateType.PREDETERMINED_ECI, msd, initialConditions); }
/// <summary> /// Calculate the solar panel power in over the time of the task /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="state"></param> /// <param name="position"></param> /// <param name="universe"></param> /// <returns></returns> protected HSFProfile<double> CalcSolarPanelPowerProfile(double start, double end, SystemState state, DynamicState position, Universe universe) { // create solar panel profile for this event double freq = 5; ShadowState lastShadow = universe.Sun.castShadowOnPos(position, start); HSFProfile<double> solarPanelPowerProfile = new HSFProfile<double>(start, GetSolarPanelPower(lastShadow)); for (double time = start + freq; time <= end; time += freq) { ShadowState shadow = universe.Sun.castShadowOnPos(position, time); // if the shadow state changes during this step, save the power data if (shadow != lastShadow) { solarPanelPowerProfile[time] = GetSolarPanelPower(shadow); lastShadow = shadow; } } state.AddValue(POWIN_KEY, solarPanelPowerProfile); return solarPanelPowerProfile; }
}//End getEarthSunVec method /// <summary> /// Casts a shadow on the specified Position. Computes whether the position matrix given is located in the shadow of /// the Earth, and it determines which shadow: the Penumbra or Umbra.This /// function calls the getEarSunVec function to retrieve the Earth-Sun vector. /// Code from "Fundamentals of Astrodynamics and Applications" /// </summary> /// <param name="pos">position of the asset</param> /// <param name="simTime">the simulation time that the shadow determination is requested</param> /// <returns> UMBRA, PENUMBRA, or NO_SHADOW depending on the case</returns> public ShadowState castShadowOnPos(DynamicState pos, double simTime) { double penVert; double satHoriz; double satVert; double sigma; double umbVert; ShadowState shadow; const double alphaPen = 0.26900424; const double alphaUmb = 0.26411888; const double rad = Math.PI / 180; const double rEar = 6378.137; // Get earth-sun vector Matrix<double> rSun = getEarSunVec(simTime); // Get the vector from the earth to the object Matrix<double> assetPosAtTime = pos.PositionECI(simTime); //TODO: this method is not yet implemented double dot_p = Matrix<double>.Dot((-rSun), assetPosAtTime); // Calculate the cosine of the angle between the position vector // and the axis the earth-sun vector lies on double arg = (dot_p) / (Matrix<double>.Norm(-rSun) * Matrix<double>.Norm(assetPosAtTime)); //fix argument, must be between -1 and 1 if(Math.Abs(arg) > 1) arg = arg/Math.Abs(arg)*Math.Floor(Math.Abs(arg)); sigma = Math.Acos(arg); // Calculate the distance from the satHoriz = Matrix<double>.Norm(assetPosAtTime)*Math.Cos(sigma); satVert = Matrix<double>.Norm(assetPosAtTime)*Math.Sin(sigma); // Calculate distance away from earth-sun axis where penumbra ends penVert = rEar + Math.Tan(alphaPen* rad)*satHoriz; // determine the shadow state of the position if (dot_p > 0 && satVert <= penVert) { shadow = ShadowState.PENUMBRA; //Calculate distance away from earth-sun axis where umbra ends umbVert = rEar - Math.Tan(alphaUmb * rad) * satHoriz; if (satVert <= umbVert) shadow = ShadowState.UMBRA; } else shadow = ShadowState.NO_SHADOW; return(shadow); }//End castShadowOnPos method
public Asset(DynamicState dynamicState, string name) { Name = name; AssetDynamicState = dynamicState; IsTaskable = false; }