public override ProjectileMotionPoint GetFarthestPoint() { if (FarthestPointIndex < 0) { FarthestPointIndex = 0; int count = GetListAllPointsOfTrajectory().Count(); for (int i = 1; i < count; i++) { if (GetListAllPointsOfTrajectory()[i].GetDistance() < GetListAllPointsOfTrajectory()[FarthestPointIndex].GetDistance()) { break; } FarthestPointIndex = i; } ProjectileMotionPoint final = GetFinalPoint(); ProjectileMotionPoint farthest = GetListAllPointsOfTrajectory()[FarthestPointIndex]; if (final.GetDistance() > farthest.GetDistance()) { FarthestPointIndex = count - 1; return(final); } return(farthest); } return(GetListAllPointsOfTrajectory()[FarthestPointIndex]); }
public string GetSpeciallySerializedTrajectory(bool usingDegradedMotion) { ProjectileMotionTrajectory trajectory = (usingDegradedMotion ? DegradedMotion : Motion).Trajectory; ProjectileMotionPoint farthestPoint = trajectory.GetFarthestPoint(); ProjectileMotionPoint highestPoint = trajectory.GetHighestPoint(); ProjectileMotionPoint finalPoint = trajectory.GetFinalPoint(); return(new JsonSerializerHelper( trajectory.GetPointsList().Select(p => new _MotionChartPoint(p, p.T == farthestPoint.T, p.T == highestPoint.T, p.T == finalPoint.T, Motion.Settings.RoundDigits)) ).Serialize()); }
public override ProjectileMotionPoint GetPoint(Time t) { ProjectileMotionPoint finalPoint = GetFinalPoint(); if (t >= finalPoint.T) { return(finalPoint); } return(GetListAllPointsOfTrajectory().Where(x => t == x.T).First()); }
public virtual ProjectileMotionPoint GetFarthestPoint() { ProjectileMotionPoint final = GetFinalPoint(); ProjectileMotionPoint initial = GetInitialPoint(); ProjectileMotionPoint above = GetPoint(new ProjectileMotionPointsComputation(Settings).GetTimeFarthestAbove()); if (final.GetDistanceFromPoint(initial) > above.GetDistanceFromPoint(initial)) { return(final); } return(above); }
public _MotionChartPoint(ProjectileMotionPoint point, bool isFarthest, bool isHighest, bool isFinal, int roundDigits) { X = point.X.GetRoundedVal(roundDigits); Y = point.Y.GetRoundedVal(roundDigits); T = point.T.GetRoundedVal(roundDigits); Vx = point.Vx.GetRoundedVal(roundDigits); Vy = point.Vy.GetRoundedVal(roundDigits); V = point.GetVelocity().GetRoundedVal(roundDigits); IsFarthest = isFarthest; IsHighest = isHighest; IsFinal = isFinal; TMiliseconds = point.T.GetConvertedVal(UnitTime.Milisecond); }
public override Area GetAreaUnderArc() { if (AreaUnderArcVal < 0) { AreaUnderArcVal = Settings.Quantities.Α.IsRight() ? 0 : GetSumParallelPointsOfTrajectory(i => { ProjectileMotionPoint current = GetListAllPointsOfTrajectory().ElementAt(i); ProjectileMotionPoint prev = GetListAllPointsOfTrajectory().ElementAt(i - 1); return((current.Y.GetBasicVal() + prev.Y.GetBasicVal()) * (current.X.GetBasicVal() - prev.X.GetBasicVal()) / 2.0); }); } return(new Area(AreaUnderArcVal, UnitArea.Basic)); }
private ProjectileMotionWithResistanceComputation(ProjectileMotionWithResistanceSettings settings) { Settings = settings; IsNextReal = true; Point = new ProjectileMotionPoint(new ProjectileMotionSettings(Settings.Quantities), ProjectileMotionPointsComputation.GetTimeInitial()); VyComputed = Point.Vy.GetBasicVal(); VxComputed = Point.Vx.GetBasicVal(); if (Point.Y.Val == 0 && Settings.Quantities.Α.Val == 0) { IsNextReal = false; } }
public ProjectileMotionWithResistanceComputation Continue() { IsNextReal = true; VyComputed = GetNewVy(); VxComputed = GetNewVx(); Point = new ProjectileMotionPoint(this); if (Point.Y.Val == 0) { IsNextReal = false; } return(this); }
public override List <ProjectileMotionPoint> GetPointsList() { return(GetPointsList((currentIndex, ordinaryPointsCount, specialPoints) => { ProjectileMotionPoint p = GetListAllPointsOfTrajectory().ElementAt( (int)Math.Floor((GetListAllPointsOfTrajectory().Count - 1) * currentIndex / (double)ordinaryPointsCount) ); if (specialPoints.Where(sp => sp.T == p.T).Any()) { return GetListAllPointsOfTrajectory().ElementAt( (int)Math.Floor((2.0 * currentIndex - 1) * (GetListAllPointsOfTrajectory().Count - 1) / (2.0 * ordinaryPointsCount)) ); } return p; })); }
protected List <ProjectileMotionPoint> GetDifferentSpecialPoints() { ProjectileMotionPoint initial = GetInitialPoint(); List <ProjectileMotionPoint> result = new List <ProjectileMotionPoint>() { initial }; ProjectileMotionPoint highest = GetHighestPoint(); ProjectileMotionPoint farthest = GetFarthestPoint(); if (initial.T == highest.T) { result.Add(farthest); } else { result.Add(highest); ProjectileMotionPoint final = GetFinalPoint(); if (highest.T == farthest.T) { result.Add(final); } else { result.Add(farthest); if (farthest.T != final.T) { result.Add(final); } } } return(result); }
private string CounstructCoordsFormatted(ProjectileMotionPoint p, string format = "( {0}, {1} )") { return(string.Format(format, p.X.Convert(Motion.Settings.Quantities.Units.Length).GetRoundedVal(Motion.Settings.RoundDigits).ToString(CultureInfo.InvariantCulture), p.Y.Convert(Motion.Settings.Quantities.Units.Length).GetRoundedVal(Motion.Settings.RoundDigits).ToString(CultureInfo.InvariantCulture))); }