fix some comments about the assumption made by the Shot
This commit is contained in:
parent
c35b1c84ff
commit
9349591548
|
@ -94,23 +94,31 @@ creation
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/** class Shot
|
/** class Shot
|
||||||
The shot is made of two things:
|
|
||||||
* the Instrinsics paramaters, which are stored as a Camera type (check vcg/math/camera) and that
|
Shot is made of two elements:
|
||||||
|
|
||||||
|
* the Instrinsics paramaters, which are stored as a Camera type (see vcg/math/camera) and that
|
||||||
determines how a point in the frame of the camera is projected in the 2D projection plane
|
determines how a point in the frame of the camera is projected in the 2D projection plane
|
||||||
|
|
||||||
* the Extrinsics parameters, which are stored in the class Shot (che the type ReferenceFrame)
|
* the Extrinsics parameters, which are stored in the class Shot (type ReferenceFrame)
|
||||||
and that tell viewpoint and view direction.
|
and that describe viewpoint and view direction.
|
||||||
|
|
||||||
The Extrinsics parameters are kept as a rotation matrix "rot" and a translation vector "tra"
|
Some important notes about the usage of this class:
|
||||||
NOTE: the translation matrix "tra" corresponds to -viewpoint while the rotation matrix
|
|
||||||
"rot" corresponds to the axis of the reference frame by row, i.e.
|
|
||||||
rot[0][0|1|2] == X axis
|
|
||||||
rot[1][0|1|2] == Y axis
|
|
||||||
rot[2][0|1|2] == Z axis
|
|
||||||
|
|
||||||
It follows that the matrix made with the upper left 3x3 equal to rot and the 4th colum equal to tra
|
* The World coordinates system is assumed to be RIGHT-HANDED.
|
||||||
and (0,0,0,1) in the bottom row transform a point from world coordiantes to the reference frame
|
* The Shot reference frame is assumed to be RIGHT-HANDED.
|
||||||
of the shot.
|
* The associated Camera is assumed to point in the negative direction of the Z axis of the Shot coordinates system (reference frame).
|
||||||
|
As a consequence, the Camera coordinates system is LEFT-HANDED.
|
||||||
|
* The Extrinsics parameters are kept as a rotation matrix "rot" and a translation vector "tra"
|
||||||
|
The translation matrix "tra" corresponds to the viewpoint of the Shot while the rotation matrix
|
||||||
|
"rot" corresponds to the axis of the reference frame by row, i.e.
|
||||||
|
rot[0][0|1|2] == X axis
|
||||||
|
rot[1][0|1|2] == Y axis
|
||||||
|
rot[2][0|1|2] == Z axis
|
||||||
|
|
||||||
|
It follows that the matrix made with the upper left 3x3 equal to rot and the 4th colum equal to tra
|
||||||
|
and (0,0,0,1) in the bottom row transform a point from world coordiantes to the reference frame
|
||||||
|
of the shot.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,27 +193,29 @@ public:
|
||||||
/// look towards (dir+up)
|
/// look towards (dir+up)
|
||||||
void LookTowards(const vcg::Point3<S> & z_dir,const vcg::Point3<S> & up);
|
void LookTowards(const vcg::Point3<S> & z_dir,const vcg::Point3<S> & up);
|
||||||
|
|
||||||
/// convert a 3d point from world to camera coordinates
|
/// convert a 3d point from world to camera coordinates (do not confuse with the Shot reference frame)
|
||||||
vcg::Point3<S> ConvertWorldToCameraCoordinates(const vcg::Point3<S> & p) const;
|
vcg::Point3<S> ConvertWorldToCameraCoordinates(const vcg::Point3<S> & p) const;
|
||||||
|
|
||||||
/// convert a 3d point from camera to world coordinates
|
/// convert a 3d point from camera (do not confuse with the Shot reference frame) to world coordinates
|
||||||
vcg::Point3<S> ConvertCameraToWorldCoordinates(const vcg::Point3<S> & p) const;
|
vcg::Point3<S> ConvertCameraToWorldCoordinates(const vcg::Point3<S> & p) const;
|
||||||
|
|
||||||
/// convert a 3d point from camera to world coordinates, uses inverse instead of trranspose
|
/* convert a 3d point from camera (do not confuse with the Shot reference frame) to world coordinates
|
||||||
/// for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
* it uses inverse instead of transpose for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
||||||
|
*/
|
||||||
vcg::Point3<S> ConvertCameraToWorldCoordinates_Substitute(const vcg::Point3<S> & p) const;
|
vcg::Point3<S> ConvertCameraToWorldCoordinates_Substitute(const vcg::Point3<S> & p) const;
|
||||||
|
|
||||||
/// project a 3d point from world coordinates to 2d camera viewport (pixel)
|
/// project a 3d point from world coordinates to 2d camera viewport (the value returned is in pixels)
|
||||||
vcg::Point2<S> Project(const vcg::Point3<S> & p) const;
|
vcg::Point2<S> Project(const vcg::Point3<S> & p) const;
|
||||||
|
|
||||||
/// inverse projection from 2d camera viewport (pixel) + Zdepth to 3d world coordinates
|
/// inverse projection from 2d camera viewport (in pixels) to 3d world coordinates (it requires the original depth of the projected point)
|
||||||
vcg::Point3<S> UnProject(const vcg::Point2<S> & p, const S & d) const;
|
vcg::Point3<S> UnProject(const vcg::Point2<S> & p, const S & d) const;
|
||||||
|
|
||||||
/// inverse projection from 2d camera viewport (pixel) + Zdepth to 3d world coordinates, uses inverse instead of trranspose
|
/* inverse projection from 2d camera viewport (in pixels) to 3d world coordinates (it requires the original depth of the projected point)
|
||||||
/// for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
* uses inverse instead of trranspose for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
||||||
|
*/
|
||||||
vcg::Point3<S> UnProject_Substitute(const vcg::Point2<S> & p, const S & d) const;
|
vcg::Point3<S> UnProject_Substitute(const vcg::Point2<S> & p, const S & d) const;
|
||||||
|
|
||||||
/// returns distance of point p from camera plane (z depth), used for unprojection
|
/// returns the distance of point p from camera plane (z depth), required for unprojection operation
|
||||||
S Depth(const vcg::Point3<S> & p)const;
|
S Depth(const vcg::Point3<S> & p)const;
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,7 +242,6 @@ public:
|
||||||
|
|
||||||
/* multiply the current reference frame for the matrix passed
|
/* multiply the current reference frame for the matrix passed
|
||||||
note: it is up to the caller to check the the matrix passed is a pure rototraslation
|
note: it is up to the caller to check the the matrix passed is a pure rototraslation
|
||||||
the matrix can have a scaling component, but is assumed uniform over the rows
|
|
||||||
*/
|
*/
|
||||||
void MultMatrix( vcg::Matrix44<S> m44)
|
void MultMatrix( vcg::Matrix44<S> m44)
|
||||||
{
|
{
|
||||||
|
@ -240,7 +249,6 @@ public:
|
||||||
m44[0][3] = m44[1][3] = m44[2][3] = 0.0; //set no translation
|
m44[0][3] = m44[1][3] = m44[2][3] = 0.0; //set no translation
|
||||||
const S k = m44.GetRow3(0).Norm(); //compute scaling (assumed uniform)
|
const S k = m44.GetRow3(0).Norm(); //compute scaling (assumed uniform)
|
||||||
Extrinsics.rot = Extrinsics.rot * m44.transpose() * (1/k);
|
Extrinsics.rot = Extrinsics.rot * m44.transpose() * (1/k);
|
||||||
Extrinsics.rot.ElementAt(3,3)=S(1.0); //fix back after scaling
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* multiply the current reference frame for the similarity passed
|
/* multiply the current reference frame for the similarity passed
|
||||||
|
@ -335,43 +343,42 @@ void Shot<S,RotationType>::LookTowards(const vcg::Point3<S> & z_dir,const vcg::P
|
||||||
|
|
||||||
//--- Space transformation methods
|
//--- Space transformation methods
|
||||||
|
|
||||||
/// convert a 3d point from world to camera coordinates
|
/// convert a 3d point from world to camera coordinates (do not confuse with the Shot reference frame)
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
vcg::Point3<S> Shot<S,RotationType>::ConvertWorldToCameraCoordinates(const vcg::Point3<S> & p) const
|
vcg::Point3<S> Shot<S,RotationType>::ConvertWorldToCameraCoordinates(const vcg::Point3<S> & p) const
|
||||||
{
|
{
|
||||||
Matrix44<S> rotM;
|
Matrix44<S> rotM;
|
||||||
Extrinsics.rot.ToMatrix(rotM);
|
Extrinsics.rot.ToMatrix(rotM);
|
||||||
vcg::Point3<S> cp = rotM * (p - GetViewPoint() );
|
vcg::Point3<S> cp = rotM * (p - GetViewPoint() );
|
||||||
cp[2]=-cp[2]; // note: camera reference system is right handed
|
cp[2]=-cp[2];
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// convert a 3d point from camera to world coordinates
|
/// convert a 3d point from camera coordinates (do not confuse with the Shot reference frame) to world coordinates
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
vcg::Point3<S> Shot<S,RotationType>::ConvertCameraToWorldCoordinates(const vcg::Point3<S> & p) const
|
vcg::Point3<S> Shot<S,RotationType>::ConvertCameraToWorldCoordinates(const vcg::Point3<S> & p) const
|
||||||
{
|
{
|
||||||
Matrix44<S> rotM;
|
Matrix44<S> rotM;
|
||||||
vcg::Point3<S> cp = p;
|
vcg::Point3<S> cp = p;
|
||||||
cp[2]=-cp[2]; // note: World reference system is left handed
|
cp[2]=-cp[2];
|
||||||
Extrinsics.rot.ToMatrix(rotM);
|
Extrinsics.rot.ToMatrix(rotM);
|
||||||
cp = rotM.transpose() * cp + GetViewPoint();
|
cp = rotM.transpose() * cp + GetViewPoint();
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// convert a 3d point from camera to world coordinates, uses inverse instead of trranspose
|
/// convert a 3d point from camera to world coordinates, uses inverse instead of trranspose for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
||||||
/// for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
vcg::Point3<S> Shot<S,RotationType>::ConvertCameraToWorldCoordinates_Substitute(const vcg::Point3<S> & p) const
|
vcg::Point3<S> Shot<S,RotationType>::ConvertCameraToWorldCoordinates_Substitute(const vcg::Point3<S> & p) const
|
||||||
{
|
{
|
||||||
Matrix44<S> rotM;
|
Matrix44<S> rotM;
|
||||||
vcg::Point3<S> cp = p;
|
vcg::Point3<S> cp = p;
|
||||||
cp[2]=-cp[2]; // note: World reference system is left handed
|
cp[2]=-cp[2];
|
||||||
Extrinsics.rot.ToMatrix(rotM);
|
Extrinsics.rot.ToMatrix(rotM);
|
||||||
cp = Inverse(rotM) * cp + GetViewPoint(); // use invert istead of transpose to dela with non-rigid cases
|
cp = Inverse(rotM) * cp + GetViewPoint();
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// project a 3d point from world coordinates to 2d camera viewport (pixel)
|
/// project a 3d point from world coordinates to 2d camera viewport (the value returned is in pixel)
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
vcg::Point2<S> Shot<S,RotationType>::Project(const vcg::Point3<S> & p) const
|
vcg::Point2<S> Shot<S,RotationType>::Project(const vcg::Point3<S> & p) const
|
||||||
{
|
{
|
||||||
|
@ -381,7 +388,7 @@ vcg::Point2<S> Shot<S,RotationType>::Project(const vcg::Point3<S> & p) const
|
||||||
return vp;
|
return vp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// inverse projection from 2d camera viewport (pixel) + Zdepth to 3d world coordinates
|
/// inverse projection from 2d camera viewport (in pixels) to 3d world coordinates (it requires the original depth of the point to unproject)
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
vcg::Point3<S> Shot<S,RotationType>::UnProject(const vcg::Point2<S> & p, const S & d) const
|
vcg::Point3<S> Shot<S,RotationType>::UnProject(const vcg::Point2<S> & p, const S & d) const
|
||||||
{
|
{
|
||||||
|
@ -391,8 +398,9 @@ vcg::Point3<S> Shot<S,RotationType>::UnProject(const vcg::Point2<S> & p, const S
|
||||||
return wp;
|
return wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// inverse projection from 2d camera viewport (pixel) + Zdepth to 3d world coordinates, uses inverse instead of trranspose
|
/* inverse projection from 2d camera viewport (in pixels) to 3d world coordinates (it requires the original depth of the projected point)
|
||||||
/// for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
* uses inverse instead of trranspose for non-exactly-rigid rotation matrices (such as calculated by tsai and garcia)
|
||||||
|
*/
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
vcg::Point3<S> Shot<S,RotationType>::UnProject_Substitute(const vcg::Point2<S> & p, const S & d) const
|
vcg::Point3<S> Shot<S,RotationType>::UnProject_Substitute(const vcg::Point2<S> & p, const S & d) const
|
||||||
{
|
{
|
||||||
|
@ -402,7 +410,7 @@ vcg::Point3<S> Shot<S,RotationType>::UnProject_Substitute(const vcg::Point2<S> &
|
||||||
return wp;
|
return wp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns distance of point p from camera plane (z depth), used for unprojection
|
/// returns the distance of point p from camera plane (z depth), required for unprojection operation
|
||||||
template <class S, class RotationType>
|
template <class S, class RotationType>
|
||||||
S Shot<S,RotationType>::Depth(const vcg::Point3<S> & p)const
|
S Shot<S,RotationType>::Depth(const vcg::Point3<S> & p)const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue