CoViS3DObservation.cpp
Go to the documentation of this file.
1 // (C) Copyright Renaud Detry 2007-2015.
2 // Distributed under the GNU General Public License and under the
3 // BSD 3-Clause License (See accompanying file LICENSE.txt).
4 
5 /** @file */
6 
8 
9 
10 namespace nuklei {
11 
12  const double CoViS3DObservation::TOL = 1e-5;
13 
14 
15  CoViS3DObservation::CoViS3DObservation()
16  {
17  NUKLEI_TRACE_BEGIN();
18  ColorPairDescriptor d;
19  k_.setDescriptor(d);
20  NUKLEI_TRACE_END();
21  }
22 
23  CoViS3DObservation::CoViS3DObservation(const kernel::r3xs2p& k) :
24  k_(k)
25  {}
26 
27  NUKLEI_UNIQUE_PTR<kernel::base> CoViS3DObservation::getKernel() const
28  {
29  return k_.clone();
30  }
31 
32  void CoViS3DObservation::setKernel(const kernel::base& k)
33  {
34  NUKLEI_TRACE_BEGIN();
35  k_ = dynamic_cast<const kernel::r3xs2p&>(k);
36  NUKLEI_TRACE_END();
37  }
38 
39  void CoViS3DObservation::setLoc(Vector3 loc)
40  {
41  NUKLEI_TRACE_BEGIN();
42  k_.loc_ = loc;
43  NUKLEI_TRACE_END();
44  }
45  Vector3 CoViS3DObservation::getLoc() const { return k_.loc_; }
46 
47  void CoViS3DObservation::setDirection(Vector3 direction)
48  {
49  NUKLEI_TRACE_BEGIN();
50  NUKLEI_ASSERT_AFE_TOL(direction.Length(), 1, TOL);
51  direction = la::normalized(direction);
52 
53  k_.dir_ = direction;
54  NUKLEI_TRACE_END();
55  }
56  Vector3 CoViS3DObservation::getDirection() const { return k_.dir_; }
57  void CoViS3DObservation::setPhiPsi(coord_t phi, coord_t psi)
58  {
59  NUKLEI_TRACE_BEGIN();
60  NUKLEI_RANGE_CHECK(phi, - M_PI, M_PI);
61  NUKLEI_RANGE_CHECK(psi, -M_PI, 2*M_PI);
62 
63  Vector3 l;
64  // This is the way Nico does it
65  l[0] = std::sin( phi ) * std::cos( psi );
66  l[1] = - std::sin( phi ) * std::sin( psi );
67  l[2] = std::cos( phi );
68 
69  setDirection(l);
70  NUKLEI_TRACE_END();
71  }
72  coord_pair CoViS3DObservation::getPhiPsi() const
73  {
74  NUKLEI_TRACE_BEGIN();
75  Vector3 direction = getDirection();
76  coord_t phi = ACos(direction[2]);
77  coord_t psi = std::atan2( -direction[1] / std::sin(phi),
78  direction[0]/std::sin(phi) );
79  return std::make_pair(phi, psi);
80  NUKLEI_TRACE_END();
81  }
82 
83  void CoViS3DObservation::setCovMatrix(const Matrix3& cov)
84  {
85  cov_ = cov;
86  }
87 
88  nullable<Matrix3> CoViS3DObservation::getCovMatrix() const
89  {
90  return cov_;
91  }
92 
93  void CoViS3DObservation::setWeight(weight_t weight)
94  {
95  NUKLEI_TRACE_BEGIN();
96  k_.setWeight(weight);
97  NUKLEI_TRACE_END();
98  }
99  weight_t CoViS3DObservation::getWeight() const { return k_.getWeight(); }
100 
101  const Color& CoViS3DObservation::getLeftColor() const
102  {
103  NUKLEI_TRACE_BEGIN();
104  return dynamic_cast<const ColorPairDescriptor&>(k_.getDescriptor()).getLeftColor();
105  NUKLEI_TRACE_END();
106  }
107  void CoViS3DObservation::setLeftColor(const Color& color)
108  {
109  NUKLEI_TRACE_BEGIN();
110  dynamic_cast<ColorPairDescriptor&>(k_.getDescriptor()).setLeftColor(color);
111  NUKLEI_TRACE_END();
112  }
113  const Color& CoViS3DObservation::getRightColor() const
114  {
115  NUKLEI_TRACE_BEGIN();
116  return dynamic_cast<const ColorPairDescriptor&>(k_.getDescriptor()).getRightColor();
117  NUKLEI_TRACE_END();
118  }
119  void CoViS3DObservation::setRightColor(const Color& color)
120  {
121  NUKLEI_TRACE_BEGIN();
122  dynamic_cast<ColorPairDescriptor&>(k_.getDescriptor()).setRightColor(color);
123  NUKLEI_TRACE_END();
124  }
125 
126  void CoViS3DObservation::setGamma(const Vector3& gamma)
127  {
128  NUKLEI_TRACE_BEGIN();
129  NUKLEI_ASSERT_AFE(gamma.Length(), 1);
130 
131  Vector3 x = k_.dir_;
132  Vector3 y = la::normalized(gamma);
133  Vector3 z = la::normalized(x.Cross(y));
134 
135  NUKLEI_ASSERT_AFE_TOL(x.Dot(k_.dir_), 1, 1e-6);
136  gamma_ = y;
137 
138  NUKLEI_TRACE_END();
139  }
140  const Vector3& CoViS3DObservation::getGamma() const
141  {
142  NUKLEI_TRACE_BEGIN();
143  return gamma_;
144  NUKLEI_TRACE_END();
145  }
146 
147 
148 
149 }
150 
Public namespace.
Definition: Color.cpp:9
std::pair< coord_t, coord_t > coord_pair
Pair of coord_t.
Definition: Definitions.h:27
double weight_t
Type for particle weights.
Definition: Definitions.h:31
r3xs2_base< groupS::s2p > r3xs2p
Definition: Kernel.h:623
weight_t getWeight() const
Returns this kernel's weight.
Definition: Kernel.h:215
void setWeight(const weight_t w)
Sets this kernel's weight.
Definition: Kernel.h:217
double coord_t
Type for point coordinates.
Definition: Definitions.h:25
base::ptr clone() const
Clone the kernel.
Definition: Kernel.h:280
© Copyright 2007-2013 Renaud Detry.
Distributed under the terms of the GNU General Public License (GPL).
(See accompanying file LICENSE.txt or copy at http://www.gnu.org/copyleft/gpl.html.)
Revised Sun Sep 13 2020 19:10:06.