// Author : Chris Tolley
// Date   : 7/13/2004
// QuadNode.cpp contains the definition for an abstract base class to use
// in a quad tree.

// DEBUG ONLY!!!!!!!!
#include <iostream>
using namespace std;

#include <math.h>

#include "QuadNode.h"

// Returns true if this node is inside a sphere created from point
// x,z and radius
bool QuadNode::InSphere( float x, float z, float radius )
{
	// Calculate the distance between x,z and this node's midpoint
//	float distance = sqrt( ( ( m_usMidX - x ) * ( m_usMidX - x ) ) +
//						   ( ( m_usMidZ - z ) * ( m_usMidZ - z ) ) );
	float distance = sqrt( ( ( x - m_usMidX ) * ( x - m_usMidX ) ) +
						   ( ( z - m_usMidZ ) * ( z - m_usMidZ ) ) );
//	float distance = fabs( m_usMidX - x ) + fabs( m_usMidZ - z );

	// Return true if distance is less than or equal to the sum of radius
	// and this node's radius
	return distance <= ( radius + m_fRadius );
}// End InteriorQuadNode::InSphere