aggiunte conversione di coordinate
This commit is contained in:
parent
8e5824a2bc
commit
c2fb300d85
|
@ -23,6 +23,9 @@
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
History
|
History
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.12 2004/12/16 11:22:30 ricciodimare
|
||||||
|
*** empty log message ***
|
||||||
|
|
||||||
Revision 1.11 2004/12/16 11:21:03 ricciodimare
|
Revision 1.11 2004/12/16 11:21:03 ricciodimare
|
||||||
*** empty log message ***
|
*** empty log message ***
|
||||||
|
|
||||||
|
@ -122,36 +125,57 @@ public:
|
||||||
/// project a point from space 3d (in the reference system of the camera) to the camera's plane
|
/// project a point from space 3d (in the reference system of the camera) to the camera's plane
|
||||||
/// the result is in absolute coordinates
|
/// the result is in absolute coordinates
|
||||||
inline vcg::Point2<S> Project(const vcg::Point3<S> & p);
|
inline vcg::Point2<S> Project(const vcg::Point3<S> & p);
|
||||||
|
inline vcg::Point2<S> LocalToViewport(const vcg::Point2<S> & p);
|
||||||
|
inline vcg::Point2<S> LocalTo_0_1(const vcg::Point2<S> & p);
|
||||||
|
inline vcg::Point2<S> LocalTo_neg1_1(const vcg::Point2<S> & p);
|
||||||
inline vcg::Point3<S> UnProject(const vcg::Point2<S> & p);
|
inline vcg::Point3<S> UnProject(const vcg::Point2<S> & p);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// project a point in the camera plane
|
/// project a point in the camera plane (in space [-1,-1]x[1,1] )
|
||||||
template<class S>
|
template<class S>
|
||||||
vcg::Point2<S> Camera<S>::Project(const vcg::Point3<S> & p){
|
vcg::Point2<S> Camera<S>::Project(const vcg::Point3<S> & p){
|
||||||
S tx = p.X();
|
vcg::Point2<S> q = Point2<S>( p[0],p[1]);
|
||||||
S ty = p.Y();
|
|
||||||
S qx,qy;
|
|
||||||
vcg::Point2<S> q;
|
|
||||||
// nota: per le camere ortogonali viewportM vale 1
|
// nota: per le camere ortogonali viewportM vale 1
|
||||||
if(!IsOrtho())
|
if(!IsOrtho())
|
||||||
{
|
{
|
||||||
tx *= f/p.Z();
|
q[0] *= f/p.Z();
|
||||||
ty *= f/p.Z();
|
q[1] *= f/p.Z();
|
||||||
|
|
||||||
qx = tx;
|
//q[0] = 2*q[0]/( s.X() * viewport[0]);
|
||||||
qy = ty;
|
//q[1] = 2*q[1]/( s.Y() * viewport[1]);
|
||||||
//undistorted_to_distorted_sensor_coord(tx,ty,qx,qy);
|
|
||||||
|
|
||||||
q[0] = qx/s.X()+c.X();
|
|
||||||
q[1] = qy/s.Y()+c.Y();
|
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
q[0] = tx/(s.X()*viewportM)+c.X();
|
// q[0] = tx/(s.X()*viewportM)+c.X();
|
||||||
q[1] = ty/(s.Y()*viewportM)+c.Y();
|
// q[1] = ty/(s.Y()*viewportM)+c.Y();
|
||||||
}
|
//}
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class S>
|
||||||
|
vcg::Point2<S> Camera<S>::LocalToViewport(const vcg::Point2<S> & p){
|
||||||
|
vcg::Point2<S> ps;
|
||||||
|
ps[0] = p[0]/s.X()+c.X();
|
||||||
|
ps[1] = p[1]/s.Y()+c.Y();
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class S>
|
||||||
|
vcg::Point2<S> Camera<S>::LocalTo_0_1(const vcg::Point2<S> & p){
|
||||||
|
vcg::Point2<S> ps;
|
||||||
|
ps[0] = ( p[0]/s.X() + c.X() ) / (ScalarType) viewport[0];
|
||||||
|
ps[1] = ( p[1]/s.Y() + c.Y() ) / (ScalarType) viewport[1];
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class S>
|
||||||
|
vcg::Point2<S> Camera<S>::LocalTo_neg1_1(const vcg::Point2<S> & p){
|
||||||
|
vcg::Point2<S> ps;
|
||||||
|
ps[0] = 2 * p[0] / ( s.X() * viewport[0] );
|
||||||
|
ps[1] = 2 * p[1] / ( s.Y() * viewport[1] );
|
||||||
|
return ps;
|
||||||
|
}
|
||||||
|
|
||||||
/// unproject a point from the camera plane
|
/// unproject a point from the camera plane
|
||||||
template<class S>
|
template<class S>
|
||||||
vcg::Point3<S> Camera<S>::UnProject(const vcg::Point2<S> & p){
|
vcg::Point3<S> Camera<S>::UnProject(const vcg::Point2<S> & p){
|
||||||
|
|
Loading…
Reference in New Issue