LSSTApplications  12.1-5-gbdcc3ab,15.0+10,15.0+24,15.0-1-g19261fa+15,15.0-1-g60afb23+24,15.0-1-g615e0bb+16,15.0-1-g6668b0b+6,15.0-1-g788a293+24,15.0-1-ga91101e+24,15.0-1-gae1598d+9,15.0-1-gd076f1f+22,15.0-1-gdf18595+3,15.0-1-gf4f1c34+9,15.0-11-g7db6e543+2,15.0-12-g3681e7a+2,15.0-13-g5992896b,15.0-13-g7441b25,15.0-2-g100d730+17,15.0-2-g1f9c9cf+2,15.0-2-gf38729e+19,15.0-27-g6268be7ac,15.0-3-g11fe1a0+11,15.0-3-g52118bc+2,15.0-3-g707930d+1,15.0-3-g7b706ea+2,15.0-3-g9103c06+9,15.0-3-gd3cbb57+1,15.0-4-g535e784+8,15.0-4-g92ca6c3+2,15.0-4-gf906033,15.0-5-g23e394c+12,15.0-5-g993f083+4,15.0-5-gf788cd9+2,15.0-6-gdf787ba+1,15.0-6-gfa9b38f+2,15.0-7-g949993c+1,15.0-7-gbf600c9+3,15.0-8-gc213bcc,w.2018.20
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