SourceXtractorPlusPlus  0.12
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RotatedModelComponent.cpp
Go to the documentation of this file.
1 
23 #include <cmath> // for std::cos, std::sin
24 #include <iostream>
26 
27 namespace ModelFitting {
28 
30  std::shared_ptr<BasicParameter> rotation_angle)
31  : m_component {std::move(component)},
32  m_rotation_angle{rotation_angle},
33  m_cos{std::cos(m_rotation_angle->getValue())},
34  m_sin{std::sin(m_rotation_angle->getValue())} {
35  m_observer_id = rotation_angle->addObserver([this](double v){
36  m_cos = std::cos(v);
37  m_sin = std::sin(v);
38  });
39 }
40 
42  : m_component {std::move(other.m_component)},
43  m_rotation_angle{std::move(other.m_rotation_angle)},
44  m_cos{other.m_cos}, m_sin{other.m_sin},
45  m_observer_id (other.m_observer_id) {
46 }
47 
49  m_rotation_angle->removeObserver(m_observer_id);
50 }
51 
52 double RotatedModelComponent::getValue(double x, double y) {
53  double new_x = x * m_cos - y * m_sin;
54  double new_y = x * m_sin + y * m_cos;
55  return m_component->getValue(new_x, new_y);
56 }
57 
58 void RotatedModelComponent::updateRasterizationInfo(double scale, double r_max) {
59  m_component->updateRasterizationInfo(scale, r_max);
60 }
61 
63  std::vector<ModelSample> result = m_component->getSharpSampling();
64  for (auto& sample : result) {
65  double new_x = std::get<0>(sample) * m_cos + std::get<1>(sample) * m_sin;
66  double new_y = std::get<1>(sample) * m_cos - std::get<0>(sample) * m_sin;
67  std::get<0>(sample) = new_x;
68  std::get<1>(sample) = new_y;
69  }
70  return result;
71 }
72 
74  double new_x = x * m_cos - y* m_sin;
75  double new_y = x * m_sin + y * m_cos;
76  return m_component->insideSharpRegion(new_x, new_y);
77 }
78 
79 } // end of namespace ModelFitting
std::unique_ptr< ModelComponent > m_component
double getValue(double x, double y) override
bool insideSharpRegion(double x, double y) override
std::vector< ModelSample > getSharpSampling() override
RotatedModelComponent(std::unique_ptr< ModelComponent > component, std::shared_ptr< BasicParameter > rotation_angle)
T sin(T...args)
T cos(T...args)
T move(T...args)
STL class.
STL class.
std::shared_ptr< BasicParameter > m_rotation_angle
void updateRasterizationInfo(double scale, double r_max) override