コード例 #1
0
ファイル: stoch.cpp プロジェクト: Snake707/Lux-Aeterna
/*
 * creates normally distributed tryouts
 * the number of iterations is given by iter. The programme terminatse as
 * soon as iter reaches zero. Iter has to be large to generate good
 * approximations.
 * eps is a positive parameter that helps to create deviations each cycle.
 * if eps is negative or zero then the programme terminates with a zero result 
 *
 */
double methastings_normal(int iter, double eps){
	double x=0,test;
	double oldlp=lnormal(x,0.0lf,1.0lf),logp;
	if(eps<=0){
		goto endof;
	}
	while(iter>0){
		test=x+unifab(-eps,eps);
		logp=lnormal(test,x,1.0f);
		if(ln(unif())<logp-oldlp){
			x=test;
			oldlp=logp;
		}
		iter--;
	}
endof:
	return x;
}
コード例 #2
0
bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal)  {
    btVector3 lp(p);
    btVector3 lnormal(normal);

    return pointInTriangle(vertices, lnormal, &lp);
}