https://github.com/ialhashim/topo-blend
Revision 39b13612ebd645a65eda854771b517371f2f858a authored by ennetws on 13 March 2015, 18:17:18 UTC, committed by ennetws on 13 March 2015, 18:17:18 UTC
1 parent c702819
Raw File
Tip revision: 39b13612ebd645a65eda854771b517371f2f858a authored by ennetws on 13 March 2015, 18:17:18 UTC
Create README.md
Tip revision: 39b1361
ARAPCurveHandle.h
#include "SurfaceMeshHelper.h"
#include "qglviewer/manipulatedFrame.h"
using namespace qglviewer;
using namespace SurfaceMesh;

class ARAPCurveHandle: public ManipulatedFrame{
	Q_OBJECT

public:
	ARAPCurveHandle(const Vector3 & start, double Radius){
		this->startPos = start;
		this->radius = Radius;
		this->setPosition(start.x(), start.y(), start.z());
	}

	Vector3 transform(const Vector3 & originalPos){
		Vector3 d = originalPos - startPos;
		Vec delta(d[0], d[1], d[2]);
		Vec rotatedDelta = this->rotation() * delta;
		Vec r = this->position() + rotatedDelta;
		Vector3 newPos(r.x, r.y, r.z);

		double alpha = 1 - gaussianFunction(((originalPos - startPos).norm() / radius));

		return (originalPos * (alpha)) + (newPos * (1-alpha));
	}

private:
	Vector3 startPos;
	double radius;

	double inline gaussianFunction(double x, double mu = 0.0, double sigma = 2){
		//double a = 1.0 / (sigma * sqrt(2 * M_PI));
		double b = mu;
		double c = sigma;
		return exp( - (pow(x - b, 2) / (2 * pow(c, 2)) ) );
	}
};
back to top