Commit bb081a11 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

minor changes

parent 590dd2fa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (C) 2017 Elphel Inc. Copyright (C) 2017 Elphel Inc.
License: GPLv3 License: GPL-3.0+
https://www.elphel.com https://www.elphel.com
...@@ -685,6 +685,34 @@ function x3dom_2d_distance(x,z,round){ ...@@ -685,6 +685,34 @@ function x3dom_2d_distance(x,z,round){
} }
function x3dom_scene_to_real(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 {
x: p_rw.x,
y: p_rw.y,
z: p_rw.z
}
}
function x3dom_real_to_scene(x,y,z){
var R0i = Data.camera.Matrices.R0.inverse();
var p_rw = new x3dom.fields.SFVec3f(x,y,z);
var p_w = R0i.multMatrixVec(p_rw);
return {
x: p_w.x,
y: p_w.y,
z: p_w.z
}
}
function x3dom_update_map(){ function x3dom_update_map(){
var Camera = Map.marker; var Camera = Map.marker;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Copyright (C) 2017 Elphel Inc. Copyright (C) 2017 Elphel Inc.
License: GPL-3.0 License: GPL-3.0+
https://www.elphel.com https://www.elphel.com
...@@ -882,6 +882,7 @@ X3DOMObject.Marker.slide = function(index,x,y,z){ ...@@ -882,6 +882,7 @@ X3DOMObject.Marker.slide = function(index,x,y,z){
yc = campos.y; yc = campos.y;
zc = campos.z; zc = campos.z;
// coords are converted to real world inside function
var da = x3dom_getDistAngle(x-xc,y-yc,z-zc); var da = x3dom_getDistAngle(x-xc,y-yc,z-zc);
var distance = da[0]; var distance = da[0];
var angle = da[1]; var angle = da[1];
...@@ -889,6 +890,8 @@ X3DOMObject.Marker.slide = function(index,x,y,z){ ...@@ -889,6 +890,8 @@ X3DOMObject.Marker.slide = function(index,x,y,z){
var p1_ll = Map.marker._latlng; var p1_ll = Map.marker._latlng;
var p2_ll = p1_ll.CoordinatesOf(angle,distance); var p2_ll = p1_ll.CoordinatesOf(angle,distance);
var xyz_real = x3dom_scene_to_real(x,y,z);
var c = Data.markers[index]; var c = Data.markers[index];
c.x = x; c.x = x;
...@@ -904,6 +907,10 @@ X3DOMObject.Marker.slide = function(index,x,y,z){ ...@@ -904,6 +907,10 @@ X3DOMObject.Marker.slide = function(index,x,y,z){
c.align.y = y; c.align.y = y;
c.align.z = z; c.align.z = z;
c.align.real.x = xyz_real.x;
c.align.real.y = xyz_real.y;
c.align.real.z = xyz_real.z;
X3DOMObject.displayMarkInfo(index); X3DOMObject.displayMarkInfo(index);
X3DOMObject.displayInfo({}); X3DOMObject.displayInfo({});
...@@ -1156,14 +1163,23 @@ X3DOMObject.displayInfo = function(e){ ...@@ -1156,14 +1163,23 @@ X3DOMObject.displayInfo = function(e){
id_msg = (st===undefined)?"n/a":st; id_msg = (st===undefined)?"n/a":st;
dist_msg += "<table>"; dist_msg += [
dist_msg += "<tr><th align='center'>shape id</td><td>"+id_msg+"</td></tr>"; '<table>',
dist_msg += "</table>"; ' <tr>',
dist_msg += "<table>"; ' <th align=\'center\'>shape id</td>',
dist_msg += "<tr><th align='left'>d<sub>xz</sub></td><td>"+mouse.d_xz+" m</td>"; ' <td>'+id_msg+'</td>',
dist_msg += "<td>&nbsp;</td>"; ' </tr>',
dist_msg += "<th align='left'>d<sub>xyz</sub></td><td>"+mouse.d_xyz+" m</td></tr>"; '</table>',
dist_msg += "</table>"; '<table>',
' <tr>',
' <th align=\'left\'>d<sub>xz</sub></td>',
' <td>'+mouse.d_xz+' m</td>',
' <td>&nbsp;</td>',
' <th align=\'left\'>d<sub>xyz</sub></td>',
' <td>'+mouse.d_xyz+' m</td>',
' </tr>',
'</table>'
].join('\n');
}else{ }else{
...@@ -1306,7 +1322,6 @@ X3DOMObject.displayMarkInfo = function(index){ ...@@ -1306,7 +1322,6 @@ X3DOMObject.displayMarkInfo = function(index){
if (Data.markers.length==0){ if (Data.markers.length==0){
hide = true; hide = true;
}else{ }else{
msg = "<div>Marker "+index+" (Satellite vs 3D model)</div>";
var d_map = Data.markers[index].d_map; var d_map = Data.markers[index].d_map;
var d_x3d = Data.markers[index].d_x3d; var d_x3d = Data.markers[index].d_x3d;
...@@ -1335,12 +1350,24 @@ X3DOMObject.displayMarkInfo = function(index){ ...@@ -1335,12 +1350,24 @@ X3DOMObject.displayMarkInfo = function(index){
delta = "-"; delta = "-";
} }
msg = [
'<div>Marker '+index+' (Satellite vs 3D model)</div>',
'<table>',
'<tr title=\'drag marker over map to update distance\'>',
' <th align=\'left\'>d<sub>map</sub></th>',
' <td align=\'left\' style=\'text-align:left;\'>'+d_map_msg+'</td>',
'</tr>',
'<tr title=\'drag marker over 3d scene to update distance\'>',
' <th align=\'left\'>d<sub>3d</sub></th>',
' <td align=\'left\' style=\'text-align:left;\'>'+d_x3d_msg+'</td>',
'</tr>',
'<tr>',
' <th align=\'center\'>&Delta;</th>',
' <td align=\'left\' style=\'text-align:left;\'>'+delta+' m</td>',
'</tr>',
'</table>'
].join('\n');
msg += "<table>";
msg += "<tr title='drag marker over map to update distance'><th align='left'>d<sub>map</sub></th><td align='left' style='text-align:left;'>"+d_map_msg+"</td></tr>";
msg += "<tr title='drag marker over 3d scene to update distance'><th align='left'>d<sub>3d</sub></th><td align='left' style='text-align:left;'>"+d_x3d_msg+"</td></tr>";
msg += "<tr><th align='center'>&Delta;</th><td align='left' style='text-align:left;'>"+delta+" m</td></tr>";
msg += "</table>";
} }
if (hide||!SETTINGS.markinfo){ if (hide||!SETTINGS.markinfo){
...@@ -1353,21 +1380,30 @@ X3DOMObject.displayMarkInfo = function(index){ ...@@ -1353,21 +1380,30 @@ X3DOMObject.displayMarkInfo = function(index){
X3DOMObject.createNewMarker = function(x,y,z){ X3DOMObject.createNewMarker = function(x,y,z){
console.log("Create marker");
x = parseFloat(x);
y = parseFloat(y);
z = parseFloat(z);
var Camera = Map.marker; var Camera = Map.marker;
// Create marker for Data // Create marker for Data
var color = SETTINGS.markercolor; var color = SETTINGS.markercolor;
color = AUTOCOLORS[Data.markers.length%AUTOCOLORS.length]; color = AUTOCOLORS[Data.markers.length%AUTOCOLORS.length];
var xyz_real = x3dom_scene_to_real(x,y,z);
var mark = new X3L({ var mark = new X3L({
x: parseFloat(x) || 0, x: x || 0,
y: parseFloat(y) || 0, y: y || 0,
z: parseFloat(z) || 0, z: z || 0,
color: color, color: color,
size: SETTINGS.markersize, size: SETTINGS.markersize,
}); });
mark.d_x3d = Math.sqrt(mark.x*mark.x+mark.z*mark.z); mark.d_x3d = Math.sqrt(Math.pow(xyz_real.x,2)+Math.pow(xyz_real.z,2));
//mark.d_x3d = Math.sqrt(Math.pow(x,2)+Math.pow(z,2));
mark.d_map = "<font style='color:red;'>drag over map</font>"; mark.d_map = "<font style='color:red;'>drag over map</font>";
mark.align = { mark.align = {
...@@ -1376,7 +1412,12 @@ X3DOMObject.createNewMarker = function(x,y,z){ ...@@ -1376,7 +1412,12 @@ X3DOMObject.createNewMarker = function(x,y,z){
altitude: 0, altitude: 0,
x: mark.x, x: mark.x,
y: mark.y, y: mark.y,
z: mark.z z: mark.z,
real:{
x: xyz_real.x,
y: xyz_real.y,
z: xyz_real.z,
}
}; };
Data.markers.push(mark); Data.markers.push(mark);
...@@ -1393,6 +1434,7 @@ X3DOMObject.createNewMarker = function(x,y,z){ ...@@ -1393,6 +1434,7 @@ X3DOMObject.createNewMarker = function(x,y,z){
zc = campos.z; zc = campos.z;
// calculate relative to the camera base // calculate relative to the camera base
// converted to real world inside the function
var da = x3dom_getDistAngle(mark.x-xc,mark.y-yc,mark.z-zc); var da = x3dom_getDistAngle(mark.x-xc,mark.y-yc,mark.z-zc);
var distance = da[0]; var distance = da[0];
var angle = da[1]; var angle = da[1];
......
...@@ -56,8 +56,9 @@ ...@@ -56,8 +56,9 @@
<scene> <scene>
<navigationInfo id="navInfo" type='"examine"' speed='0.01'></navigationInfo> <navigationInfo id="navInfo" type='"examine"' speed='0.01'></navigationInfo>
<!--<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' ></Viewpoint>--> <!--<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' ></Viewpoint>-->
<!-- in x3dom 1.7.2 - big zNear does not work properly --> <!-- in x3dom 1.7.2 - bug: zNear does not work properly -->
<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' zNear='3'></Viewpoint> <!--<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0' zNear='3'></Viewpoint>-->
<Viewpoint fieldOfView='1' position='0 0 0' orientation='0 0 1 0'></Viewpoint>
<!-- <group> <!-- <group>
<inline name="back" namespacename="back" url="models/m1/v1/background.x3d"/> <inline name="back" namespacename="back" url="models/m1/v1/background.x3d"/>
</group>--> </group>-->
...@@ -71,9 +72,9 @@ ...@@ -71,9 +72,9 @@
<div id='crosshair_v' class='crosshair'></div> <div id='crosshair_v' class='crosshair'></div>
<div id='help_wrapper'> <div id='help_wrapper'>
<div id='exit_button' title='Exit to models index'></div> <div id='exit_button' title='Exit to models index'></div>
<div id='help_button'>?</div> <div id='help_button' title='Help'>?</div>
<div id='download_button' title='Download 3d model (.obj & .x3d formats)'></div> <div id='download_button' title='Download 3d model (.obj & .x3d formats)'></div>
<div id='menu_button'></div> <div id='menu_button' title='Menu'></div>
<div id='align_button' title='Run least squares fitting algorithm (Gauss-Newton) for camera heading and location using markers. <div id='align_button' title='Run least squares fitting algorithm (Gauss-Newton) for camera heading and location using markers.
Instructions: Instructions:
1. Use approximate location control on the map to change initial approximation for the algorithm. 1. Use approximate location control on the map to change initial approximation for the algorithm.
......
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