// metaball class
// defines a gaussian function

#pragma once

class metaball
{
public:
	double lambda;
	double sigma;
	vector r0;

	metaball () {
		lambda=0.0;
		sigma=0.0;
	}
	metaball(double lambda_val, double sigma_val, vector center) {
		lambda=lambda_val;
		sigma=sigma_val;
		r0=center;
	}
	double gaussian(vector r) {
		return (lambda * exp(-sigma * length2(r - r0)));
	}
	double dx_gaussian(vector r) {
		return (-2.0*lambda*sigma * (r.x - r0.x) * exp(-sigma * length2(r - r0))); 
	}
	double dy_gaussian(vector r) {
		return (-2.0*lambda*sigma * (r.y - r0.y) * exp(-sigma * length2(r - r0))); 
	}
	double dz_gaussian(vector r) {
		return (-2.0*lambda*sigma * (r.z - r0.z) * exp(-sigma * length2(r - r0))); 
	}
};
