   seen player
  I have this function to see if the ai has seen the playervoid CAi::SeenPlayer(CVector PPosition)// Position of the player{CVector Length;// Get the distancesLength = PPosition - Position;// Get the angledouble TempAngle = atan(Length.x/Length.z);// Convert it to degreesTempAngle = TempAngle*RadToAng;if((TempAngle > -FOV)&&(TempAngle < FOV))}Now it works they why i wanted but there no way to tell if you''re behind or infront of the ai.  How would i tell if the player is infront or behind the ai?  unless someone can tell me a better way of doing it.  I''m going to take the convert to degrees bit out when i get it working. 
  This will die horribly when Length.z is 0.In general, using trigonometry is almost never what you actually want.In this case, I would do this:On start-up, I would calculate cos(FOV) and store it in a variable.When checking, I would do this:void CAi:ointInFOV( CVector point ){  point -= Position();  point.Normalize();  CVector myFront = Orientation().FrontVector();  return myFront.Dot( point ) >= cosFieldOfView;}  The dot of a normalized vector with another normalized vector is the cosine of the angle between those vectors. Which happens to be well defined for "behind" vs "in front".Note that this calculates a cone, not a upwards-aligned pie slice like yours does. If you want the pie slice, project point (after subtraction of position) and myFront to the ground plane before normalizing, then dot and compare.Oh, and if you really need atan() to tell you in front/behind sometime (which you usually shouldn''t do) then atan2() is your friend. ;  Thanks.  Length.x and Length.z will never be 0 anyway though. one question what is Orientation().FrontVector();  at the moment i just have the ai''s angle along the y axis.  how would i calculate the front vector? 