コード例 #1
0
        private void UpdateBoatVisual(Boat boat)
        {
            BoatBearing.Angle = boat.Bearing.Degrees;
            CartesianVector location = _projections.ToCartesian(boat.Location);

            BoatPosition.OffsetX = _projections.ToWorld(location.X);
            BoatPosition.OffsetY = _projections.ToWorld(location.Y);

            if (null == boat.Autopilot.WayPoint)
            {
                Waypoint.Visible = false;
            }
            else
            {
                Waypoint.Visible = true;
                CartesianVector cartesianVector = _projections.ToCartesian(boat.Autopilot.WayPoint.Location);

                if (Waypoint.HasCapture)
                {
                    boat.Autopilot.WayPoint = new Waypoint(_projections.ToModel(Waypoint.Center.X, Waypoint.Center.Y));
                }
                else
                {
                    Waypoint.Center = new Point3D(_projections.ToWorld(cartesianVector.X), _projections.ToWorld(cartesianVector.Y),
                                                  Waypoint.Center.Z);
                }
            }
        }
コード例 #2
0
        public Coordinate ToModel(double x, double y)
        {
            var cartesian = new CartesianVector(ToModel(x), ToModel(y));
            var vector    = _earth.AngularVector(cartesian);

            return(_modelcenter.GreatCircle(vector));
        }
コード例 #3
0
        public void EarthShouldCreateAngularVectorFromCartesianVector()
        {
            var           cartesianvector = new CartesianVector(Length.FromMeters(0), Length.FromMeters(1));
            AngularVector angularvector   = Ball.EarthSurfaceApproximation.AngularVector(cartesianvector);

            Assert.IsTrue((angularvector.Bearing.Abs() - Bearing.North.Abs()).Abs() < Angle.FromDegrees(1e-6));

            cartesianvector = new CartesianVector(Length.FromMeters(1), Length.FromMeters(0));
            angularvector   = Ball.EarthSurfaceApproximation.AngularVector(cartesianvector);

            Assert.IsTrue((angularvector.Bearing.Abs() - Bearing.East.Abs()).Abs() < Angle.FromDegrees(1e-6));
        }
コード例 #4
0
        public void EarthShouldCreateCartesianVectorFromAngularVector()
        {
            var             angularVector   = new AngularVector(Bearing.North, Angle.FromDegrees(1));
            CartesianVector cartesianVector = Ball.EarthSurfaceApproximation.Cartesian(angularVector);

            Assert.IsTrue(cartesianVector.X == Length.Zero);
            Assert.IsTrue(cartesianVector.Y > Length.Zero);

            angularVector   = new AngularVector(Bearing.East, Angle.FromDegrees(1));
            cartesianVector = Ball.EarthSurfaceApproximation.Cartesian(angularVector);

            Assert.IsTrue(cartesianVector.X > Length.Zero);
            Assert.IsTrue(cartesianVector.Y < Length.FromMeters(1E-10));
        }
コード例 #5
0
        public void Vectors_Test()
        {
            var spaceTime = new Cartesian_ND(Units.m, Units.m, Units.m, Units.s);

            var i = new CartesianVector <Cartesian_ND>(1, 0, 0, 0); // Instantaniously move 1 in x

            var j = new CartesianVector <Cartesian_ND>(0, 1, 0, 0); // Instantaniously move 1 in y

            var k = new CartesianVector <Cartesian_ND>(0, 0, 1, 0); // Instantaniously move 1 in z

            var t = new CartesianVector <Cartesian_ND>(0, 0, 0, 1); // Move 1 in t

            var it = i + t;                                         // Move 1 in x in 1 t
            var jt = j + t;                                         // Move 1 in y in 1 t
            var kt = k + t;                                         // Move 1 in z in 1 t

            var loc = new Cartesian_ND_Coordinate(spaceTime, 0, 0, 0, 0);

            CartesianVector <Cartesian_ND> doSomthing(int time)
            {
                CartesianVector <Cartesian_ND> result = new CartesianVector <Cartesian_ND>(0, 0, 0, 0);

                Random rand = new Random(DateTime.Now.GetHashCode() + time);

                result += (rand.Next(-10, 20) * i) + (rand.Next(-10, 20) * j) + (rand.Next(-10, 20) * k);

                return(result);
            }

            CartesianVector <Cartesian_ND> movement;

            for (int time = 0; time < 200; time++)
            {
                movement = new CartesianVector <Cartesian_ND>(0, 0, 0, 1);

                movement += doSomthing(time);

                loc.Move(movement);
            }

            Print(loc.Ordinates[0].ToString() + ", " + loc.Ordinates[1].ToString() + ", " + loc.Ordinates[2].ToString());
        }
