public static double[] ETCurve_Directional(Direct_Sound Direct, ImageSourceData ISData, Receiver_Bank RTData, double CO_Time_ms, int Sampling_Frequency, int Octave, int Rec_ID, bool Start_at_Zero, double alt, double azi, bool degrees) { double[] Histogram = new double[(int)(CO_Time_ms * 0.001 * Sampling_Frequency)]; if (RTData != null) { for (int i = 0; i < Histogram.Length; i++) { Hare.Geometry.Vector Vpos = RTData.Directions_Pos(Octave, i, Rec_ID, alt, azi, degrees); Hare.Geometry.Vector Vneg = RTData.Directions_Neg(Octave, i, Rec_ID, alt, azi, degrees); double E = RTData.Rec_List[Rec_ID].Energy(i, Octave); Hare.Geometry.Vector VTot = new Hare.Geometry.Vector(Math.Abs(Vpos.x) - Math.Abs(Vneg.x), Math.Abs(Vpos.y) - Math.Abs(Vneg.y), Math.Abs(Vpos.z) - Math.Abs(Vneg.z)); if (Vpos.x > 0) { Histogram[i] += Math.Abs(Vpos.x); } if (Vneg.x > 0) { Histogram[i] += Math.Abs(Vneg.x); } double L = VTot.Length(); if (L > 0) Histogram[i] *= E / L; if (AcousticalMath.SPL_Intensity(Histogram[i]) > 200) { Rhino.RhinoApp.Write("Super high SPLs... what's going on, man?"); } } } if (Direct != null && Direct.IsOccluded(Rec_ID)) { int D_Start = 0; if (!Start_at_Zero) D_Start = (int)Math.Ceiling(Direct.Time(Rec_ID) * Sampling_Frequency); Hare.Geometry.Vector[] DirectValue; switch (Octave) { case 8: DirectValue = Direct.Dir_Energy_Sum(Rec_ID, alt, azi, degrees); break; default: DirectValue = Direct.Dir_Energy(Octave, Rec_ID, alt, azi, degrees); break; } for (int i = 0; i < DirectValue.Length; i++) { if (DirectValue[i].x > 0) Histogram[D_Start + i] += Math.Abs(DirectValue[i].x); } } if (ISData != null) { switch (Octave) { case 8: foreach (Deterministic_Reflection value in ISData.Paths[Rec_ID]) { if (Math.Ceiling(Sampling_Frequency * value.TravelTime) < Histogram.Length - 1) { Hare.Geometry.Vector[] E_Sum = value.Dir_EnergySum(alt, azi, degrees); for (int i = 0; i < E_Sum.Length; i++) { if (E_Sum[i].x > 0) Histogram[(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i)] += Math.Abs(E_Sum[i].x); } } } break; default: foreach (Deterministic_Reflection value in ISData.Paths[Rec_ID]) { if (Math.Ceiling(Sampling_Frequency * value.TravelTime) < Histogram.Length - 1) { Hare.Geometry.Vector[] E_Dir = value.Dir_Energy(Octave, alt, azi, degrees); for (int i = 0; i < E_Dir.Length; i++) { if (E_Dir[i].x > 0) Histogram[(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i)] += Math.Abs(E_Dir[i].x); } } } break; } } return Histogram; }
public static double[][] ETCurve_1d(Direct_Sound Direct, ImageSourceData ISData, Receiver_Bank RTData, double CO_Time_ms, int Sampling_Frequency, int Octave, int Rec_ID, bool Start_at_Zero, double alt, double azi, bool degrees) { double[][] Histogram = new double[3][]; Histogram[0] = new double[(int)(CO_Time_ms * 0.001 * Sampling_Frequency)]; Histogram[1] = new double[(int)(CO_Time_ms * 0.001 * Sampling_Frequency)]; Histogram[2] = new double[(int)(CO_Time_ms * 0.001 * Sampling_Frequency)]; if (RTData != null) { for (int i = 0; i < Histogram[0].Length; i++) { Hare.Geometry.Vector Vpos = RTData.Directions_Pos(Octave, i, Rec_ID, alt, azi, degrees); Hare.Geometry.Vector Vneg = RTData.Directions_Neg(Octave, i, Rec_ID, alt, azi, degrees); double E = RTData.Rec_List[Rec_ID].Energy(i, Octave); Hare.Geometry.Vector VTot = new Hare.Geometry.Vector(Math.Abs(Vpos.x) - Math.Abs(Vneg.x), Math.Abs(Vpos.y) - Math.Abs(Vneg.y), Math.Abs(Vpos.z) - Math.Abs(Vneg.z)); VTot.Normalize(); VTot *= E; Histogram[0][i] = VTot.x; Histogram[1][i] = VTot.y; Histogram[2][i] = VTot.z; } } if (Direct != null && Direct.IsOccluded(Rec_ID)) { int D_Start = 0; if (!Start_at_Zero) D_Start = (int)Math.Ceiling(Direct.Time(Rec_ID) * Sampling_Frequency); Hare.Geometry.Vector[] DirectValue; switch (Octave) { case 8: DirectValue = Direct.Dir_Energy_Sum(Rec_ID, alt, azi, degrees); break; default: DirectValue = Direct.Dir_Energy(Octave, Rec_ID, alt, azi, degrees); break; } for (int i = 0; i < DirectValue.Length; i++) { Histogram[0][D_Start + i] += Math.Abs(DirectValue[i].x); Histogram[1][D_Start + i] += Math.Abs(DirectValue[i].y); Histogram[2][D_Start + i] += Math.Abs(DirectValue[i].z); } } if (ISData != null) { switch (Octave) { case 8: foreach (Deterministic_Reflection value in ISData.Paths[Rec_ID]) { if (Math.Ceiling(Sampling_Frequency * value.TravelTime) < Histogram[0].Length - 1) { Hare.Geometry.Vector[] E_Sum = value.Dir_EnergySum(alt, azi, degrees); for (int i = 0; i < E_Sum.Length; i++) { Histogram[0][(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i / Sampling_Frequency)] += Math.Abs(E_Sum[i].x); Histogram[1][(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i / Sampling_Frequency)] += Math.Abs(E_Sum[i].y); Histogram[2][(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i / Sampling_Frequency)] += Math.Abs(E_Sum[i].z); } } } break; default: foreach (Deterministic_Reflection value in ISData.Paths[Rec_ID]) { if (Math.Ceiling(Sampling_Frequency * value.TravelTime) < Histogram[0].Length - 1) { Hare.Geometry.Vector[] E_Dir = value.Dir_Energy(Octave, alt, azi, degrees); for (int i = 0; i < E_Dir.Length; i++) { Histogram[0][(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i / Sampling_Frequency)] += Math.Abs(E_Dir[i].x); Histogram[1][(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i / Sampling_Frequency)] += Math.Abs(E_Dir[i].y); Histogram[2][(int)Math.Ceiling(Sampling_Frequency * value.TravelTime + i / Sampling_Frequency)] += Math.Abs(E_Dir[i].z); } } } break; } } return Histogram; }