Exemplo n.º 1
0
        /// <summary>
        /// Calculates the angle between two rays
        /// </summary>
        /// <param name="other">Ray to calculate the angle with</param>
        /// <returns>Angle between two rays</returns>
        public double Angle(Ray other)
        {
            if(other == null)
                return Double.NaN;

            return Math.Acos(Math.Abs(Vector3.Dot(Director, other.Director))/(Director.Magnitude * other.Director.Magnitude));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the distance vector between two rays
        /// </summary>
        /// <param name="other">Ray to calculate the distance with</param>
        /// <returns>Distance between two rays</returns>
        public Vector3 Distance(Ray other)
        {
            if (other == null)
                return null;

            // Gets the closest point of this ray to the other ray
            Vector3 difference = other.Position - this.position;
            Vector3 closestPoint = this.position + Vector3.Dot(director, difference) * director;
            Vector3 distanceV = other.Position - closestPoint;

            // Distance between paralel rays
            if (this.director == other.director)
                return distanceV;

            return distanceV;
        }