コード例 #6
0
 /// <summary>
 /// Returns the tangent vector of this <see cref="GreatCircleSegement"/>'s underlaying <see cref="GreatCircle"/> in the given point, that points in the specified direction.
 /// </summary>
 /// <param name="point">The point on the underlaying <see cref="GreatCircle"/> that the tangent is wanted for.</param>
 /// <param name="direction">The vector specifying in which direction the tangent vector will point.</param>
 /// <returns>The tangent vector pointing in the right direction.</returns>
 public CartesianVector GetTangentAt(SphereCoordinate point, CartesianVector direction)
 {
     return BaseCircle.GetTangentAt(point, direction);
 }
コード例 #7
0
        /// <summary>
        /// Returns the tangent vector of this <see cref="GreatCircle"/> in the given point, that points in the specified direction.
        /// </summary>
        /// <param name="point">The point on the <see cref="GreatCircle"/> that the tangent is wanted for.</param>
        /// <param name="direction">The vector specifying in which direction the tangent vector will point.</param>
        /// <returns>The tangent vector pointing in the right direction.</returns>
        public CartesianVector GetTangentAt(CartesianVector point, CartesianVector direction)
        {
            var possibleTangent = GetTangentAt(point);
            var otherPossibleTangent = -possibleTangent;
            var intendedDirection = (direction - point).AsUnitVector;

            // Don't need to divide by the length because the vectors are both unit vectors.
            var possibleAngle = possibleTangent.DotProduct(intendedDirection);
            var otherPossibleAngle = otherPossibleTangent.DotProduct(intendedDirection);

            return possibleAngle < otherPossibleAngle ? possibleTangent : otherPossibleTangent;
        }
コード例 #8
0
 /// <summary>
 /// Returns one possible tangent vector of this <see cref="GreatCircle"/> in the given point, the other is antipodal to it.
 /// </summary>
 /// <param name="point">The point on the <see cref="GreatCircle"/> that the tangent is wanted for.</param>
 /// <returns>One possible tangent vector.</returns>
 public CartesianVector GetTangentAt(CartesianVector point)
 {
     return DefinitionVector.CrossProduct(point).AsUnitVector;
 }
コード例 #9
0
 /// <summary>
 /// Creates a new instance of the <see cref="GreatCircle"/> struct with the given definition vector.
 /// </summary>
 /// <param name="definitionVector">The vector perpendicular to the plane that produces the great circle.</param>
 public GreatCircle(CartesianVector definitionVector)
 {
     DefinitionVector = definitionVector.AsUnitVector;
 }
コード例 #10
0
 /// <summary>
 /// Creates a new instance of the <see cref="GreatCircle"/> struct given two points defining it.
 /// </summary>
 /// <param name="start">The start coordinate of the segment.</param>
 /// <param name="end">The end coordinate of the segment.</param>
 public GreatCircle(CartesianVector start, CartesianVector end)
     : this(start.CrossProduct(end))
 {
 }
コード例 #11
0
        /// <summary>
        /// Checks whether the given <see cref="GreatCircle"/> intersects with this one.
        /// One point of intersection can then be found in the out-Parameter, the other is the antipodal point to it.
        /// </summary>
        /// <param name="other">The other <see cref="GreatCircle"/>.</param>
        /// <param name="intersection">The point of intersection, if they intersect.</param>
        /// <returns>Whether the two <see cref="GreatCircle"/>s intersect or not.</returns>
        public bool Intersects(GreatCircle other, out CartesianVector intersection)
        {
            // http://www.boeing-727.com/Data/fly%20odds/distance.html

            intersection = default(CartesianVector);

            if (this == other)
                return false;

            intersection = DefinitionVector.CrossProduct(other.DefinitionVector).AsUnitVector;

            return true;
        }