private void Select() { if (LastPointerEnterData == null || Radial.isActiveAndEnabled == false) { return; } var selected = Radial.Selected; if (selected != this) { selected.OrNull()?.FadeOut(LastPointerEnterData); Radial.Selected = this; } if (LastPointerEnterData.dragging || Button.interactable == false) { return; } SetColor(colors.highlightedColor); Button.OnPointerEnter(LastPointerEnterData); Radial.Invoke(PointerEventType.PointerEnter, LastPointerEnterData, this); SelectionDelayId = 0; }
public override void Confirm() { if (Actions[SelectedIndex].Del()) { Radial.StartCloseRadial(); } }
// Creating a single bullet public void CreateSingle(Vector2 position, Radial direction, Color color, BulletDraw shape = BulletDraw.circle) { // check if a bullet can be made if (activeCount == Count) { Debug.ErrorLog("Reached max number of bullets"); return; } // find a location to add the bullet to int index; for (index = 0; index < Count; index++) { if (bulletArr[index].state == 0) { break; } else if (index + 1 == Count) { Debug.ErrorLog("Reached max number of bullets but failed to recognise that sooner"); return; } } // create and add bullet bulletArr[index].position = position; bulletArr[index].direction = direction; bulletArr[index].state = BulletState.spawning; bulletArr[index].draw = shape; bulletArr[index].color = color; }
public override void Init(UIRadialMenu radialMenu, float targetAngle) { base.Init(radialMenu, targetAngle); ClearList(); Radial.SetCenterText(Description); Populate(targetAngle); _cursorOffset = _elementAngleDeg / 2.0f; TransitionSetup(true); }
public static void RegisterGear(Radial radial, string gearName) { if (!gears.ContainsKey(radial)) { gears.Add(radial, new List <string>()); } gears[radial].Add(gearName); }
public override void Cancel() { //SelectedIndex = 0; if (!Radial.TransitionToPreviousLayer()) { if (CancelDel != null) { CancelDel(); } } }
public override void Setup(Radial <RightClickRadialButton> parent, int index) { base.Setup(parent, index); Mask.fillAmount = 1f / 360f * parent.ItemArcMeasure; var iconTransform = icon.rectTransform; iconTransform.localPosition = Radial.ItemCenter; iconTransform.localScale = Vector3.one; var altLabelTransform = altLabel.transform; altLabelTransform.localPosition = Radial.ItemCenter; altLabelTransform.localScale = Vector3.one; }
private void OnUpdate(float value) { if (TweenID.HasValue == false) { return; } var descr = LeanTween.descr(TweenID.Value); descr.setTo(new Vector3(descr.to.x - value, 0f, 0f)); Radial.RotateRadial(value); if (Mathf.Abs(descr.to.x) < 0.01f) { LeanTween.cancel(TweenID.Value, true); } }
internal static void InsertAllGears() { foreach (KeyValuePair <Radial, List <string> > eachEntry in gears) { Radial radial = eachEntry.Key; List <string> gearNames = eachEntry.Value; foreach (string eachGearName in gearNames) { if (!InsertGear(radial, eachGearName)) { break; } } } }
public void OnPointerEnter(PointerEventData eventData) { var selected = Radial.Selected; if (selected != this) { selected.OrNull()?.FadeOut(eventData); Radial.Selected = this; } if (eventData.dragging || Button.interactable == false) { return; } SetColor(colors.highlightedColor); Button.OnPointerEnter(eventData); Radial.Invoke(PointerEventType.PointerEnter, eventData, this); }
void Start() { vrLaserPointer = transform.GetComponent <SteamVR_LaserPointer>(); vrTrackedController = transform.GetComponent <SteamVR_TrackedController>(); Handle handle; if (isRadial) { handle = new Radial(); vrTrackedController.TriggerClicked += handle.OnHandleClick;//按下按键 vrTrackedController.PadClicked += handle.RotationModel; } else { handle = new Needle(); } vrLaserPointer.PointerIn += handle.OnHandleIn; //射线进入某个物体时 vrLaserPointer.PointerOut += handle.OnHandleOut; //射线移除某个物体时 }
internal static bool InsertGear(Radial radial, string gearName) { switch (radial) { case Radial.LightSources: return(InsertGear(ref InterfaceManager.m_Panel_ActionsRadial.m_LightSourceRadialOrder, gearName)); case Radial.Weapons: return(InsertGear(ref InterfaceManager.m_Panel_ActionsRadial.m_WeaponRadialOrder, gearName)); case Radial.Navigation: return(InsertGear(ref InterfaceManager.m_Panel_ActionsRadial.m_NavigationRadialOrder, gearName)); case Radial.Campcraft: return(InsertGear(ref InterfaceManager.m_Panel_ActionsRadial.m_PlaceItemRadialOrder, gearName)); default: return(false); } }
protected void Populate(float targetAngle) { if (Actions.Count <= 0) { Debug.LogError("There are no elements in the layer " + Description); return; } _elementAngleDeg = 360.0f / Actions.Count; _elementAngleRad = _elementAngleDeg * Mathf.Deg2Rad; //_elementArcSize = 2.0f * Mathf.PI * Radial.ScreenSize * (_elementAngleDeg / 360.0f); Vector2[] positions = new Vector2[Actions.Count]; for (int i = 0; i < positions.Length; i++) { positions[i] = new Vector2(); var tempAngle = i * _elementAngleRad; positions[i].x = Radial.ScreenSize * Mathf.Sin(tempAngle); positions[i].y = Radial.ScreenSize * Mathf.Cos(tempAngle); } SelectedIndex = HandleCursor(targetAngle); UpdateDisplayedText(Actions[SelectedIndex].Description, Actions[SelectedIndex].Icon, Color.white); int prevIndex = SelectedIndex == 0 ? Actions.LastIndex() : SelectedIndex - 1; for (var i = 0; i < Actions.Count; i++) { var element = Radial.CreateElement(); CurrentRadials.Add(element); element.AssignParent(Radial, i, Actions[i]); element.RectTr.localPosition = positions[SelectedIndex]; if (i == SelectedIndex) { element.AssignPoints(null); continue; } var pnts = new Vector2[4]; pnts[0] = positions[prevIndex]; pnts[1] = element.RectTr.localPosition; pnts[2] = positions[i]; pnts[3] = i < Actions.Count - 1 ? positions[i + 1] : positions[0]; element.AssignPoints(pnts); } }
public Task<Radial> this[Radial radial] { get { var guid = radial.Guid.ToString(); var requestedData = (Task<Radial>)this[guid]; if (requestedData == null) { lock (radial) { requestedData = (Task<Radial>)this[guid]; if (requestedData == null) { requestedData = radial.LoadAsync(); Add(guid, requestedData, DefaultCacheItemPolicy); Debug.WriteLine(string.Format("{0}: Adding radial ({1:0.###}, {2:0.###})/{3} to cache", DateTime.Now, radial.TransmissionLoss.AnalysisPoint.Geo.Latitude, radial.TransmissionLoss.AnalysisPoint.Geo.Longitude, radial.Bearing)); } } } return requestedData; } }
protected override void SolveInstance(IGH_DataAccess DA) { // --- Input var mesh = default(Mesh); var countA = default(int); var countZ = default(int); var thickness = default(double); var plane = default(Plane); var radius = default(double); var deeper = default(double); var project = default(bool); var projectDistance = default(double); DA.GetData(0, ref mesh); DA.GetData(1, ref countA); DA.GetData(2, ref countZ); DA.GetData(3, ref thickness); DA.GetData(4, ref plane); DA.GetData(5, ref radius); DA.GetData(6, ref deeper); DA.GetData(7, ref project); DA.GetData(8, ref projectDistance); // --- Execute var unit = DocumentTolerance(); var result = Radial.Create(mesh, plane, thickness, deeper, radius, countA, countZ, unit, project, projectDistance); // --- Output DA.SetEnum2D(0, result.CurvesA); DA.SetEnum2D(1, result.CurvesZ); DA.SetEnum1D(2, result.PlanesA); DA.SetEnum1D(3, result.PlanesZ); }
public override void Read(AssetReader reader) { base.Read(reader); X.Read(reader); Y.Read(reader); Z.Read(reader); if (IsReadOrbital(reader.Version)) { OrbitalX.Read(reader); OrbitalY.Read(reader); OrbitalZ.Read(reader); OrbitalOffsetX.Read(reader); OrbitalOffsetY.Read(reader); OrbitalOffsetZ.Read(reader); Radial.Read(reader); } if (IsReadSpeedModifier(reader.Version)) { SpeedModifier.Read(reader); } InWorldSpace = reader.ReadBoolean(); reader.AlignStream(AlignType.Align4); }
public void SpawnSingleAt(BulletLogic logicType, BulletDraw drawType, Radial radial, Vector2 position, Color color) { int index = 0; for (index = 0; index < Count; index++) { if (this[index].logicType == BulletLogic.None) { break; } else { IO.Debug.Log("Could not spawn bullet"); return; } } this[index].logicType = logicType; this[index].drawType = drawType; this[index].radial = radial; this[index].position = position; this[index].color = color; this[index].TimeSinceAwake = 0f; }
public void Add(Radial radial) { if (radial.HasErrors) { Debug.WriteLine(string.Format("Radial at bearing {0} has errors. Calculation aborted.", radial.Bearing)); return; } Radial outRadial; if (WorkQueue.TryGetValue(radial.Guid, out outRadial)) return; WorkQueue.Add(radial.Guid, radial); _calculatorQueue.Post(radial); }
void Calculate(Radial radial) { try { var scenario = radial.TransmissionLoss.AnalysisPoint.Scenario; var mode = (from m in radial.TransmissionLoss.Modes orderby m.MaxPropagationRadius select m).Last(); var platform = mode.Source.Platform; var timePeriod = platform.Scenario.TimePeriod; if (radial.IsDeleted) return; var wind = (Wind)_cacheService[scenario.Wind].Result; if (radial.IsDeleted) return; var soundSpeed = (SoundSpeed)_cacheService[scenario.SoundSpeed].Result; if (radial.IsDeleted) return; var bathymetry = (Bathymetry)_cacheService[scenario.Bathymetry].Result; if (radial.IsDeleted) return; var sediment = (Sediment)_cacheService[scenario.Sediment].Result; if (radial.IsDeleted) return; var deepestPoint = bathymetry.DeepestPoint; var deepestProfile = soundSpeed[timePeriod].GetDeepestSSP(deepestPoint).Extend(deepestPoint.Data); var depthAtAnalysisPoint = bathymetry.Samples.IsFast2DLookupAvailable ? bathymetry.Samples.GetNearestPointAsync(radial.TransmissionLoss.AnalysisPoint.Geo).Result : bathymetry.Samples.GetNearestPoint(radial.TransmissionLoss.AnalysisPoint.Geo); // If there is less than one meter of water at the analysis point, discard this radial if (depthAtAnalysisPoint.Data > -1) { radial.Delete(); return; } var windData = wind[timePeriod].EnvironmentData; var windSample = windData.IsFast2DLookupAvailable ? windData.GetNearestPointAsync(radial.Segment.Center).Result : windData.GetNearestPoint(radial.Segment.Center); var sedimentSample = sediment.Samples.IsFast2DLookupAvailable ? sediment.Samples.GetNearestPointAsync(radial.Segment.Center).Result : sediment.Samples.GetNearestPoint(radial.Segment.Center); var bottomProfile = new BottomProfile(99, radial.Segment, bathymetry); var directoryPath = Path.GetDirectoryName(radial.BasePath); if (directoryPath == null) return; if (!Directory.Exists(directoryPath)) Directory.CreateDirectory(directoryPath); if (Globals.PluginManagerService != null && Globals.PluginManagerService[PluginType.TransmissionLossCalculator] != null) { var profilesAlongRadial = ProfilesAlongRadial(radial.Segment, 0.0, null, null, bottomProfile, soundSpeed[timePeriod].EnvironmentData, deepestProfile).ToList(); if (radial.IsDeleted) return; radial.CalculationStarted = DateTime.Now; try { mode.GetTransmissionLossPlugin(Globals.PluginManagerService).CalculateTransmissionLoss(platform, mode, radial, bottomProfile, sedimentSample, windSample.Data, profilesAlongRadial); } catch (RadialDeletedByUserException) { radial.CleanupFiles(); } radial.CalculationCompleted = DateTime.Now; radial.Length = mode.MaxPropagationRadius; radial.IsCalculated = true; LocationContext.Modify(c => { var transmissionLoss = (from tl in c.TransmissionLosses where tl.Guid == radial.TransmissionLoss.Guid select tl).Single(); transmissionLoss.Radials.Add(radial); radial.TransmissionLoss = transmissionLoss; }); } else Debug.WriteLine("TransmissionLossCalculatorService: PluginManagerService is not initialized, or there are no transmission loss calculator plugins defined"); } catch (Exception e) { Debug.WriteLine("{0}: FAIL: Calculation of transmission loss for radial bearing {1} degrees, of mode {2} in analysis point {3}. Exception: {4}", DateTime.Now, radial == null ? "(null)" : radial.Bearing.ToString(CultureInfo.InvariantCulture), radial == null || radial.TransmissionLoss == null || radial.TransmissionLoss.Modes == null || radial.TransmissionLoss.Modes.Count == 0 ? "(null)" : radial.TransmissionLoss.Modes[0].ToString(), radial == null || radial.TransmissionLoss == null || radial.TransmissionLoss.AnalysisPoint == null || radial.TransmissionLoss.AnalysisPoint.Geo == null ? "(null)" : ((Geo)radial.TransmissionLoss.AnalysisPoint.Geo).ToString(), e.Message); } }
public void TestAdd(Radial radial) { Calculate(radial); }
public void Remove(Radial radial) { WorkQueue.Remove(radial.Guid); }
public void Add(Radial radial) { var geoRect = (GeoRect)radial.TransmissionLoss.AnalysisPoint.Scenario.Location.GeoRect; if (!geoRect.Contains(radial.Segment[0]) || !geoRect.Contains(radial.Segment[1])) { //radial.Errors.Add("This radial extends beyond the location boundaries"); return; } //Debug.WriteLine("{0}: Queueing calculation of transmission loss for radial bearing {1} degrees, of mode {2} in analysis point {3}", DateTime.Now, radial.Bearing, radial.TransmissionLoss.Mode.ModeName, (Geo)radial.TransmissionLoss.AnalysisPoint.Geo); Radial outRadial; if (WorkQueue.TryGetValue(radial.Guid, out outRadial)) return; WorkQueue.Add(radial.Guid, radial); _calculatorQueue.Post(radial); }
public override void CalculateTransmissionLoss(Platform platform, Mode mode, Radial radial, BottomProfile bottomProfile, SedimentType sedimentType, double windSpeed, IList<Tuple<double, SoundSpeedProfile>> soundSpeedProfilesAlongRadial) { var sourceDepth = platform.Depth; var frequency = (float)Math.Sqrt(mode.HighFrequency * mode.LowFrequency); if (mode.Depth.HasValue) sourceDepth += mode.Depth.Value; var directoryPath = Path.GetDirectoryName(radial.BasePath); if (directoryPath == null) throw new NullReferenceException("radial.BasePath does not point to a valid directory"); if (!Directory.Exists(directoryPath)) Directory.CreateDirectory(directoryPath); // Derived Parameters // ================== // Note: All the specific calculations given in the comments below assume a frequency of 1kHz // lambda is wavelength, in meters var lambda = ReferenceSoundSpeed / frequency; // if dz < 1m round dz down to either [1/10, 1/5, 1/4 or 1/2] m ... or multiples of 10^-n of these numbers // = [1 2 2.5 or 5 ] x 0.1m " " ... // if dz > 1m round dz down to either [1 2 2.5 5 ] m ... or multiples of 10^+n of these numbers // var fixpoints = new List<double> { 1, 2, 2.5, 5 }; // dz = 0.1 * lambda var dz = RelativeDepthResolution * lambda; // make dz a 'pretty' number //dz = Fix2X10pN(dz, fixpoints); // ndz is the depth decimation factor // MinimumOutputDepthResolution is 10m // dz is 0.1 * lambda (dz = 0.15 for a 1 kHz signal, 'pretty' dz = 0.2 @ 1kHz) // so ndz = (10 / 0.2) = 50 @ 1kHz // this means that we will only output every 50 computational depth cells, giving us a depth // resolution of 50 * 0.2m = 10m @ 1kHz which is what we want it to be. Outstanding. var ndz = (int)Math.Max(1.0, Math.Floor(MinimumOutputDepthResolution / dz)); // similar for dr and assoc. grid decimation // RelativeRangeResolution is 2, so with our 'pretty' dz = 0.2, dr = 0.4 var dr = RelativeRangeResolution * dz; // make dr a 'pretty' number, in this case 0.25 //dr = Fix2X10pN(dr, fixpoints); // ndr is the range decimation factor // MinimumOutputRangeResolution is 10m // dr is 0.25 * lambda, so (10 / 0.25) gives us an ndr of 40 // this means that we will only output every 40 computational range cells, giving us a range // resolution of 40 * 0.25m = 10m @ 1kHz which is what we want it to be. Outstanding. var ndr = (int)Math.Max(1, Math.Floor(MinimumOutputRangeResolution / dr)); // attenuation layer (round up to nearest dz) var sedimentLambda = sedimentType.CompressionWaveSpeed / frequency; var sedimentLayerDz = Math.Ceiling(LastLayerThickness * sedimentLambda / dz) * dz; var attenuationLayerDz = Math.Ceiling(AttenuationLayerThickness * sedimentLambda / dz) * dz; var maxSubstrateDepth = bottomProfile.MaxDepth + sedimentLayerDz; var zstep = dz * ndz; var zmplt = Math.Ceiling((bottomProfile.MaxDepth + 2 * zstep) / zstep) * zstep; // Maximum Depth for PE calc -> zmax // zmax is the z-limit for the PE calc from top of the water column to the bottom of the last substrate layer // (including the attentuation layer if, as recommended, this is included) var zmax = maxSubstrateDepth + attenuationLayerDz; var envFileName = radial.BasePath + ".env"; //Debug.WriteLine("Scenario: '{0}' Mode: '{2}' Analysis point: {1} Bearing: {3}, zmplt: {4}", // radial.TransmissionLoss.AnalysisPoint.Scenario.Name, // radial.TransmissionLoss.AnalysisPoint.Geo, // radial.TransmissionLoss.Modes[0].ModeName, // radial.Bearing, zmplt); using (var envFile = new StreamWriter(envFileName, false)) { envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "Scenario: '{0}' Mode: '{2}' Analysis point: {1} Bearing: {3}", radial.TransmissionLoss.AnalysisPoint.Scenario.Name, radial.TransmissionLoss.AnalysisPoint.Geo, radial.TransmissionLoss.Modes[0].ModeName, radial.Bearing)); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.000000}\t{1:0.000000}\t{2:0.000000}\t\tf [Frequency (Hz)], zs [Source Depth (m)], zrec0 [First receiever depth (m)]", frequency, sourceDepth, 0.1)); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.000000}\t{1:0.000000}\t{2}\t\t\trmax[Max range (m)], dr [Range resolution (m)], ndr [Range grid decimation factor]", mode.MaxPropagationRadius + (dr * ndr), dr, ndr)); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.000000}\t{1:0.000000}\t{2}\t{3:0.000000}\tzmax [Max computational depth (m)], dz [Depth resolution (m)], ndz [Depth grid decimation factor], zmplot [Maximum depth to plot (m)]", zmax, dz, ndz, zmplt)); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.000000}\t{1}\t{2}\t{3:0.000000}\t\tc0 [Reference sound speed (m/s)], np [Number of terms in Padé expansion], ns [Number of stability constraints], rs [Maximum range of stability constraints (m)]", ReferenceSoundSpeed, PadeExpansionTerms, StabilityConstraints, StabilityConstraintMaxRange)); // todo: different stuff goes here for RAMSGeo // bathymetry data var first = true; foreach (var profilePoint in bottomProfile.Profile) { envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.000000}\t{1:0.000000}{2}", profilePoint.Range * 1000, profilePoint.Depth, first ? "\t\t\t\t\tbathymetry data [range (m), depth (m)]" : "")); first = false; } envFile.WriteLine("-1\t-1"); // range-dependent environment profiles var firstRangeProfile = true; foreach (var rangeProfileTuple in soundSpeedProfilesAlongRadial) { // Range of profile only written for second and subsequent profiles if (!firstRangeProfile) envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.#}\t\t\t\t\t\t\tProfile range (m)", rangeProfileTuple.Item1 * 1000)); var firstSoundSpeedProfile = true; foreach (var profilePoint in rangeProfileTuple.Item2.Data) { if (double.IsNaN(profilePoint.SoundSpeed)) break; envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.######}\t{1:0.######}{2}", profilePoint.Depth, profilePoint.SoundSpeed, firstSoundSpeedProfile ? "\t\t\t\t\tsound speed profile in water [depth (m), sound speed (m/s)]" : "")); firstSoundSpeedProfile = false; } envFile.WriteLine("-1\t-1"); // todo: RAMGeo and RAMSGeo also support sediment layers, as well as range-dependent sediment, neither of which is not yet supported by ESME // If sediment layers are ever supported, put a loop like for the sound speed profile above // A sediment layer is analogous to a sound speed profile point // For range-dependent sediment, the sediment samples have to be at the same ranges as the sound speed profiles // so we might want to change the API to include sediment properties in what is the current range and sound speed profile tuple envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.######}\t{1:0.######}\t\t\t\t\t\tcompressive sound speed profile in substrate [depth (m), sound speed (m/s)]", 0.0, sedimentType.CompressionWaveSpeed)); envFile.WriteLine("-1\t-1"); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.######}\t{1:0.######}\t\t\t\t\t\tdensity profile in substrate [depth (m), rhob (g/cm³)]", 0.0, sedimentType.Density)); envFile.WriteLine("-1\t-1"); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.######}\t{1:0.######}\t\t\t\t\t\tcompressive attenuation profile in substrate [depth (m), attnp (db/lambda)]", 0.0, 0.0)); envFile.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0:0.######}\t{1:0.######}", attenuationLayerDz, 40)); envFile.WriteLine("-1\t-1"); firstRangeProfile = false; } } var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(envFileName)); //Debug.WriteLine(string.Format("Env File: {0} temp path: {1}", envFileName, tempDirectory)); if (Directory.Exists(tempDirectory)) { var files = Directory.GetFiles(tempDirectory, "*.*"); foreach (var file in files) File.Delete(file); Directory.Delete(tempDirectory, true); } else if (File.Exists(tempDirectory)) File.Delete(tempDirectory); Directory.CreateDirectory(tempDirectory); File.Copy(envFileName, Path.Combine(tempDirectory, "ramgeo.in")); using (var steerableArrayFile = new StreamWriter(Path.Combine(tempDirectory, "sra.in"), false)) { // From http://www.activefrance.com/Antennas/Introduction%20to%20Phased%20Array%20Design.pdf // theta3 = 3dB beam width, in degrees // emitterSize = size of emitter array, in meters // theta3 = (0.886 * lambda / arrayLength) * 180 / pi // so, doing the algebra and solving for arrayLength, you get: // emitterSize = (0.886 * lambda) / (theta3 * (pi / 180)) var emitterSize = (0.886 * lambda) / (mode.VerticalBeamWidth * (Math.PI / 180.0)); var emitterCount = (int)(emitterSize / (dz * 2)); var emitterSpacing = 1.0; var weights = new List<double> { 1 }; if (emitterCount > 1) { emitterSpacing = emitterSize / (emitterCount - 1); // chebyshev window calculations for relative emitter strength across the array var discreteFourierTransform = new MathNet.Numerics.IntegralTransforms.Algorithms.DiscreteFourierTransform(); var r0 = Math.Pow(10, mode.SideLobeAttenuation / 20.0); var n = emitterCount - 1; var a = Complex.Cosh((1.0 / n) * Acosh(r0)); var am = new Complex[n]; for (var m = 0; m < n; m++) am[m] = a * Complex.Cos(Math.PI * m / n); var wm = new Complex[n]; var sign = 1; for (var i = 0; i < n; i++) { if (am[i].Magnitude > 1) wm[i] = sign * Complex.Cosh(n * Acosh(am[i])); else wm[i] = sign * Complex.Cos(n * Complex.Acos(am[i])); sign *= -1; } discreteFourierTransform.BluesteinInverse(wm, FourierOptions.Default); weights = wm.Select(e => e.Real).ToList(); weights[0] /= 2; weights.Add(weights[0]); var maxWeight = weights.Max(); for (var i = 0; i < weights.Count; i++) weights[i] /= maxWeight; } steerableArrayFile.WriteLine("{0}\t{1}\t{2}", emitterCount, emitterSpacing, mode.DepressionElevationAngle); for (var i = 0; i < emitterCount; i++) steerableArrayFile.WriteLine("{0}", weights[i]); } //File.Copy(Path.Combine(AssemblyLocation, "sra.in"), Path.Combine(tempDirectory, "sra.in")); //Debug.WriteLine(string.Format("Env File: {0} copied to: {1}", envFileName, tempDirectory)); // Now that we've got the files ready to go, we can launch bellhop to do the actual calculations var ramProcess = new Process { StartInfo = new ProcessStartInfo(Path.Combine(AssemblyLocation, "RAMGeo.exe")) { CreateNoWindow = true, UseShellExecute = false, RedirectStandardInput = false, RedirectStandardOutput = true, RedirectStandardError = true, WorkingDirectory = tempDirectory } }; if (radial.IsDeleted) throw new RadialDeletedByUserException(); ramProcess.Start(); try { ramProcess.PriorityClass = ProcessPriorityClass.Idle; } catch (InvalidOperationException) { } //ramProcess.BeginOutputReadLine(); while (!ramProcess.HasExited) { if (radial.IsDeleted) { ramProcess.Kill(); throw new RadialDeletedByUserException(); } Thread.Sleep(20); } var ramOutput = ramProcess.StandardOutput.ReadToEnd(); var ramError = ramProcess.StandardError.ReadToEnd(); if (ramProcess.ExitCode != 0) { Debug.WriteLine("RAMGeo process for radial {0} exited with error code {1:X}", radial.BasePath, ramProcess.ExitCode); Debug.WriteLine(ramError); Directory.Delete(tempDirectory, true); return; } //File.Delete(Path.Combine(tempDirectory, "ramgeo.in")); //File.Delete(radial.BasePath + ".grid"); //File.Move(Path.Combine(tempDirectory, "tl.grid"), radial.BasePath + ".grid"); //File.Delete(radial.BasePath + ".line"); //File.Move(Path.Combine(tempDirectory, "tl.line"), radial.BasePath + ".line"); //File.Delete(radial.BasePath + ".pgrid"); //File.Move(Path.Combine(tempDirectory, "p.grid"), radial.BasePath + ".pgrid"); //File.Delete(radial.BasePath + ".sra"); //File.Move(Path.Combine(tempDirectory, "sra.in"), radial.BasePath + ".sra"); using (var writer = new StreamWriter(radial.BasePath + ".bty")) writer.Write(bottomProfile.ToBellhopString()); if (File.Exists(Path.Combine(tempDirectory, "p.grid"))) { var pressures = ReadPGrid(Path.Combine(tempDirectory, "p.grid")); File.Copy(Path.Combine(tempDirectory, "p.grid"), radial.BasePath + ".pgrid", true); //File.Delete(radial.BasePath + ".pgrid"); if (pressures.Count == 0) { Debug.WriteLine("Temp directory: " + tempDirectory); Debug.WriteLine("RAMGeo stdout: " + ramOutput); Debug.WriteLine("RAMGeo stderr: " + ramError); Directory.Delete(tempDirectory, true); return; } var rangeCount = pressures.Count; var depthCount = pressures[0].Length; var rr = new double[rangeCount]; var rd = new double[depthCount]; for (var rangeIndex = 0; rangeIndex < rr.Length; rangeIndex++) rr[rangeIndex] = (rangeIndex + 1) * dr * ndr; for (var depthIndex = 0; depthIndex < rd.Length; depthIndex++) rd[depthIndex] = depthIndex * zstep; //Debug.WriteLine("Scenario: '{0}' Mode: '{2}' Analysis point: {1} Bearing: {3}, zmplt: {4}, zstep: {5}, maxDepth: {6}, fileName: {7}, reqDepthCells: {8}, actualDepthCells: {9}", // radial.TransmissionLoss.AnalysisPoint.Scenario.Name, // radial.TransmissionLoss.AnalysisPoint.Geo, // radial.TransmissionLoss.Modes[0].ModeName, // radial.Bearing, // zmplt, // zstep, // rd.Last(), // Path.GetFileNameWithoutExtension(radial.BasePath), // zmplt / zstep, // depthCount); var shadeFile = new ShadeFile(sourceDepth, frequency, rd, rr, pressures); shadeFile.Write(radial.BasePath + ".shd"); //BellhopOutput.WriteShadeFile(radial.BasePath + ".shd", sourceDepth, frequency, rd, rr, pressures); } else { //Debug.WriteLine("Scenario: {0} Analysis point: {1} Mode {2} Bearing {3}", // radial.TransmissionLoss.AnalysisPoint.Scenario.Name, // radial.TransmissionLoss.AnalysisPoint.Geo, // radial.TransmissionLoss.Modes[0].ModeName, // radial.Bearing); //Debug.WriteLine("p.grid file not found in RAMGeo output directory"); } Directory.Delete(tempDirectory, true); //Debug.WriteLine(string.Format("Env File: {0} temp directory deleted: {1}", envFileName, tempDirectory)); }
public void OnPointerClick(PointerEventData eventData) => Radial.Invoke(PointerEventType.PointerClick, eventData, this);
public void OnPointerExit(PointerEventData eventData) { LeanTween.cancel(SelectionDelayId); SelectionDelayId = 0; Radial.Invoke(PointerEventType.PointerExit, eventData, this); }
public void OnPointerExit(PointerEventData eventData) { Radial.Invoke(PointerEventType.PointerExit, eventData, this); }