Commit 760d94bb authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

1. weights 2. zNear fixe

parent 38c56432
......@@ -170,6 +170,13 @@ function hll_dr_dh_i(i,v){
return 1;
}
/**
* weight function
*/
function hll_w_i(i,v){
return 1;
}
/**
* Functions for relative altitude, tilt and roll
......@@ -203,7 +210,7 @@ function art_r_i(i,v){
var f1 = art_f_3d_i(i,v);
var f2 = art_f_map_i(i,v);
//return (f1-f2+360)%360;
return (f1-f2)/art_l_i(i);
return (f1-f2);
}
function art_dr_dx_i(i,v){
......@@ -217,7 +224,7 @@ function art_dr_dx_i(i,v){
res += -Math.sin(v[0])*Math.cos(v[1])*yi;
res += -Math.cos(v[0])*zi;
return res/art_l_i(i);
return res;
}
......@@ -231,7 +238,7 @@ function art_dr_dy_i(i,v){
var res = -Math.cos(v[0])*Math.cos(v[1])*xi;
res += -Math.cos(v[0])*Math.sin(v[1])*yi;
return res/art_l_i(i);
return res;
}
......@@ -246,7 +253,10 @@ function art_l_i(i){
var yi = mark.align.y;
var zi = mark.align.z;
return Math.sqrt(xi*xi+yi*yi+zi*zi);
return Math.sqrt(Math.pow(xi,2)+Math.pow(yi,2)+Math.pow(zi,2));
}
function art_w_i(i,v){
return 1/art_l_i(i);
}
......@@ -38,7 +38,7 @@
* @eps {Number} precision
*
*/
numbers.calculus.GaussNewton = function(v,n,r,dr,eps){
numbers.calculus.GaussNewton = function(v,n,r,dr,eps,w){
var epsilon = eps || 1e-8
var limit = 1000
......@@ -47,6 +47,12 @@ numbers.calculus.GaussNewton = function(v,n,r,dr,eps){
var counter = 0
var v0 = v
if (w===undefined){
w = function(){
return 1;
};
}
while(!stop){
counter++
......@@ -102,13 +108,15 @@ numbers.calculus.GaussNewton = function(v,n,r,dr,eps){
function sigma(v,n,r){
var sum = 0;
var sum = 0
var wsum = 0
for(var i=0;i<n;i++){
sum += r(i,v)*r(i,v)
wsum += w(i,v)
}
sum = Math.sqrt(sum/n)
sum = Math.sqrt(sum/wsum)
return sum
......@@ -122,7 +130,7 @@ numbers.calculus.GaussNewton = function(v,n,r,dr,eps){
var row = []
for(var j=0;j<dr.length;j++){
row.push(dr[j](i,v))
row.push(w(i,v)*dr[j](i,v))
}
J[i] = row
......
......@@ -131,7 +131,7 @@ function x3dom_align_hll(){
var xyh = [x0,y0,(h0>180)?h0-360:h0];
var result = numbers.calculus.GaussNewton(xyh,Data.markers.length,hll_r_i,[hll_dr_dx_i,hll_dr_dy_i,hll_dr_dh_i],epsilon);
var result = numbers.calculus.GaussNewton(xyh,Data.markers.length,hll_r_i,[hll_dr_dx_i,hll_dr_dy_i,hll_dr_dh_i],epsilon,hll_w_i);
xyh = result.v;
var s1 = result.error;
......@@ -271,7 +271,7 @@ function x3dom_align_art(){
}
var epsilon = 1e-8;
var result = numbers.calculus.GaussNewton([0,0,0],Data.markers.length,art_r_i,[art_dr_dx_i,art_dr_dy_i,art_dr_da_i],epsilon);
var result = numbers.calculus.GaussNewton([0,0,0],Data.markers.length,art_r_i,[art_dr_dx_i,art_dr_dy_i,art_dr_da_i],epsilon,art_w_i);
console.log(result);
......
......@@ -99,7 +99,7 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
y = xyz[1];
z = xyz[2];
dist_xz = Math.sqrt(Math.pow(x-xc,2)+Math.pow(z-zc,2));
//dist_xz = Math.sqrt(Math.pow(x-xc,2)+Math.pow(z-zc,2));
}else{
......@@ -107,16 +107,17 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
y = Data.markers[index].y;
z = Data.markers[index].z;
/*
dist_xz = Data.markers[index].d_x3d;
if (isNaN(dist_xz)){
dist_xz = Math.sqrt(Math.pow(x-xc,2)+Math.pow(z-zc,2));;
}
*/
}
dist_xyz = Math.sqrt(Math.pow(y-yc,2)+Math.pow(dist_xz,2));
//dist_xyz = Math.sqrt(Math.pow(y-yc,2)+Math.pow(dist_xz,2));
id = $(shootRay.pickObject).attr("id");
}else{
var viewingRay = elem.runtime.getViewingRay(cnvx,cnvy);
......@@ -125,14 +126,14 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
y = viewingRay.dir.y;
z = viewingRay.dir.z;
dist_xz = null;
dist_xyz = null;
//dist_xz = null;
//dist_xyz = null;
valid_distance = false;
}
var R0 = Data.camera.Matrices.R0;
var p_w = new x3dom.fields.SFVec3f(x,y,z);
var p_w = new x3dom.fields.SFVec3f(x-xc,y-yc,z-zc);
var p_rw = R0.multMatrixVec(p_w);
if (valid_distance){
......
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