1 #include "PlusConfigure.h" 14 this->Observation = newObervation;
21 this->Observation.clear();
36 currPoint->put( 0, 0, this->Observation.at(0) );
37 currPoint->put( 1, 0, this->Observation.at(1) );
38 currPoint->put( 2, 0, this->Observation.at(2) );
40 vnl_matrix<double>* rotPoint =
new vnl_matrix<double>( ( *rotation ) * ( *currPoint ) );
41 this->Observation.at(0) = rotPoint->get( 0, 0 );
42 this->Observation.at(1) = rotPoint->get( 1, 0 );
43 this->Observation.at(2) = rotPoint->get( 2, 0 );
50 std::ostringstream xmlstring;
51 std::ostringstream matrixstring;
52 matrixstring <<
"0 0 0 " << this->Observation.at(0) <<
" ";
53 matrixstring <<
"0 0 0 " << this->Observation.at(1) <<
" ";
54 matrixstring <<
"0 0 0 " << this->Observation.at(2) <<
" ";
55 matrixstring <<
"0 0 0 1";
58 xmlstring <<
" TimeStampSec=\"" << 0 <<
"\"";
59 xmlstring <<
" TimeStampNSec=\"" << 0 <<
"\"";
60 xmlstring <<
" type=\"transform\"";
61 xmlstring <<
" DeviceName=\"" <<
"Pointer" <<
"\"";
62 xmlstring <<
" transform=\"" << matrixstring.str() <<
"\"";
63 xmlstring <<
" />" << std::endl;
65 return xmlstring.str();
73 if ( strcmp( element->GetName(),
"log" ) != 0 || strcmp( element->GetAttribute(
"type" ),
"transform" ) != 0 )
78 this->Observation = std::vector<double>( SIZE, 0.0 );
80 std::stringstream matrixstring( std::string( element->GetAttribute(
"transform" ) ) );
83 for (
int i = 0;
i < 16;
i++ )
85 matrixstring >>
value;
88 this->Observation.at(0) =
value;
92 this->Observation.at(1) =
value;
96 this->Observation.at(2) =
value;
106 const double ROTATION_THRESHOLD = 0.005;
107 const double TRANSLATION_THRESHOLD = 0.5;
110 if ( strcmp( currElement->GetName(),
"log" ) != 0 || strcmp( currElement->GetAttribute(
"type" ),
"transform" ) != 0 )
114 if ( strcmp( prevElement->GetName(),
"log" ) != 0 || strcmp( prevElement->GetAttribute(
"type" ),
"transform" ) != 0 )
119 std::stringstream currmatrixstring( std::string( currElement->GetAttribute(
"transform" ) ) );
120 std::stringstream prevmatrixstring( std::string( prevElement->GetAttribute(
"transform" ) ) );
121 double currValue, prevValue;
123 std::vector<double> currRotation, prevRotation;
124 std::vector<double> currTranslation, prevTranslation;
126 for (
int i = 0;
i < 16;
i++ )
128 currmatrixstring >> currValue;
129 prevmatrixstring >> prevValue;
130 if (
i == 0 ||
i == 1 ||
i == 2 ||
i == 4 ||
i == 5 ||
i == 6 ||
i == 8 ||
i == 9 ||
i == 10 )
132 currRotation.push_back( currValue );
133 prevRotation.push_back( prevValue );
135 if (
i == 3 ||
i == 7 ||
i == 11 )
137 currTranslation.push_back( currValue );
138 prevTranslation.push_back( prevValue );
144 this->FromXMLElement( currElement );
static double Distance(std::vector< double > v1, std::vector< double > v2)
void Rotate(vnl_matrix< double > *rotation)
void Translate(std::vector< double > translation)
static std::vector< double > Add(std::vector< double > v1, std::vector< double > v2)
void FromXMLElement(vtkXMLDataElement *element)
std::string ToXMLString()
const char const char * value