Removed Similarity from Shot

Problem: Shot was using similarity merely to store
rotation and translation. 
There was an incompatibility in that Similarity::ToMatrix
gives scale*rotation*translation while in Shot
the translation stores the viewpoint and the rotation the orientation of the Shot.

In this version, a small class ReferenceFrame was done to play the role of similarity and MultMatrix and MultSimilarity functions were added to transform the frame by multiplying it for a Matrix44 (or applying a similarity).

NOTE: the file export_ply.ply and import_ply.h must also be updated.

-- only compiled with .net ---
This commit is contained in:
ganovelli 2008-09-26 17:05:49 +00:00
parent e5258c6aa3
commit 8acc6a4e2c
2 changed files with 38 additions and 37 deletions

View File

@ -359,18 +359,18 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
{ {
float t[17]; float t[17];
t[ 0] = (float)-m.shot.Extrinsics.tra[0]; t[ 0] = (float)m.shot.Extrinsics.Tra()[0];
t[ 1] = (float)-m.shot.Extrinsics.tra[1]; t[ 1] = (float)m.shot.Extrinsics.Tra()[1];
t[ 2] = (float)-m.shot.Extrinsics.tra[2]; t[ 2] = (float)m.shot.Extrinsics.Tra()[2];
t[ 3] = (float)m.shot.Extrinsics.rot[0][0]; t[ 3] = (float)m.shot.Extrinsics.Rot()[0][0];
t[ 4] = (float)m.shot.Extrinsics.rot[0][1]; t[ 4] = (float)m.shot.Extrinsics.Rot()[0][1];
t[ 5] = (float)m.shot.Extrinsics.rot[0][2]; t[ 5] = (float)m.shot.Extrinsics.Rot()[0][2];
t[ 6] = (float)m.shot.Extrinsics.rot[1][0]; t[ 6] = (float)m.shot.Extrinsics.Rot()[1][0];
t[ 7] = (float)m.shot.Extrinsics.rot[1][1]; t[ 7] = (float)m.shot.Extrinsics.Rot()[1][1];
t[ 8] = (float)m.shot.Extrinsics.rot[1][2]; t[ 8] = (float)m.shot.Extrinsics.Rot()[1][2];
t[ 9] = (float)m.shot.Extrinsics.rot[2][0]; t[ 9] = (float)m.shot.Extrinsics.Rot()[2][0];
t[10] = (float)m.shot.Extrinsics.rot[2][1]; t[10] = (float)m.shot.Extrinsics.Rot()[2][1];
t[11] = (float)m.shot.Extrinsics.rot[2][2]; t[11] = (float)m.shot.Extrinsics.Rot()[2][2];
t[12] = (float)m.shot.Intrinsics.FocalMm; t[12] = (float)m.shot.Intrinsics.FocalMm;
t[13] = (float)m.shot.Intrinsics.PixelSizeMm[0]; t[13] = (float)m.shot.Intrinsics.PixelSizeMm[0];
t[14] = (float)m.shot.Intrinsics.PixelSizeMm[1]; t[14] = (float)m.shot.Intrinsics.PixelSizeMm[1];
@ -389,18 +389,18 @@ static int Save(SaveMeshType &m, const char * filename, bool binary, PlyInfo &p
else else
{ {
fprintf(fpout,"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d %d %g %g %g %g\n" fprintf(fpout,"%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %d %d %g %g %g %g\n"
,-m.shot.Extrinsics.tra[0] ,-m.shot.Extrinsics.Tra()[0]
,-m.shot.Extrinsics.tra[1] ,-m.shot.Extrinsics.Tra()[1]
,-m.shot.Extrinsics.tra[2] ,-m.shot.Extrinsics.Tra()[2]
,m.shot.Extrinsics.rot[0][0] ,m.shot.Extrinsics.Rot()[0][0]
,m.shot.Extrinsics.rot[0][1] ,m.shot.Extrinsics.Rot()[0][1]
,m.shot.Extrinsics.rot[0][2] ,m.shot.Extrinsics.Rot()[0][2]
,m.shot.Extrinsics.rot[1][0] ,m.shot.Extrinsics.Rot()[1][0]
,m.shot.Extrinsics.rot[1][1] ,m.shot.Extrinsics.Rot()[1][1]
,m.shot.Extrinsics.rot[1][2] ,m.shot.Extrinsics.Rot()[1][2]
,m.shot.Extrinsics.rot[2][0] ,m.shot.Extrinsics.Rot()[2][0]
,m.shot.Extrinsics.rot[2][1] ,m.shot.Extrinsics.Rot()[2][1]
,m.shot.Extrinsics.rot[2][2] ,m.shot.Extrinsics.Rot()[2][2]
,m.shot.Intrinsics.FocalMm ,m.shot.Intrinsics.FocalMm
,m.shot.Intrinsics.PixelSizeMm[0] ,m.shot.Intrinsics.PixelSizeMm[0]
,m.shot.Intrinsics.PixelSizeMm[1] ,m.shot.Intrinsics.PixelSizeMm[1]

View File

@ -605,22 +605,23 @@ static int Open( OpenMeshType &m, const char * filename, PlyInfo &pi )
// extrinsic // extrinsic
m.shot.Extrinsics.SetIdentity(); m.shot.Extrinsics.SetIdentity();
// view point // view point
m.shot.Extrinsics.tra[0] = -ca.view_px; m.shot.Extrinsics.SetTra(Point3<ScalarType>( ca.view_px,ca.view_py,ca.view_pz));
m.shot.Extrinsics.tra[1] = -ca.view_py;
m.shot.Extrinsics.tra[2] = -ca.view_pz;
// axis (i.e. rotation). // axis (i.e. rotation).
m.shot.Extrinsics.rot[0][0] = ca.x_axisx; Matrix44<ScalarType> rm;
m.shot.Extrinsics.rot[0][1] = ca.x_axisy; rm[0][0] = ca.x_axisx;
m.shot.Extrinsics.rot[0][2] = ca.x_axisz; rm[0][1] = ca.x_axisy;
rm[0][2] = ca.x_axisz;
m.shot.Extrinsics.rot[1][0] = ca.y_axisx; rm[1][0] = ca.y_axisx;
m.shot.Extrinsics.rot[1][1] = ca.y_axisy; rm[1][1] = ca.y_axisy;
m.shot.Extrinsics.rot[1][2] = ca.y_axisz; rm[1][2] = ca.y_axisz;
m.shot.Extrinsics.rot[2][0] = ca.z_axisx; rm[2][0] = ca.z_axisx;
m.shot.Extrinsics.rot[2][1] = ca.z_axisy; rm[2][1] = ca.z_axisy;
m.shot.Extrinsics.rot[2][2] = ca.z_axisz; rm[2][2] = ca.z_axisz;
m.shot.Extrinsics.SetRot(rm);
//intrinsic //intrinsic
m.shot.Intrinsics.FocalMm = ca.focal; m.shot.Intrinsics.FocalMm = ca.focal;