Ejemplo n.º 1
0
int main()
{
	int N, i, tot, j, num[100];
	while(scanf("%d", &N) !=EOF ) {
		if(!N)
			break;
		for(i = 0; i < N; ++i)
			scanf("%d", &num[i]);
		tot = 0;	
		for(i = 0; i < N; ++i)
			for(j = i+1; j < N; ++j)
				if(!has_common(num[i], num[j]))
					++tot;
		if(tot)			
			printf("%lf\n", sqrt( 6.0/tot*(N*(N-1)/2)) );
		else
			printf("No estimate for this data set.\n");
	}
	return 0;
}
Ejemplo n.º 2
0
//Intersection point of NURBS and straight line.
MGCCisect_list MGRLBRep::isect(const MGStraight& sline) const{
	MGCCisect_list list(this,&sline);
	if(!has_common(sline)) return list;

	MGCParam_list clist;
	double errsave=MGTolerance::wc_zero();
	MGTolerance::set_wc_zero(errsave*.3);//make error smaller.
	if(sdim()<=2 && sline.sdim()<=2) clist=isect_2D(sline);
	else {
		MGPlane plane(sline, mgORIGIN);
			//The plane that includes sline and passes through the origin.
		clist=isect_3D(plane);
	}
	MGTolerance::set_wc_zero(errsave);	//Retrieve error.

	MGPosition p; double t1,t2;
	MGCParam_list::Citerator i;
	for(i=clist.begin(); i!=clist.end(); i++){
		t1=(*i); p=eval(t1);
		if(sline.on(p,t2)) list.append(MGCCisect(p,t1,t2));
	}

	return list;
}