/// <summary>
 /// Calculates the cross product of this vector and the given one.
 /// </summary>
 /// <param name="other">The other vector.</param>
 /// <returns>The cross product of the two vectors.</returns>
 public CartesianVector CrossProduct(CartesianVector other)
 {
     return(new CartesianVector(
                x: (Y * other.Z) - (other.Y * Z),
                y: (other.X * Z) - (X * other.Z),
                z: (X * other.Y) - (other.X * Y)));
 }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
 public double DotProduct(CartesianVector other)
 {
     return((X * other.X) + (Y * other.Y) + (Z * other.Z));
 }
Beispiel #5
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);
 }
Beispiel #6
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;
 }
Beispiel #7
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))
 {
 }
Beispiel #8
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));
 }