LSSTApplications  12.1-5-gbdcc3ab+2,15.0+13,15.0+26,15.0-1-g19261fa+17,15.0-1-g60afb23+26,15.0-1-g615e0bb+18,15.0-1-g788a293+26,15.0-1-ga91101e+26,15.0-1-gae1598d+12,15.0-1-gd076f1f+24,15.0-1-gdf18595+5,15.0-1-gf4f1c34+12,15.0-11-g7db6e543+4,15.0-12-g3681e7a+4,15.0-15-gc15de322,15.0-16-g83b84f4,15.0-2-g100d730+19,15.0-2-g1f9c9cf+4,15.0-2-g8aea5f4+1,15.0-2-gf38729e+21,15.0-29-ga12a2b06e,15.0-3-g11fe1a0+14,15.0-3-g707930d+3,15.0-3-g9103c06+12,15.0-3-gd3cbb57+3,15.0-4-g2d82b59,15.0-4-g535e784+10,15.0-4-g92ca6c3+4,15.0-4-gf906033+2,15.0-5-g23e394c+14,15.0-5-g4be42a9,15.0-6-g69628aa,15.0-6-g86e3f3d+1,15.0-6-gfa9b38f+4,15.0-7-g949993c+3,15.0-8-g67a62d3+1,15.0-8-gcf05001+1,15.0-9-g1e7c341+1,w.2018.21
LSSTDataManagementBasePackage
Orientation.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  * Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014 LSST Corporation.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <http://www.lsstcorp.org/LegalNotices/>.
21  */
22 
24 
25 namespace lsst {
26 namespace afw {
27 namespace cameraGeom {
28 
29 Orientation::Orientation(geom::Point2D const fpPosition, geom::Point2D const refPoint, geom::Angle const yaw,
30  geom::Angle const pitch, geom::Angle const roll)
31  : _fpPosition(fpPosition), _refPoint(refPoint), _yaw(yaw), _pitch(pitch), _roll(roll), _rotMat() {
32  double cosYaw = std::cos(_yaw);
33  double sinYaw = std::sin(_yaw);
34  double cosPitch = std::cos(_pitch);
35  double sinPitch = std::sin(_pitch);
36  double cosRoll = std::cos(_roll);
37  double sinRoll = std::sin(_roll);
38 
39  // This comes from the rotation matrix written down here:
40  // http://en.wikipedia.org/wiki/Euler_angles
41  // for Tait-Bryan angles Z_1Y_2X_3
42  // _rotMat = coeffA coeffB
43  // coeffD coeffE
44  _rotMat << cosYaw * cosPitch, cosYaw * sinPitch * sinRoll - cosRoll * sinYaw, cosPitch * sinYaw,
45  cosYaw * cosRoll + sinYaw * sinPitch * sinRoll;
46 }
47 
48 Orientation::~Orientation() = default;
49 Orientation::Orientation(Orientation const &) = default;
53 
55  float yawDeg = _yaw.asDegrees();
56  while (yawDeg < 0.) {
57  yawDeg += 360.;
58  }
59  return std::floor((yawDeg + 45.) / 90.);
60 }
61 
63  geom::Extent2D const pixelSizeMm) const {
64  // jacobian = coeffA*pixelSizeMmX, coeffB*pixelSizeMmY,
65  // coeffD*pixelSizeMmX, coeffE*pixelSizeMmY
66  Eigen::Matrix2d jacobian =
67  _rotMat.array() * (Eigen::Vector2d::Ones() * pixelSizeMm.asEigen().transpose()).array();
68 
69  Eigen::Vector2d refMm = pixelSizeMm.asEigen().array() * _refPoint.asEigen().array();
70  Eigen::Vector2d translation = _fpPosition.asEigen() - (_rotMat * refMm);
71 
73  return geom::makeTransform(affineTransform);
74 }
75 
77  geom::Extent2D const pixelSizeMm) const {
78  return makePixelFpTransform(pixelSizeMm)->getInverse();
79 }
80 } // namespace cameraGeom
81 } // namespace afw
82 } // namespace lsst
Orientation(geom::Point2D const fpPosition=geom::Point2D(0, 0), geom::Point2D const refPoint=geom::Point2D(-0.5, -0.5), geom::Angle const yaw=geom::Angle(0), geom::Angle const pitch=geom::Angle(0), geom::Angle const roll=geom::Angle(0))
Definition: Orientation.cc:29
std::shared_ptr< geom::TransformPoint2ToPoint2 > makeFpPixelTransform(geom::Extent2D const pixelSizeMm) const
Generate a Transform from focal plane to pixel coordinates.
Definition: Orientation.cc:76
T floor(T... args)
Describe a detector&#39;s orientation in the focal plane.
Definition: Orientation.h:51
int getNQuarter() const
Return the number of quarter turns (rounded to the closest quarter)
Definition: Orientation.cc:54
T sin(T... args)
EigenVector const & asEigen() const
Return a fixed-size Eigen representation of the coordinate object.
A class representing an angle.
Definition: Angle.h:102
A base class for image defects.
Definition: cameraGeom.dox:3
An affine coordinate transformation consisting of a linear transformation and an offset.
std::shared_ptr< geom::TransformPoint2ToPoint2 > makePixelFpTransform(geom::Extent2D const pixelSizeMm) const
Generate a Transform from pixel to focal plane coordinates.
Definition: Orientation.cc:62
T cos(T... args)
std::shared_ptr< TransformPoint2ToPoint2 > makeTransform(AffineTransform const &affine)
Wrap an AffineTransform as a Transform.
Orientation & operator=(Orientation const &)
constexpr double asDegrees() const noexcept
Return an Angle&#39;s value in degrees.
Definition: Angle.h:144