Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

main.cpp 6.87 KB
Newer Older
1

2 3 4 5 6 7 8 9 10 11
/* ALTA --- Analysis of Bidirectional Reflectance Distribution Functions

   Copyright (C) 2013 Inria

   This file is part of ALTA.

   This Source Code Form is subject to the terms of the Mozilla Public
   License, v. 2.0.  If a copy of the MPL was not distributed with this
   file, You can obtain one at http://mozilla.org/MPL/2.0/.  */

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#include <core/param.h>

int main(int argc, char** argv) {

	spherical sphericalParam;
	isotropic_tl_tv isotropicParam;

	vec in(4);
	in[0] = 0.0;
	in[1] = 0.0;
	in[2] = 0.0;
	in[3] = 0.0;

	vec out(2);
	sphericalParam.convert_to(in, isotropicParam, out);

	return 0;
}


#ifdef OLD


35 36 37 38 39 40 41 42 43 44 45 46 47
#include <core/args.h>
#include <core/data.h>
#include <core/function.h>
#include <core/fitter.h>
#include <core/plugins_manager.h>

#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
#include <cstdlib>

48 49 50 51 52 53 54 55
#define EPSILON 1.0E-5

bool is_close(double x, double y)
{
	return std::abs(x - y) < EPSILON;
}

int parametrization_tests();
56 57 58 59 60 61 62 63

int main(int argc, char** argv)
{

	int nb_tests_failed = 0;

	// Parametrization tests
	//
64
	nb_tests_failed += parametrization_tests();
65 66 67 68 69 70 71

	// Evaluation tests
	//

	std::cout << "<<INFO>> " << nb_tests_failed << " tests failed" << std::endl;


72 73 74
	return nb_tests_failed;
}

75 76 77 78 79 80 81 82 83 84
bool is_close(const vec& a, const vec& b)
{
	double dist = 0.0;
	for(int i=0; i<a.size(); ++i)
	{
		dist += abs(a[i] - b[i]);
	}
	return dist < 1.0E-10;
}

