From 181cef32fa74441615d17db06c33b49aa5e84735 Mon Sep 17 00:00:00 2001 From: cignoni Date: Sun, 10 Aug 2014 00:30:20 +0000 Subject: [PATCH] Refactored a bit to allow the conversion of shot and cameras from float to double (added the notoriuous vcg style Construct) --- vcg/math/camera.h | 19 +++++++++++++++++++ vcg/math/shot.h | 23 +++++++++++++++++++---- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/vcg/math/camera.h b/vcg/math/camera.h index 58c9f4aa..101b8030 100644 --- a/vcg/math/camera.h +++ b/vcg/math/camera.h @@ -172,6 +172,25 @@ public: int cameraType; /// Type of camera: PERSPECTIVE,ORTHO,ISOMETRIC,CAVALIERI + + + template + static inline Camera Construct( const Camera &t) + { + Camera n; + n.FocalMm = t.FocalMm; + n.ViewportPx.Import(t.ViewportPx); + n.PixelSizeMm.Import(t.PixelSizeMm); + n.CenterPx.Import(t.CenterPx); + n.DistorCenterPx.Import(t.DistorCenterPx); + n.cameraType =t.cameraType; + n.k[0] = t.k[0]; + n.k[1] = t.k[1]; + n.k[2] = t.k[2]; + n.k[3] = t.k[3]; + return n; + } + void SetOrtho( S l,S r, S b, S t, vcg::Point2 viewport) { cameraType = ORTHO; diff --git a/vcg/math/shot.h b/vcg/math/shot.h index 8070d340..801a2ff0 100644 --- a/vcg/math/shot.h +++ b/vcg/math/shot.h @@ -75,6 +75,8 @@ public: RotoType rot; // rotation Point3 tra; // viewpoint public: + ReferenceFrame(){} + void SetIdentity(){ rot.SetIdentity(); tra = Point3(0.0,0.0,0.0);} void SetTra(const Point3 & tr) {tra = tr;} void SetRot(const RotoType & rt) {rot = rt;} @@ -82,11 +84,15 @@ public: RotoType Rot() const { return rot;} }; - Camera Intrinsics; // the camera that made the shot - ReferenceFrame Extrinsics; // the position and orientation of the camera + Camera Intrinsics; // the camera that made the shot + ReferenceFrame Extrinsics; // the position and orientation of the camera + Shot(const Camera &i, const ReferenceFrame &e) + { + Intrinsics = i; + Extrinsics = e; + } - - Shot(Camera c) + Shot(const Camera &c) { Intrinsics = c; Extrinsics.SetIdentity(); @@ -97,6 +103,15 @@ public: Extrinsics.SetIdentity(); } + template + static inline Shot Construct( const Shot & b ) + { + ReferenceFrame r; + r.SetRot(Matrix44::Construct(b.Extrinsics.Rot())); + r.SetTra(Point3::Construct(b.Extrinsics.Tra())); + return Shot(Camera::Construct(b.Intrinsics), r); + } + /// GET the i-th axis of the coordinate system of the camera vcg::Point3 Axis(const int & i)const;