コード例 #1
0
        public bool isRayWithinFOV(IMathPoint rayTo)
        {
            IMathPoint source    = getCentreOfVision();
            MathVector direction = ((MathVector)mathUtils.CreateVector(new double[] {
                rayTo.ArrayData[0] - source.ArrayData[0],
                rayTo.ArrayData[1] - source.ArrayData[1],
                rayTo.ArrayData[2] - source.ArrayData[2],
            })).Normalise();

            // now we need to see if our direction is less extreme than all of the corner directions.
            rayVectors();

            double theta = Math.Acos(direction.Dot(cameraDirection.Normalise()));

            // TODO : this could be better
            return(theta < VIEWINGANGLEUPDOWN && theta < VIEWINGANGLERIGHTLEFT);
        }
コード例 #2
0
 /// <summary>
 /// Finds if the 2 vectors are in the same direction
 /// </summary>
 /// <param name="v1">THe first vector</param>
 /// <param name="v2">The second vector</param>
 /// <returns>whether the 2 vectors have the same direction</returns>
 public static bool IsSameDirection(MathVector v1, MathVector v2)
 {
     v1 = v1.Normalise();
     v2 = v2.Normalise();
     return v1.Subtract(v2).GetLength() < errorVal;
 }