Commit 2df437f7 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

switched to real world coordinates

parent 23871976
...@@ -48,6 +48,10 @@ function align_init(){ ...@@ -48,6 +48,10 @@ function align_init(){
x3dom_align_GN(); x3dom_align_GN();
}); });
$("#align_tr_button").on("click",function(){
x3dom_align_tr();
});
/* /*
$("#align_0").on("click",function(){ $("#align_0").on("click",function(){
x3dom_align_0(); x3dom_align_0();
...@@ -381,6 +385,32 @@ function distance_error(x,y,h){ ...@@ -381,6 +385,32 @@ function distance_error(x,y,h){
} }
function x3dom_align_tr(){
if (Data.markers.length<2){
console.log("Too few points");
return;
}
var mark0 = Data.markers[0];
var mark1 = Data.markers[1];
var v0 = { x: mark0.align.x, y: mark0.align.y, z: mark0.align.z};
var v1 = { x: mark1.align.x, y: mark1.align.y, z: mark1.align.z};
var dx = Math.abs(v1.x-v0.x);
var dy = Math.abs(v1.y-v0.y);
var dz = Math.abs(v1.z-v0.z);
console.log(dx+" "+dy+" "+dz);
var tilt = 180/Math.PI*Math.asin(dy/Math.sqrt(dy*dy+dz*dz));
var roll = 180/Math.PI*Math.asin(dy/Math.sqrt(dy*dy+dx*dx));
console.log("Tilt: "+tilt+" Roll: "+roll);
}
/* /*
* not used * not used
*/ */
......
...@@ -617,9 +617,12 @@ function leaf_events(){ ...@@ -617,9 +617,12 @@ function leaf_events(){
p_w = x3dom_delta_map2scene(p1_ll,p2_ll); p_w = x3dom_delta_map2scene(p1_ll,p2_ll);
mark.x = p_w.x; //conversion to real world coordinates
mark.y = p_w.y; var p_rw = xyz_to_real_world(p_w.x,p_w.y,p_w.z);
mark.z = p_w.z;
mark.x = p_rw.x;
mark.y = p_rw.y;
mark.z = p_rw.z;
mark.d_map = distance; mark.d_map = distance;
...@@ -777,7 +780,7 @@ function leaf_drag_marker(){ ...@@ -777,7 +780,7 @@ function leaf_drag_marker(){
var index = Camera.draggedMarker._index; var index = Camera.draggedMarker._index;
var p1_ll = Camera._latlng; var p1_ll = Camera._latlng;
var p2_ll = Camera.draggedMarker._latlng; var p2_ll = Camera.draggedMarker.__latlng;
leaf_update_x3dom_marker(p1_ll,p2_ll,index); leaf_update_x3dom_marker(p1_ll,p2_ll,index);
X3DOMObject.displayMarkInfo(index); X3DOMObject.displayMarkInfo(index);
......
...@@ -78,3 +78,12 @@ function getAzimuth(p1_ll,p2_ll){ ...@@ -78,3 +78,12 @@ function getAzimuth(p1_ll,p2_ll){
return azimuth; return azimuth;
} }
function xyz_to_real_world(x,y,z){
var R0 = Data.camera.Matrices.R0;
var p_w = new x3dom.fields.SFVec3f(x,y,z);
var p_rw = R0.multMatrixVec(p_w);
return [p_rw.x,p_rw.y,p_rw.z];
}
...@@ -118,6 +118,11 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){ ...@@ -118,6 +118,11 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
var p_w = new x3dom.fields.SFVec3f(x,y,z); var p_w = new x3dom.fields.SFVec3f(x,y,z);
var p_rw = R0.multMatrixVec(p_w); var p_rw = R0.multMatrixVec(p_w);
//conversion to real world coordinates
x = p_rw.x;
y = p_rw.y;
z = p_rw.z;
if (valid_distance){ if (valid_distance){
dist_xz = Math.sqrt(p_rw.x*p_rw.x+p_rw.z*p_rw.z); dist_xz = Math.sqrt(p_rw.x*p_rw.x+p_rw.z*p_rw.z);
dist_xyz = Math.sqrt(p_rw.y*p_rw.y+dist_xz*dist_xz); dist_xyz = Math.sqrt(p_rw.y*p_rw.y+dist_xz*dist_xz);
...@@ -185,6 +190,10 @@ function x3dom_getCameraPosOr(round){ ...@@ -185,6 +190,10 @@ function x3dom_getCameraPosOr(round){
//x3dom_matrix_test(); //x3dom_matrix_test();
//conversion to real world coordinates
var tmp = xyz_to_real_world(tr.x,tr.y,tr.z);
tr = new x3dom.fields.SFVec3f(tmp[0],tmp[1],tmp[2]);
if (!round){ if (!round){
return { return {
x: tr.x, x: tr.x,
......
...@@ -75,6 +75,8 @@ Instructions: ...@@ -75,6 +75,8 @@ Instructions:
3. Move all markers on the map to update their location - drag to position more precisely. 3. Move all markers on the map to update their location - drag to position more precisely.
4. Click this button - the results will appear in a dialog window with "apply"/"cancel" 4. Click this button - the results will appear in a dialog window with "apply"/"cancel"
5. To save the result click upload button (Initial location and heading) in the menu.' class='edit'></div> 5. To save the result click upload button (Initial location and heading) in the menu.' class='edit'></div>
<!--<div id='align_tr_button' title='Align tilt and roll' class='edit'></div>-->
<div id='align_tr_button' title='Align tilt and roll' class='experimental'></div>
</div> </div>
<div id='info-wrapper'> <div id='info-wrapper'>
<div id='window-info'></div> <div id='window-info'></div>
......
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