85 86 87 88 89
int parametrization_tests()
{
	// Params
	int nb_tests_failed = 0;

90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
	
	// Test RUSIN_TH_TD
	vec rhd(2), cart(6), res(6), vh(3);

	// Convert RUSIN_TH_TD (0,0) to CARTESIAN (0,0,1,0,0,1)
	rhd[0] = 0;	rhd[1] = 0;
	res[0] = 0; res[1] = 0; res[2] = 1; res[3] = 0; res[4] = 0; res[5] = 1;
	params::convert(&rhd[0], params::RUSIN_TH_TD, params::CARTESIAN, &cart[0]);
	if(!is_close(cart, res)) {
		nb_tests_failed++;
		std::cout << "<<FAILED>> out = " << cart << ", while attending " << res << std::endl;
	}

	// Convert RUSIN_TH_TD (0,pi/2) to CARTESIAN (1,0,0,-1,0,0)
	rhd[0] = 0;	rhd[1] = M_PI*0.5;
	res[0] = 1; res[1] = 0; res[2] = 0; res[3] = -1; res[4] = 0; res[5] = 0;
	params::convert(&rhd[0], params::RUSIN_TH_TD, params::CARTESIAN, &cart[0]);
	if(!is_close(cart, res)) {
	  	nb_tests_failed++;
		std::cout << "<<FAILED>> out = " << cart << ", while attending " << res << std::endl;
	}

	// Convert RUSIN_TH_TD (0, pi/2) to CARTESIAN (1,0,0,-1,0,0) and to RUSIN_VH (0,0,1)
	rhd[0] = 0;	rhd[1] = M_PI*0.5;
	res[0] = 1; res[1] = 0; res[2] = 0; res[3] = -1; res[4] = 0; res[5] = 0;
	params::convert(&rhd[0], params::RUSIN_TH_TD, params::CARTESIAN, &cart[0]);
	if(!is_close(cart, res)) {
	  	nb_tests_failed++;
		std::cout << "<<FAILED>> out = " << cart << ", while attending " << res << std::endl;
	}
	else
	{
		params::convert(&rhd[0], params::RUSIN_TH_TD, params::RUSIN_VH, &vh[0]);
		res.resize(3); res[0] = 0; res[1] = 0; res[2] = 1;
		if(!is_close(vh, res)) {
			nb_tests_failed++;
			std::cout << "<<FAILED>> out = " << vh << ", while attending " << res << std::endl;
		}
	}
/*
Laurent Belcour's avatar
Laurent Belcour committed
130 131 132 133 134 135 136 137 138 139

	// Test the rotation code
	vec x(3);
	x[0] = 0; x[1] = 0; x[2] = 1;
	params::rotate_binormal(&x[0], 0.5*M_PI);
	std::cout << "<<DEBUG>> x = " << x << std::endl;

	params::rotate_binormal(&x[0], -0.5*M_PI);
	std::cout << "<<DEBUG>> x = " << x << std::endl;
	std::cout << "<<DEBUG>> acos(x[2]) = " << acos(x[2]) << std::endl;
140 141
	
	// Test Rusinkevich parametrization
Laurent Belcour's avatar
Laurent Belcour committed
142
	vec cart(6), spherical(4);
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
	vec rusi(3);

	// Equal directions test, when the PHI_D is ZERO
	rusi[0] = 0.25*M_PI; rusi[1] = 0.0; rusi[2] = 0.0;
	params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::CARTESIAN, &cart[0]);

	const double dot = cart[0]*cart[3] + cart[1]*cart[4] + cart[2]*cart[5];

	if(!is_close(cart[0], cart[3]) || !is_close(cart[1], cart[4]) ||
	   !is_close(cart[2], cart[5]) || !is_close(dot, 1.0))
	{
		std::cout << "<<DEBUG>> rusin 3d: " << rusi << std::endl;
		std::cout << "<<DEBUG>> cartesian: " << cart << std::endl;
		std::cout << "<<DEBUG>> dot: " << dot << std::endl;
		std::cout << std::endl;
		nb_tests_failed++;
	}


Laurent Belcour's avatar
Laurent Belcour committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175
	// Pathological case when THETA_H and THETA_D are equal to
	// PI/4 and PHI_D PI, the conversion seems to fail.
	rusi[0] = 0.759218; rusi[1] = 0.759218; rusi[2] = 3.14159;
	try
	{
		params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
		params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
	}
	catch(...)
	{
		std::cout << "<<ERROR>> the conversion failed" << std::endl;
		std::cout << "<<DEBUG>> rusin 3d: " << rusi << std::endl;
		std::cout << "<<DEBUG>> cartesian: " << spherical << std::endl;
		nb_tests_failed++;
176
    }
Laurent Belcour's avatar
Laurent Belcour committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194


	// Convert issue #1
	vec cart2(6);
	spherical[0] = 0; spherical[1] = 0; spherical[2] = 1.51844; spherical[3] = -2.96706;
	params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::CARTESIAN, &cart2[0]);
	try
	{
		params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
		params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
		params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::CARTESIAN, &cart[0]);
	}
	catch(...)
	{
		std::cout << "<<ERROR>> the conversion failed" << std::endl;
		std::cout << "<<DEBUG>> rusin 3d: " << rusi << std::endl;
		std::cout << "<<DEBUG>> spherical: " << spherical << std::endl;
		nb_tests_failed++;
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
    }



	/// Test on a known couple of directions
	/// in = [0, 0, 1] out = [1, 0, 0]

	// Convert from Cartesian to spherical
	cart[0] = 0; cart[1] = 0; cart[2] = 1; 
	cart[3] = 1; cart[4] = 0; cart[5] = 0; 
    params::convert(&cart[0], params::CARTESIAN, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
	 std::cout << "From cartesian to spherical" << std::endl;
	 std::cout << spherical << std::endl << std::endl;
    
	 params::convert(&cart[0], params::CARTESIAN, params::RUSIN_TH_TD_PD, &rusi[0]);
	 std::cout << "From cartesian to rusi" << std::endl;
    std::cout << rusi << std::endl << std::endl;
    
	 params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::CARTESIAN, &cart[0]);
	 std::cout << "From rusi to cartesian" << std::endl;
    std::cout << cart << std::endl << std::endl;

    params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
	 std::cout << "From spherical to rusi" << std::endl;
    std::cout << rusi << std::endl << std::endl;

    params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
	 std::cout << "From rusi to spherical" << std::endl;
    std::cout << spherical << std::endl << std::endl;

    params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::CARTESIAN, &cart[0]);
	 std::cout << "From rusi to cartesian" << std::endl;
    std::cout << cart << std::endl << std::endl;

    params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
	 std::cout << "From spherical to rusi" << std::endl;
    std::cout << rusi << std::endl << std::endl;
232
*/
233 234
	return nb_tests_failed;
}
235 236

#endif