Exemplo n.º 1
0
void	hsv_to_rgb(t_env *e, double p, double q, double t)
{
	double	hh;
	double	ff;
	int		i;

	hh = e->h / 60;
	i = floor(hh);
	ff = hh - i;
	p = e->v * (1.0 - e->s);
	q = e->v * (1.0 - (e->s * ff));
	t = e->v * (e->s * (1.0 - ff));
	p *= 250;
	q *= 250;
	t *= 250;
	(i == 0) ? hsv0(e, p, t) : 1;
	(i == 1) ? hsv1(e, p, q) : 1;
	(i == 2) ? hsv2(e, p, t) : 1;
	(i == 3) ? hsv3(e, p, q) : 1;
	(i == 4) ? hsv4(e, p, t) : 1;
	if (i == 5)
	{
		e->r = e->v;
		e->g = p;
		e->b = q;
	}
}
Exemplo n.º 2
0
// ---------- begin of function ColorTable::color_dist_hsv --------//
int ColorTable::color_dist_hsv(RGBColor c1, RGBColor c2)
{
	// calculate a distance for the colour
	// h betweeh 0 and 6
	// s between 0 and 1
	// v between 0 and 1
	HSVColor hsv1(rgb2hsv(c1));
	HSVColor hsv2(rgb2hsv(c2));;

	double dx = hsv2.saturation * cos(hsv2.hue * M_PI / 3.0) - hsv1.saturation * cos(hsv1.hue * M_PI / 3.0);
	double dy = hsv2.saturation * sin(hsv2.hue * M_PI / 3.0) - hsv1.saturation * sin(hsv1.hue * M_PI / 3.0);
	double dv = hsv2.brightness - hsv1.brightness;

	return int(10000 * ( dx*dx + dy*dy + dv*dv*BRIGHTNESS_WEIGHTING ));
}
Exemplo n.º 3
0
void CODECHECK_STI_infectivity_curves()
{
	
	/// CHECK ALL INFECTIVITY CURVES
	/// will be plotted in R
	
	ofstream f("./CODECHECK/codecheck_STI_IC.out");
	
	double timestep = 1.0 / 365.0;
	
	Gender defaultgender = female;
	
	// --- Syphilis ---
	
	cout << "CODECHECK: IC Tp (syphilis)"<<endl;
	
	STI s(Tp,"./in_STI.csv");
	
	s.set_is_recurrent(true);
	s.set_is_recurrent_2(true);
	s.set_is_symptomatic(false);

	for (double t=0; t<2; t+=timestep)
		f << "Tp," << t<<","<<s.infectivityCurve(t,defaultgender)<<endl;
	
	s.set_is_symptomatic(true);
	
	for (double t=0; t<2; t+=timestep)
		f << "Tp_condy," << t<<","<<s.infectivityCurve(t,defaultgender)<<endl;

	
	// --- Ct ---
	
	cout << "CODECHECK: IC Ct"<<endl;
	
	STI ct(Ct,"./in_STI.csv");
	
	ct.set_is_symptomatic(false);
	
	for (double t=0; t<2; t+=timestep)
		f << "Ct asymptom," << t<<","<<ct.infectivityCurve(t,defaultgender)<<endl;
	
	ct.set_is_symptomatic(true);
	
	for (double t=0; t<2; t+=timestep)
		f << "Ct symptom," << t<<","<<ct.infectivityCurve(t,defaultgender)<<endl;
	
	
	// --- Ng ---
	
	cout << "CODECHECK: IC Ng"<<endl;
	
	STI ng(Ng,"./in_STI.csv");
	
	//ng.set_is_symptomatic(true);
	
	for (double t=0; t<2; t+=timestep)
		f << "Ng," << t<<","<<ng.infectivityCurve(t,defaultgender)<<endl;
	
	
	// --- Hd ---
	
	cout << "CODECHECK: IC Hd"<<endl;
	
	STI hd(Hd,"./in_STI.csv");
	
	hd.set_is_symptomatic(false);
	
	for (double t=0; t<1; t+=timestep)
		f << "Hd asymptom," << t<<","<<hd.infectivityCurve(t,defaultgender)<<endl;
	
	hd.set_is_symptomatic(true);
	
	for (double t=0; t<1; t+=timestep)
		f << "Hd symptom," << t<<","<<hd.infectivityCurve(t,defaultgender)<<endl;

	
	
	// --- HPV ---
	
	cout << "CODECHECK: IC HPV"<<endl;
	
	STI hpv(HPV,"./in_STI.csv");
	
	hpv.set_is_recurrent(false);
	
	for (double t=0; t<1; t+=timestep)
		f << "HPV not recurrent," << t<<","<<hpv.infectivityCurve(t,defaultgender)<<endl;

	hpv.set_is_recurrent(true);
	
	for (double t=0; t<3; t+=timestep)
		f << "HPV recurrent," << t<<","<<hpv.infectivityCurve(t,defaultgender)<<endl;

	
	// --- HSV2 ---
	
	cout << "CODECHECK: IC HSV2"<<endl;
	
	STI hsv2(HSV2,"./in_STI.csv");
	
	hsv2.set_is_symptomatic(false);
	
	for (double t=0; t<5; t+=timestep)
		f << "HSV2," << t<<","<<hsv2.infectivityCurve(t,defaultgender)<<endl;
	
	hsv2.set_is_symptomatic(true);
	
	for (double t=0; t<5; t+=timestep)
		f << "HSV2 symptomatic," << t<<","<<hsv2.infectivityCurve(t,defaultgender)<<endl;
	
	
	// --- HIV ---
	
	cout << "CODECHECK: IC HIV"<<endl;
	
	STI hiv(HIV,"./in_STI.csv");
	
	for (double t=0; t<12; t+=timestep)
		f << "HIV," << t<<","<<hiv.infectivityCurve(t,defaultgender)<<endl;
	
	
	// --- Tv ---
	
	cout << "CODECHECK: IC Tv"<<endl;
	
	STI tv(Tv,"./in_STI.csv");
	Gender gmale = male;
	
	tv.set_is_symptomatic(false);
	
	for (double t=0; t<2; t+=timestep)
		f << "Tv female asympt," << t<<","<<tv.infectivityCurve(t,defaultgender)<<endl;

	for (double t=0; t<2; t+=timestep)
		f << "Tv male asympt," << t<<","<<tv.infectivityCurve(t,gmale)<<endl;
	
	
	tv.set_is_symptomatic(true);
	
	for (double t=0; t<2; t+=timestep)
		f << "Tv female symptom," << t<<","<<tv.infectivityCurve(t,defaultgender)<<endl;
	
	for (double t=0; t<2; t+=timestep)
		f << "Tv male symptom," << t<<","<<tv.infectivityCurve(t,gmale)<<endl;

}