LSSTApplications  11.0-24-g0a022a1,12.1-4-g110c6f4+31,15.0+14,15.0+9,15.0-1-g19261fa+6,15.0-1-g60afb23+14,15.0-1-g615e0bb+6,15.0-1-g6668b0b+5,15.0-1-g788a293+14,15.0-1-ga91101e+14,15.0-1-gae1598d+8,15.0-1-gd076f1f+13,15.0-1-gdf18595+2,15.0-1-gf4f1c34+8,15.0-2-g100d730+7,15.0-2-g18f3f21+8,15.0-2-g20c4630+2,15.0-2-g35685a8+9,15.0-2-g5dfaa72+2,15.0-2-gf38729e+8,15.0-23-g309a1dfe0,15.0-3-g150fc43+17,15.0-3-g6f085af+7,15.0-3-g707930d,15.0-3-g9103c06+8,15.0-3-ga03b4ca+20,15.0-3-gaec6799+5,15.0-4-g45f767a+8,15.0-4-g5589a47,15.0-4-g654b129+12,15.0-4-gff20472+17,15.0-5-g0db841d+1,15.0-5-g23e394c+1,15.0-6-g86eaddf,15.0-6-g9a9df217+9,15.0-8-g11095dd,15.0-8-g306a5613
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