Changeset 17808 for trunk/FACT++
- Timestamp:
- 05/08/14 13:21:44 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/www/viewer/index.js
r17806 r17808 579 579 if (rc.ret!==undefined && Array.isArray(rc.ret)) 580 580 { 581 var now = new Date(); 582 581 583 if (rc.ret[0] instanceof Object) 582 584 processCameraData(1, rc.ret[0]); … … 592 594 if (rc.ret.length>3) 593 595 processCameraData(4, rc.ret[3]); 596 597 debug("Calc Time = "+(new Date()-now)+" ms"); 594 598 } 595 599 … … 1428 1432 var sz = 0; 1429 1433 1434 var mx2 = 0; 1435 var my2 = 0; 1436 var mxy = 0; 1437 1430 1438 var cnt = 0; 1431 1439 for (var i=0; i<1440; i++) … … 1434 1442 continue; 1435 1443 1436 sz += data[i]; 1437 mx += data[i] * coord[i][0]; 1438 my += data[i] * coord[i][1]; 1444 sz += data[i]; 1445 mx += data[i] * coord[i][0]; 1446 my += data[i] * coord[i][1]; 1447 1448 mx2 += data[i] * coord[i][0]*coord[i][0]; 1449 my2 += data[i] * coord[i][1]*coord[i][1]; 1450 mxy += data[i] * coord[i][0]*coord[i][1]; 1439 1451 1440 1452 cnt++; 1441 1453 } 1442 1454 1443 if (sz==0 )1455 if (sz==0 || cnt<3) 1444 1456 return; 1445 1457 1446 mx /= sz; 1447 my /= sz; 1448 1449 if (cnt<3) 1450 return; 1451 1452 var xx=0; 1453 var xy=0; 1454 var yy=0; 1455 1456 for (var i=0; i<1440; i++) 1457 { 1458 if (data[i]===undefined) 1459 continue; 1460 1461 var dx = coord[i][0] - mx; 1462 var dy = coord[i][1] - my; 1463 1464 xx += data[i] * dx*dx; 1465 xy += data[i] * dx*dy; 1466 yy += data[i] * dy*dy; 1467 } 1468 1469 var d0 = yy - xx; 1470 var d1 = xy*2; 1471 var d2 = Math.sqrt(d0*d0 + d1*d1) + d0; 1472 1473 var tand = d2==0 ? 0 : d2 / d1; 1474 var tand2 = tand*tand; 1475 1476 var s2 = tand2+1; 1477 var s = Math.sqrt(s2); 1458 var xx = mx2 - mx*mx/sz; 1459 var yy = my2 - my*my/sz; 1460 var xy = mxy - mx*my/sz; 1461 1462 var d0 = yy - xx; 1463 var d1 = xy*2; 1464 var d2 = Math.sqrt(d0*d0 + d1*d1) + d0; 1478 1465 1479 1466 var phi = 0; … … 1487 1474 if (d1!=0 || d2==0) 1488 1475 { 1476 var tand = d2==0 ? 0 : d2 / d1; 1477 var tand2 = tand*tand; 1478 1479 var s2 = tand2+1; 1480 var s = Math.sqrt(s2); 1481 1489 1482 phi = Math.atan(tand)-Math.PI/2; 1490 1483 cos = 1.0 /s; … … 1500 1493 1501 1494 return { 1502 "mean": [ mx , my],1495 "mean": [ mx/sz, my/sz ], 1503 1496 "axis": [ width, length ], 1504 1497 "phi": phi,
Note:
See TracChangeset
for help on using the changeset viewer.