public void TestGetHandlePosition() { Rope rope = new Rope(23); // Handle is on the right side. var pos = rope.GetHandlePosition(65); Assert.IsTrue(Math.Round(pos.X, 4) == Math.Round(20.845079101842948, 4)); Assert.IsTrue(Math.Round(pos.Y, 4) == Math.Round(9.7202200200360878, 4)); // When handle is past the pilon and on left side. var pos2 = rope.GetHandlePosition(-91.2); // X - 22.994955719921446 double // Y - 0.48167565731721124 double // Just ensure they are both negative. Assert.IsTrue(pos2.X < 0 && pos2.Y < 0); }
/// /// <summary> Get handle position in x,y coordinates from the pilon. </summary> /// private CoursePosition CalculateRopeHandlePosition(Measurement current) { CoursePosition virtualHandlePos = m_rope.GetHandlePosition(current.RopeAngleDegrees); // Actual handle position is calculated relative to the pilon/boat position, behind the boat. double y = current.BoatPosition.Y - virtualHandlePos.Y; double x = current.BoatPosition.X - virtualHandlePos.X; return new CoursePosition(x, y); }