SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
EllipticalAperture.cpp
Go to the documentation of this file.
1
17/*
18 * EllipticalAperture.cpp
19 *
20 * Created on: Oct 08, 2018
21 * Author: Alejandro Alvarez
22 */
23
25#include <iostream>
26namespace SourceXtractor {
27
28
30 SeFloat rad_max)
31 : m_cxx{cxx}, m_cyy{cyy}, m_cxy{cxy}, m_rad_max{rad_max} {
32}
33
34 SeFloat EllipticalAperture::getArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const {
35 if (getRadiusSquared(center_x, center_y, pixel_x, pixel_y) < m_rad_max * m_rad_max) {
36
37 return 1.0;
38 }
39 return 0.;
40 }
41
42 SeFloat EllipticalAperture::drawArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const {
43 SeFloat thickness = 1.0;
44 SeFloat min_rad_squared = m_rad_max > thickness ? (m_rad_max - thickness) * (m_rad_max - thickness) : 0;
45
46 //SeFloat min_rad_squared = .877777*(m_rad_max*m_rad_max);
47 //SeFloat min_rad_squared = .877777*(m_rad_max*m_rad_max);
48 //SeFloat min_rad_squared = .133333*(m_rad_max*m_rad_max) > 6.0 ? .877777*(m_rad_max*m_rad_max) : (m_rad_max*m_rad_max)-6.0;
49
50 //SeFloat max_rad_squared = (m_rad_max + thickness) * (m_rad_max + thickness);
51
52 //if (min_supersampled_radius_squared < distance_squared && distance_squared <= max_supersampled_radius_squared) {
53 //if ((m_rad_max-1.)*(m_rad_max-1.)< distance_squared && distance_squared < m_rad_max * m_rad_max) {
54 //if ((m_rad_max*m_rad_max-thickness)< distance_squared && distance_squared < (m_rad_max * m_rad_max)) {
55 //if (fabs(distance_squared - (m_rad_max * m_rad_max)) < thickness) {
56
57 auto distance_squared = getRadiusSquared(center_x, center_y, pixel_x, pixel_y);
58 if (min_rad_squared < distance_squared && distance_squared < (m_rad_max * m_rad_max)) {
59 //if (min_rad_squared < distance_squared && distance_squared < max_rad_squared) {
60 return 1.0;
61 }
62 return 0.;
63 }
64
66 SeFloat pixel_y) const {
67 auto dist_x = SeFloat(pixel_x) - center_x;
68 auto dist_y = SeFloat(pixel_y) - center_y;
69
70 return m_cxx * dist_x * dist_x + m_cyy * dist_y * dist_y + m_cxy * dist_x * dist_y;
71}
72
74 SeFloat dx, dy;
75
76 // compute the maximum extend in x/y
77 dx = m_rad_max * std::sqrt(1.0 / (m_cxx - m_cxy * m_cxy / (4.0 * m_cyy)));
78 dy = m_rad_max * std::sqrt(1.0 / (m_cyy - m_cxy * m_cxy / (4.0 * m_cxx)));
79
80 // return the absolute values
81 return PixelCoordinate(centroid_x - dx, centroid_y - dy);
82}
83
85 SeFloat dx, dy;
86
87 // compute the maximum extend in x/y
88 dx = m_rad_max * std::sqrt(1.0 / (m_cxx - m_cxy * m_cxy / (4.0 * m_cyy)));
89 dy = m_rad_max * std::sqrt(1.0 / (m_cyy - m_cxy * m_cxy / (4.0 * m_cxx)));
90
91 // return the absolute values
92 return PixelCoordinate(centroid_x + dx + 1, centroid_y + dy + 1);
93}
94
95} // end SourceXtractor
SeFloat drawArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
PixelCoordinate getMinPixel(SeFloat centroid_x, SeFloat centroid_y) const override
SeFloat getRadiusSquared(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
PixelCoordinate getMaxPixel(SeFloat centroid_x, SeFloat centroid_y) const override
SeFloat getArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
EllipticalAperture(SeFloat cxx, SeFloat cyy, SeFloat cxy, SeFloat rad_max)
SeFloat32 SeFloat
Definition Types.h:32
T sqrt(T... args)
A pixel coordinate made of two integers m_x and m_y.