/***************************************************************************** * VCGLib o o * * Visual and Computer Graphics Library o o * * _ O _ * * Copyright(C) 2004-2022 \/)\/ * * Visual Computing Lab /\/| * * ISTI - Italian National Research Council | * * \ * * All rights reserved. * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * for more details. * * * ****************************************************************************/ #ifndef __VCGLIB_SHOT #define __VCGLIB_SHOT #include #include #include #include namespace vcg { /** * @class Shot * * 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 * - the Extrinsics parameters, which are stored in the class Shot (type ReferenceFrame) * and that describe viewpoint and view direction. * * Some important notes about the usage of this class: * - The World coordinates system is assumed to be RIGHT-HANDED. * - The Shot reference frame is assumed to be RIGHT-HANDED. * - 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. */ template> class Shot { public: typedef Camera CameraType; typedef S ScalarType; class ReferenceFrame; Camera Intrinsics; // the camera that made the shot ReferenceFrame Extrinsics; // the position and orientation of the camera Shot(); Shot(const Camera& i, const ReferenceFrame& e); Shot(const Camera& c); template static inline Shot Construct(const Shot& b); vcg::Point3 Axis(const int& i) const; const vcg::Point3 GetViewDir() const; const vcg::Point3 GetViewPoint() const; void SetViewPoint(const vcg::Point3& viewpoint); float GetFovFromFocal() const; void LookAt(const vcg::Point3& point, const vcg::Point3& up); void LookAt( const S& eye_x, const S& eye_y, const S& eye_z, const S& at_x, const S& at_y, const S& at_z, const S& up_x, const S& up_y, const S& up_z); void LookTowards(const vcg::Point3& z_dir, const vcg::Point3& up); void ConvertFocalToMM(S ccdwidth); void RescalingWorld(S scalefactor, bool adjustIntrinsics); void ApplyRigidTransformation(const Matrix44& M); void ApplySimilarity(Matrix44 M); void ApplySimilarity(const Similarity& Sim); vcg::Point3 ConvertWorldToCameraCoordinates(const vcg::Point3& p) const; vcg::Point3 ConvertCameraToWorldCoordinates(const vcg::Point3& p) const; vcg::Point3 ConvertCameraToWorldCoordinates_Substitute(const vcg::Point3& p) const; vcg::Point2 Project(const vcg::Point3& p) const; vcg::Point3 UnProject(const vcg::Point2& p, const S& d) const; vcg::Point3 UnProject_Substitute(const vcg::Point2& p, const S& d) const; S Depth(const vcg::Point3& p) const; Matrix44 GetExtrinsicsToWorldMatrix() const; Matrix44 GetWorldToExtrinsicsMatrix() const; void MultMatrix(vcg::Matrix44 m44); void MultSimilarity(const Similarity& s); bool IsValid() const; bool operator==(const Shot& oth) const; bool operator!=(const Shot& oth) const; }; template class Shot::ReferenceFrame { friend class Shot; public: ReferenceFrame(); void SetIdentity(); void SetTra(const Point3& tr); void SetRot(const RotationType& rt); Point3 Tra() const; RotationType Rot() const; bool operator==(const Shot::ReferenceFrame& oth) const; bool operator!=(const Shot::ReferenceFrame& oth) const; private: RotationType rot; // rotation Point3 tra; // viewpoint }; //--- utility definitions typedef Shot Shotf; typedef Shot Shotd; } // namespace vcg #include "shot.ipp" #endif // __VCGLIB_SHOT