/usr/include/OTB-5.8/otbLineOfSightOptimizer.txx is in libotb-dev 5.8.0+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | /*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef otbLineOfSightOptimizer_txx
#define otbLineOfSightOptimizer_txx
#include "otbLineOfSightOptimizer.h"
#include "vnl/vnl_inverse.h"
namespace otb
{
template <class TPrecision, class TLabel>
LineOfSightOptimizer<TPrecision,TLabel>
::LineOfSightOptimizer()
{
m_Residues.clear();
m_GlobalResidue = 0;
m_InvCumul = vnl_matrix<PrecisionType>(3,3);
m_Identity = vnl_matrix<PrecisionType>(3,3);
m_Identity.fill(0);
m_Identity.fill_diagonal(1.);
m_SecCumul = vnl_vector<PrecisionType>(3);
}
template <class TPrecision, class TLabel>
typename LineOfSightOptimizer<TPrecision,TLabel>::PointType
LineOfSightOptimizer<TPrecision,TLabel>
::Compute(PointSetPointerType pointA, PointSetPointerType pointB)
{
// First, empty the cumulators and residues
m_InvCumul.fill(0);
m_SecCumul.fill(0);
m_Residues.clear();
vnl_matrix<PrecisionType> idMinusViViT(3,3);
vnl_matrix<PrecisionType> vi(3,1);
vnl_vector<PrecisionType> si(3);
PointType result;
//check inputs
if (pointA->GetNumberOfPoints() != pointB->GetNumberOfPoints() ||
pointA->GetNumberOfPoints() < 2)
{
itkExceptionMacro(<<"Points are missing in at least one of the input point sets.");
return result;
}
// iterate over lines of sight
PointSetConstIteratorType itPointA = pointA->GetPoints()->Begin();
PointSetConstIteratorType itPointB = pointB->GetPoints()->Begin();
while (itPointA != pointA->GetPoints()->End() &&
itPointB != pointB->GetPoints()->End())
{
vi(0,0) = itPointB.Value()[0] - itPointA.Value()[0];
vi(1,0) = itPointB.Value()[1] - itPointA.Value()[1];
vi(2,0) = itPointB.Value()[2] - itPointA.Value()[2];
PrecisionType norm_inv = 1. / vcl_sqrt(vi(0,0)*vi(0,0)+vi(1,0)*vi(1,0)+vi(2,0)*vi(2,0));
vi(0,0) *= norm_inv;
vi(1,0) *= norm_inv;
vi(2,0) *= norm_inv;
si(0) = itPointA.Value()[0];
si(1) = itPointA.Value()[1];
si(2) = itPointA.Value()[2];
idMinusViViT = m_Identity - (vi * vi.transpose());
m_InvCumul+=idMinusViViT;
m_SecCumul+=(idMinusViViT * si);
++itPointA;
++itPointB;
}
vnl_vector<PrecisionType> intersection = vnl_inverse(m_InvCumul) * m_SecCumul;
result[0] = intersection[0];
result[1] = intersection[1];
result[2] = intersection[2];
// Compute residues
m_GlobalResidue = 0;
vnl_vector<PrecisionType> AB(3);
vnl_vector<PrecisionType> AC(3);
PrecisionType res2;
itPointA = pointA->GetPoints()->Begin();
itPointB = pointB->GetPoints()->Begin();
while (itPointA != pointA->GetPoints()->End() &&
itPointB != pointB->GetPoints()->End())
{
AB[0] = itPointB.Value()[0] - itPointA.Value()[0];
AB[1] = itPointB.Value()[1] - itPointA.Value()[1];
AB[2] = itPointB.Value()[2] - itPointA.Value()[2];
AC[0] = intersection[0] - itPointA.Value()[0];
AC[1] = intersection[1] - itPointA.Value()[1];
AC[2] = intersection[2] - itPointA.Value()[2];
res2 = std::max(0.0,dot_product(AC,AC) - (dot_product(AB,AC) * dot_product(AB,AC)) / (dot_product(AB,AB)));
m_Residues.push_back( vcl_sqrt( res2 ) );
m_GlobalResidue += res2;
++itPointA;
++itPointB;
}
m_GlobalResidue = vcl_sqrt(m_GlobalResidue);
return result;
}
}
#endif
|