#include #include "vector2d.h" #include "Common.h" #include "Kernel.h" Kernel::Kernel() { h = h2 = h2inv = 1.0; } Kernel* Kernel::newKernel(DEKernelShape ks) { switch (ks) { case DE_CYLINDER_KERNEL: return new CylinderKernel(); case DE_CONE_KERNEL: return new ConeKernel(); case DE_K2_KERNEL: return new K2Kernel(); case DE_EPANECHNIKOV_KERNEL: return new EpanechnikovKernel(); default: break; } return NULL; } void Kernel::setSize(const float newh) { // Check precondition when debugging. DebugAssert(h>0.0f,"Kernel size is a stricly positive number"); h = newh; h2 = h*h; h2inv = 1.0f / h2; } int Kernel::isInside(const VEC2D &point,const VEC2D ¢er) { VEC2D d; float f; // Use square norm, faster... VEC2DSUBTRACT(point,center,d); f = VEC2DNORM2(d); return (f EPSILON) { // The line intersects the kernel. d = sqrt(disc); i0 = v-d; i1 = v+d; // Check if intersection is on line segment. if (((i0>0.0f)&&(i00.0f)&&(i1