SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
RotatedModelComponent.cpp
Go to the documentation of this file.
1
23#include <cmath> // for std::cos, std::sin
24#include <iostream>
26
27namespace ModelFitting {
28
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
51
52double 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
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;
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::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
double getValue(double x, double y) override
bool insideSharpRegion(double x, double y) override
RotatedModelComponent(std::unique_ptr< ModelComponent > component, std::shared_ptr< BasicParameter > rotation_angle)
std::shared_ptr< BasicParameter > m_rotation_angle
void updateRasterizationInfo(double scale, double r_max) override
std::vector< ModelSample > getSharpSampling() override
std::unique_ptr< ModelComponent > m_component
T cos(T... args)
T move(T... args)
STL namespace.
T sin(T... args)