示例#1
0
        /// <summary>
        ///     Devuelve el ángulo (en grados) entre v1 y v2.
        ///     <para>Ambos vectores se normalizan y quedan modificados.</para>
        ///     <para>Si uno de los vectores o los dos valen cero, devuelve 90º.</para>
        ///     <para>El ángulo devuelto varia entre 0 y 180 grados</para>
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <returns></returns>
        public static double Angle(Vector3F v1, Vector3F v2)
        {
            v1.Normalize();
            v2.Normalize();
            var rdot   = v1.Dot(v2);
            var result = Math.Acos(rdot);

            return(MathHelp.DegreesFromRadians((float)result));
        }
示例#2
0
        /// <summary>
        ///     Construct a plane from 3 coplanar points.
        /// </summary>
        /// <param name="point0">First point.</param>
        /// <param name="point1">Second point.</param>
        /// <param name="point2">Third point.</param>
        public Plane(Vector3F point0, Vector3F point1, Vector3F point2)
        {
            Normal = new Vector3F();
            var edge1 = point1 - point0;
            var edge2 = point2 - point0;

            Vector3F.Cross(edge1, edge2, ref Normal);
            Normal.Normalize();
            D = -Normal.Dot(point0);
        }
示例#3
0
 /// <summary>
 ///     This is a pseudodistance. The sign of the return value is
 ///     positive if the point is on the positive side of the plane,
 ///     negative if the point is on the negative side, and zero if the
 ///     point is on the plane.
 ///     The absolute value of the return value is the true distance only
 ///     when the plane normal is a unit length vector.
 /// </summary>
 /// <param name="point"></param>
 /// <returns></returns>
 public float GetDistance(Vector3F point)
 {
     return(Normal.Dot(point) + D);
 }
示例#4
0
 public Plane(Vector3F normal, Vector3F point)
 {
     Normal = normal;
     D      = -normal.Dot(point);
 }