Commit 1655f1af authored by Laurent Belcour's avatar Laurent Belcour

Adding parametrizations and infos on parametrizations for Pascal

parent f25b3b52
......@@ -4,6 +4,8 @@ CONFIG *= static \
DESTDIR = ../build
QMAKE_CXXFLAGS += -std=c++11
HEADERS = args.h \
common.h \
data.h \
......@@ -18,4 +20,5 @@ HEADERS = args.h \
SOURCES = plugins_manager.cpp \
vertical_segment.cpp \
rational_function.cpp \
#clustering.cpp
params.cpp \
# clustering.cpp
#include "params.h"
// Assing the input params map
const std::map<params::input, const params::param_info> params::input_map = {
{COS_TH, {"COS_TH", 1, "Cosine of the Half angle"}},
{RUSIN_TH_TD, {"RUSIN_TH_TD", 2, "Radialy symmetric Half angle parametrization"}},
{RUSIN_TH_TD_PD, {"RUSIN_TH_TD_PD", 3, "Isotropic Half angle parametrization"}},
{RUSIN_TH_PH_TD_PD, {"RUSIN_TH_PH_TD_PD", 4, "Complete Half angle parametrization"}},
{SPHERICAL_TL_PL_TV_PV, {"SPHERICAL_TL_PL_TV_PV", 4, "Complete classical parametrization"}},
{CARTESIAN, {"CARTESIAN", 6, "Complete vector parametrization"}}
};
#pragma once
#include <string>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
/*! \brief a static class allowing to change from one parametrization
* to another.
* \ingroup core
......@@ -12,42 +20,53 @@ class params
{
public: // data
//! \brief list of all supported parametrization for the input space.
//! An unsupported parametrization will go under the name
//! <em>unknown</em>.
enum input
{
ROMEIRO_TH_TD,
RUSIN_TH_TD,
RUSIN_TH_PH_TD,
RUSIN_TH_TD_PD,
RUSIN_TH_PH_TD_PD,
COS_TH,
COS_TH_TD,
ISOTROPIC_TV_TL_DPHI,
ISOTROPIC_TD_PD, // Difference between two directions such as R and H
CARTESIAN,
SPHERICAL_TL_PL_TV_PV,
UNKNOWN_INPUT
};
//! \brief list of all supported parametrization for the output space.
//! An unsupported parametrization will go under the name
//! <em>unknown</em>.
enum output
{
INV_STERADIAN,
ENERGY,
RGB_COLOR,
XYZ_COLOR,
UNKNOWN_OUTPUT
};
//! \brief list of all supported parametrization for the input space.
//! An unsupported parametrization will go under the name
//! <em>unknown</em>.
enum input
{
ROMEIRO_TH_TD,
RUSIN_TH_TD,
RUSIN_TH_PH_TD,
RUSIN_TH_TD_PD,
RUSIN_TH_PH_TD_PD,
COS_TH,
COS_TH_TD,
ISOTROPIC_TV_TL_DPHI,
ISOTROPIC_TD_PD, // Difference between two directions such as R and H
CARTESIAN,
SPHERICAL_TL_PL_TV_PV,
UNKNOWN_INPUT
};
//! \brief list of all supported parametrization for the output space.
//! An unsupported parametrization will go under the name
//! <em>unknown</em>.
enum output
{
INV_STERADIAN,
ENERGY,
RGB_COLOR,
XYZ_COLOR,
UNKNOWN_OUTPUT
};
public: // methods
//! \brief parse a string to provide a parametrization type.
static params::input parse_input(const std::string& txt)
{
for(std::map<params::input, const params::param_info>::const_iterator it=input_map.begin(); it != input_map.end(); ++it)
{
if(txt.compare(it->second.name) == 0)
{
return it->first;
}
}
return params::UNKNOWN_INPUT;
/*
if(txt == std::string("COS_TH"))
{
return params::COS_TH;
......@@ -56,10 +75,15 @@ class params
{
return params::RUSIN_TH_TD;
}
else if(txt == std::string("RUSIN_TH_PH_TD_PD"))
{
return params::RUSIN_TH_PH_TD_PD;
}
else
{
return params::UNKNOWN_INPUT;
}
*/
}
//! \brief parse a string to provide a parametrization type.
......@@ -154,6 +178,14 @@ class params
half_to_cartesian(invec[0], invec[1], invec[2], invec[3], outvec);
break;
case params::SPHERICAL_TL_PL_TV_PV:
outvec[0] = cos(invec[1])*sin(invec[0]);
outvec[1] = sin(invec[1])*sin(invec[0]);
outvec[2] = cos(invec[0]);
outvec[3] = cos(invec[3])*sin(invec[2]);
outvec[4] = sin(invec[3])*sin(invec[2]);
outvec[5] = cos(invec[2]);
break;
// 6D Parametrization
case params::CARTESIAN:
......@@ -181,6 +213,9 @@ class params
half[0] /= half_norm;
half[1] /= half_norm;
half[2] /= half_norm;
// Difference vector
double diff[3];
switch(outtype)
{
......@@ -200,8 +235,31 @@ class params
outvec[0] = acos(half[2]);
outvec[1] = atan2(half[0], half[1]);
outvec[2] = acos(half[0]*outvec[0] + half[1]*outvec[1] + half[2]*outvec[2]);
break;
// 4D Parametrization
case params::RUSIN_TH_PH_TD_PD:
outvec[0] = acos(half[2]);
outvec[1] = atan2(half[0], half[1]);
// Compute the diff vector
diff[0] = invec[0];
diff[1] = invec[1];
diff[2] = invec[2];
rotate_normal(diff, -outvec[1]);
rotate_binormal(diff, -outvec[0]);
outvec[2] = acos(diff[2]);
outvec[3] = atan2(diff[0], diff[1]);
break;
case params::SPHERICAL_TL_PL_TV_PV:
outvec[0] = acos(invec[2]);
outvec[1] = atan2(invec[0], invec[1]);
outvec[2] = acos(invec[5]);
outvec[3] = atan2(invec[3], invec[4]);
break;
// 6D Parametrization
case params::CARTESIAN:
memcpy(outvec, invec, 6*sizeof(double));
......@@ -216,6 +274,16 @@ class params
//! \brief provide a dimension associated with a parametrization
static int dimension(params::input t)
{
std::map<params::input, const params::param_info>::const_iterator it = params::input_map.find(t);
if(it != params::input_map.end())
{
return it->second.dimension;
}
else
{
return -1;
}
/*
switch(t)
{
// 1D Parametrizations
......@@ -254,6 +322,7 @@ class params
return -1;
break;
}
*/
}
//! \brief provide a dimension associated with a parametrization
......@@ -332,4 +401,26 @@ class params
vec[0] = cost * vec[0] - sint * vec[2];
vec[2] = sint * vec[0] + cost * vec[2];
}
static void print_input_params()
{
for(std::map<params::input, const params::param_info>::const_iterator it=input_map.begin(); it != input_map.end(); ++it)
{
std::cout << it->second.name << std::endl;
}
}
protected:
struct param_info
{
param_info(std::string n, int d, std::string i) :
name(n), dimension(d), info(i) { };
std::string name;
int dimension;
std::string info;
};
static const std::map<params::input, const params::param_info> input_map;
};
......@@ -32,6 +32,12 @@ int main(int argc, char** argv)
fit = manager.get_fitter() ;
}
if(args.is_defined("available_params"))
{
params::print_input_params();
return 0;
}
if(! args.is_defined("input")) {
std::cerr << "<<ERROR>> the input filename is not defined" << std::endl ;
return 1 ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment