Commit 590dd2fa authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

testing + display real world coordinates, scene coordinates to console

parent 926361c2
...@@ -445,6 +445,7 @@ function x3d_initial_camera_placement(){ ...@@ -445,6 +445,7 @@ function x3d_initial_camera_placement(){
// proper Euler rotation // proper Euler rotation
var R = Mh.mult(Mt).mult(Mr); var R = Mh.mult(Mt).mult(Mr);
//var R = Mr.mult(Mt).mult(Mh);
// convert to proper Euler // convert to proper Euler
var T = x3dom_toYawPitchRoll(); var T = x3dom_toYawPitchRoll();
...@@ -459,6 +460,7 @@ function x3d_initial_camera_placement(){ ...@@ -459,6 +460,7 @@ function x3d_initial_camera_placement(){
// exclude tilt and roll // exclude tilt and roll
var RC0_rw = T.inverse().mult(Mh).mult(T); var RC0_rw = T.inverse().mult(Mh).mult(T);
// what's this?!
var RC_w = R0.inverse().mult(RC0_rw); var RC_w = R0.inverse().mult(RC0_rw);
// store matrices // store matrices
Data.camera.Matrices = { Data.camera.Matrices = {
...@@ -468,6 +470,8 @@ function x3d_initial_camera_placement(){ ...@@ -468,6 +470,8 @@ function x3d_initial_camera_placement(){
}; };
x3dom_setViewpoint(RC_w); x3dom_setViewpoint(RC_w);
//x3dom_setViewpoint(RC0_rw);
//x3dom_setViewpoint(R0);
} }
......
...@@ -129,12 +129,21 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){ ...@@ -129,12 +129,21 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
// to get XZ(horizontal) distance - convert to real world coordinates // to get XZ(horizontal) distance - convert to real world coordinates
var R0 = Data.camera.Matrices.R0; var R0 = Data.camera.Matrices.R0;
var p_w = new x3dom.fields.SFVec3f(x-xc,y-yc,z-zc);
var p_w = new x3dom.fields.SFVec3f(x,y,z);
var p_rw = R0.multMatrixVec(p_w); var p_rw = R0.multMatrixVec(p_w);
var c_w = new x3dom.fields.SFVec3f(xc,yc,zc);
var c_rw = R0.multMatrixVec(c_w);
if (valid_distance){ if (valid_distance){
dist_xz = Math.sqrt(Math.pow(p_rw.x,2)+Math.pow(p_rw.z,2));
dist_xyz = Math.sqrt(Math.pow(p_rw.y,2)+Math.pow(dist_xz,2)); //console.log("D_xz_Local: "+Math.sqrt(Math.pow(p_w.x,2)+Math.pow(p_w.z,2)));
//console.log("D_xz_World: "+Math.sqrt(Math.pow(p_rw.x,2)+Math.pow(p_rw.z,2)));
dist_xz = Math.sqrt(Math.pow(p_rw.x-c_rw.x,2)+Math.pow(p_rw.z-c_rw.z,2));
dist_xyz = Math.sqrt(Math.pow(p_rw.y-c_rw.y,2)+Math.pow(dist_xz,2));
}else{ }else{
dist_xz = null; dist_xz = null;
dist_xyz = null; dist_xyz = null;
...@@ -146,6 +155,16 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){ ...@@ -146,6 +155,16 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
el = Math.atan2(p_rw.y,Math.sqrt(p_rw.x*p_rw.x+p_rw.z*p_rw.z))*180/Math.PI; el = Math.atan2(p_rw.y,Math.sqrt(p_rw.x*p_rw.x+p_rw.z*p_rw.z))*180/Math.PI;
sk = 0; sk = 0;
//distance to previous marker
if (
(index!=null)&&
(index>0)&&
(Data.markers[index]!=undefined)&&
(Data.markers[index-1]!=undefined)
){
console.log("Getting distance to previous point");
}
// fill out the output // fill out the output
var result = { var result = {
x: !round? x : x.toFixed(2), x: !round? x : x.toFixed(2),
...@@ -154,7 +173,13 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){ ...@@ -154,7 +173,13 @@ function x3dom_getXYPosOr(cnvx,cnvy,round){
a: !round? az : az.toFixed(1), a: !round? az : az.toFixed(1),
e: !round? el : el.toFixed(1), e: !round? el : el.toFixed(1),
s: !round? sk : sk.toFixed(1) s: !round? sk : sk.toFixed(1),
real: {
x: !round? p_rw.x:p_rw.x.toFixed(2),
y: !round? p_rw.y:p_rw.y.toFixed(2),
z: !round? p_rw.z:p_rw.z.toFixed(2)
}
}; };
if (dist_xz!=null){ if (dist_xz!=null){
...@@ -508,6 +533,7 @@ function x3dom_matrix_test(){ ...@@ -508,6 +533,7 @@ function x3dom_matrix_test(){
* unrelated: what's x3dom's native getWCtoCCMatrix()? canvas-to-world? * unrelated: what's x3dom's native getWCtoCCMatrix()? canvas-to-world?
*/ */
function x3dom_toYawPitchRoll(){ function x3dom_toYawPitchRoll(){
return new x3dom.fields.SFMatrix4f( return new x3dom.fields.SFMatrix4f(
0, 0,-1, 0, 0, 0,-1, 0,
...@@ -642,6 +668,23 @@ function x3dom_getDistAngle(x,y,z){ ...@@ -642,6 +668,23 @@ function x3dom_getDistAngle(x,y,z){
} }
function x3dom_3d_distance(x,y,z,round){
var d = x3dom_2d_distance(x,z,false);
var res = Math.sqrt(Math.pow(y,2)+Math.pow(d,2));
res = !round? res:res.toFixed(2);
return res;
}
function x3dom_2d_distance(x,z,round){
var res = Math.sqrt(Math.pow(x,2)+Math.pow(z,2));
res = !round? res:res.toFixed(2);
return res;
}
function x3dom_update_map(){ function x3dom_update_map(){
var Camera = Map.marker; var Camera = Map.marker;
......
...@@ -1236,42 +1236,56 @@ X3DOMObject.displayViewInfo = function(e){ ...@@ -1236,42 +1236,56 @@ X3DOMObject.displayViewInfo = function(e){
//Map.marker.setAltitude(camera.y); //Map.marker.setAltitude(camera.y);
//Map.marker.setElevation(camera.e*Math.PI/180); //Map.marker.setElevation(camera.e*Math.PI/180);
var msg = ` var m_dxz = x3dom_2d_distance(mouse.x,mouse.z,true);
<table> var m_dxyz = x3dom_3d_distance(mouse.x,mouse.y,mouse.z,true);
<tr>
<td></td> var m_real_dxz = x3dom_2d_distance(mouse.real.x,mouse.real.z,true);
<td colspan='3' align='center'>position, m</td> var m_real_dxyz = x3dom_3d_distance(mouse.real.x,mouse.real.y,mouse.real.z,true);
<td colspan='3' align='center'>orientation, &deg;</td>
</tr> var log = [
<tr> 'data:',
<th></th> ' scene : x='+mouse.x+' y='+mouse.y+' z='+mouse.z+' d_xz='+m_dxz+' d_xyz='+m_dxyz,
<th style='width:60px;'>x</th> ' world : x='+mouse.real.x+' y='+mouse.real.y+' z='+mouse.real.z+' d_xz='+m_real_dxz+' d_xyz='+m_real_dxyz
<th style='width:60px;'>y</th> ].join('\n');
<th style='width:60px;'>z</th>
<th>azimuth</th> console.log(log);
<th>elevation</th>
<th>skew</th> var msg = [
</tr> '<table>',
<tr> '<tr>',
<td>mouse</td> ' <td></td>',
<td>`+mouse.x+`</td> ' <td colspan=\'3\' align=\'center\'>position, m</td>',
<td>`+mouse.y+`</td> ' <td colspan=\'3\' align=\'center\'>orientation, &deg;</td>',
<td>`+mouse.z+`</td> '</tr>',
<td>`+mouse.a+`</td> '<tr>',
<td>`+mouse.e+`</td> ' <th></th>',
<td>`+mouse.s+`</td> ' <th style=\'width:60px;\'>x</th>',
</tr> ' <th style=\'width:60px;\'>y</th>',
<tr> ' <th style=\'width:60px;\'>z</th>',
<td>camera</td> ' <th>azimuth</th>',
<td>`+camera.x+`</td> ' <th>elevation</th>',
<td>`+camera.y+`</td> ' <th>skew</th>',
<td>`+camera.z+`</td> '</tr>',
<td>`+camera.a+`</td> '<tr>',
<td>`+camera.e+`</td> ' <td>mouse</td>',
<td>`+camera.s+`</td> ' <td>'+mouse.real.x+'</td>',
</tr> ' <td>'+mouse.real.y+'</td>',
</table> ' <td>'+mouse.real.z+'</td>',
`; ' <td>'+mouse.a+'</td>',
' <td>'+mouse.e+'</td>',
' <td>'+mouse.s+'</td>',
'</tr>',
'<tr>',
' <td>camera</td>',
' <td>'+camera.x+'</td>',
' <td>'+camera.y+'</td>',
' <td>'+camera.z+'</td>',
' <td>'+camera.a+'</td>',
' <td>'+camera.e+'</td>',
' <td>'+camera.s+'</td>',
'</tr>',
'</table>'
].join('\n');
if (SETTINGS.viewinfo){ if (SETTINGS.viewinfo){
ui_showMessage("window-viewinfo",msg); ui_showMessage("window-viewinfo",msg);
......
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