Ejemplo n.º 1
0
        public static CoursePass TestTrack(double ropeM, double swingSpeedRadS, double boatSpeedMps)
        {
            Rope       rope = new Rope(ropeM);
            CoursePass pass = new CoursePass(CourseTest.CreateTestCoursePass().Course, rope);
            DateTime   courseEntryTimestamp = DateTime.Now.Subtract(TimeSpan.FromSeconds(15));

            // Travel down the course is 259m @ 14m/sec
            // 2 events per second
            //
            const int    eventsPerSecond  = 16;
            double       metersPerSecond  = boatSpeedMps;
            double       courseLengthM    = 259 + rope.LengthM + (55 * 2);
            int          events           = (int)(courseLengthM / metersPerSecond) * eventsPerSecond;
            double       ropeRadPerSecond = swingSpeedRadS;
            int          ropeDirection    = 1;
            const double centerLineX      = 11.5;
            double       ropeSpeed        = ropeRadPerSecond;

            for (int i = 0; i < events; i++)
            {
                if (i > 0)
                {
                    //double ropeAngle = pass.Measurements[pass.Measurements.Count - 1].RopeAngleDegrees;
                    double handlePosX = pass.Measurements[pass.Measurements.Count - 1].HandlePosition.X;

                    // Invert the direction of the rope when you hit the apex.
                    //if (ropeAngle > rope.GetHandleApexDeg() || ropeAngle < (rope.GetHandleApexDeg() * -1))
                    if (handlePosX > 22.5 || handlePosX < 0.5)
                    {
                        ropeDirection = ropeDirection * -1;
                    }

                    // Exponentially increment speed towards center line.
                    double ropeSpeedFactor = ((Math.Pow(handlePosX - centerLineX, 2) / 100) * ropeRadPerSecond);
                    if (ropeSpeedFactor > (ropeRadPerSecond * 0.80))
                    {
                        ropeSpeedFactor = ropeRadPerSecond * 0.80;
                    }
                    ropeSpeed = ropeRadPerSecond - ropeSpeedFactor;
                }

                // increment 1 second & 14 meters.
                double longitude = CourseTest.AddDistance(CourseTest.latitude, CourseTest.longitude,
                                                          ((metersPerSecond / eventsPerSecond) * i) + ropeM);
                DateTime time = courseEntryTimestamp.AddSeconds((double)(1.0 / eventsPerSecond) * i);

                string      latLon = $"{CourseTest.latitude}, {longitude}";
                Measurement m      = new Measurement()
                {
                    Timestamp          = time,
                    RopeSwingSpeedRadS = (ropeSpeed * ropeDirection),
                    BoatGeoCoordinate  = GeoCoordinateConverter.FromLatLon(latLon)
                };
            }

            Trace.WriteLine(string.Format("X: Apex:{0}", rope.GetHandleApexDeg()));
            foreach (var m in pass.Measurements)
            {
                Trace.WriteLine(m.HandlePosition.X);
            }

            Trace.WriteLine("Y:");
            foreach (var m in pass.Measurements)
            {
                Trace.WriteLine(m.HandlePosition.Y);
            }

            return(pass);
        }
Ejemplo n.º 2
0
 public CoursePass(Course course, Rope rope) : this(course, rope, 0)
 {
 }