Exemple #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);
        }
 /// <summary>
 /// Finds if the vectors are perpendicular
 /// </summary>
 /// <param name="vec1">Vector 1</param>
 /// <param name="vec2">Vector 2</param>
 /// <returns>True if the vectors are perpendicular</returns>
 public static bool IsPerpendicular(MathVector vec1, MathVector vec2)
 {
     return Math.Abs(vec1.Dot(vec2)) < errorVal;
 }