Commit 20d91983 authored by Laurent Belcour's avatar Laurent Belcour

Correction of the 3D projected parametrization

Correction of the L2 & Linf distance with respect to the objects params
Updating the example in python
parent 8445c96b
......@@ -144,12 +144,12 @@ double function::L2_distance(const data* d) const
for(int i=0; i<d->size(); ++i)
{
vec dat = d->get(i);
vec x(d->dimX()), y(d->dimY());
for(int j=0; j<d->dimX(); ++j) { x[j] = dat[j]; }
for(int j=0; j<d->dimY(); ++j) { y[j] = dat[d->dimX()+j]; }
vec x(dimX()), y(d->dimY());
params::convert(&dat[0], d->input_parametrization(), input_parametrization(), &x[0]);
for(int j=0; j<d->dimY(); ++j) { y[j] = dat[d->dimX()+j]; }
//linf_dist = std::max<double>(linf_dist, std::abs<double>(norm(y-rj->value(dat))));
l2_dist += std::pow(norm(y-value(x)), 2);
l2_dist += std::pow(norm(y-value(x)), 2);
}
l2_dist = std::sqrt(l2_dist / d->size());
return l2_dist;
......@@ -163,11 +163,11 @@ double function::Linf_distance(const data* d) const
for(int i=0; i<d->size(); ++i)
{
vec dat = d->get(i);
vec x(d->dimX()), y(d->dimY());
for(int j=0; j<d->dimX(); ++j) { x[j] = dat[j]; }
for(int j=0; j<d->dimY(); ++j) { y[j] = dat[d->dimX()+j]; }
vec x(dimX()), y(d->dimY());
params::convert(&dat[0], d->input_parametrization(), input_parametrization(), &x[0]);
for(int j=0; j<d->dimY(); ++j) { y[j] = dat[d->dimX()+j]; }
linf_dist = std::max<double>(linf_dist, std::abs(norm(y-value(dat))));
linf_dist = std::max<double>(linf_dist, std::abs(norm(y-value(x))));
}
return linf_dist;
......
......@@ -137,11 +137,11 @@ void params::to_cartesian(const double* invec, params::input intype,
break;
case ISOTROPIC_TL_TV_PROJ_DPHI:
{
const double theta = 0.5*sqrt(invec[1]*invec[1] + invec[2]*invec[2]);
const double theta = sqrt(invec[1]*invec[1] + invec[2]*invec[2]);
if(theta > 0.0)
{
outvec[3] = invec[1]/theta*sin(theta);
outvec[4] = invec[2]/theta*sin(theta);
outvec[3] = (invec[1]/theta)*sin(theta);
outvec[4] = (invec[2]/theta)*sin(theta);
}
else
{
......
......@@ -18,8 +18,8 @@ int main(int argc, char** argv)
arguments args(argc, argv) ;
if(args.is_defined("help")) {
std::cout << "<<HELP>> data2moments --input data.file --output gnuplot.file --data loader.so" << std::endl ;
std::cout << " - input, output and data are mandatory parameters" << std::endl ;
std::cout << "Usage: data2moments --input data.file --output gnuplot.file --data loader.so" << std::endl ;
std::cout << " -> input, output and data are mandatory parameters" << std::endl ;
return 0 ;
}
......
import math
from vec3 import *
f = open('unitary-proj-params-2d.data', 'w+')
......@@ -37,25 +38,48 @@ def blinn(cost, sigma):
return math.pow(cost, sigma);
#endif
N = 100
M = 3
for t in range(0,M-1):
N = vec3(0.0, 0.0, 1.0)
n = 100
M = 5
for t in range(0,M):
theta_i = 0.5 * math.pi * (t / float(M));
theta_i = 0.5 * math.pi * (t / float(M)) ;
L = vec3()
L.set_spherical(1.0, theta_i, 0.0)
for i in range(0,N):
for j in range(0,N):
x = math.pi*(i / float(N) - 0.5)
y = math.pi*(j / float(N) - 0.5)
R = 2*(N*L)*N - L
for i in range(0,n):
for j in range(0,n):
x = math.pi*(i / float(n) - 0.5)
y = math.pi*(j / float(n) - 0.5)
theta = math.sqrt(x*x + y*y)
if theta > 0.5*math.pi:
continue
dphi = math.atan2(y, x)
V = vec3()
V.set_spherical(1.0, theta, dphi)
H = V+L
H.normalize()
K = R+V
K.normalize()
cos = math.cos(theta_i)*math.cos(theta) - math.sin(theta_i)*math.sin(theta)*math.cos(dphi)
cos = H*N
if cos < 0.0:
cos = 0.0
retrocos = K*N#L*V
if retrocos < 0.0:
retrocos = 0.0
val = blinn(cos, 10);
val = blinn(cos, 300) + blinn(retrocos, 150);
f.write(str(theta_i) + '\t' + str(x) + '\t' + str(y) + '\t' + str(val) + "\n");
#end
......
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