htrdr_planets_source.h (4525B)
1 /* Copyright (C) 2018-2019, 2022-2025 Centre National de la Recherche Scientifique 2 * Copyright (C) 2020-2022 Institut Mines Télécom Albi-Carmaux 3 * Copyright (C) 2022-2025 Institut Pierre-Simon Laplace 4 * Copyright (C) 2022-2025 Institut de Physique du Globe de Paris 5 * Copyright (C) 2018-2025 |Méso|Star> (contact@meso-star.com) 6 * Copyright (C) 2022-2025 Observatoire de Paris 7 * Copyright (C) 2022-2025 Université de Reims Champagne-Ardenne 8 * Copyright (C) 2022-2025 Université de Versaille Saint-Quentin 9 * Copyright (C) 2018-2019, 2022-2025 Université Paul Sabatier 10 * 11 * This program is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU General Public License as published by 13 * the Free Software Foundation, either version 3 of the License, or 14 * (at your option) any later version. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU General Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License 22 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 23 24 #ifndef HTRDR_PLANETS_SOURCE_H 25 #define HTRDR_PLANETS_SOURCE_H 26 27 #include <rsys/rsys.h> 28 29 /* Forward declarations */ 30 struct htrdr; 31 struct htrdr_planets_source; 32 struct htrdr_planets_source_args; 33 struct ssp_rng; 34 35 struct htrdr_planets_source_spectrum { 36 const struct htrdr_planets_source* source; 37 double range[2]; /* In nm. Limits are inclusive */ 38 size_t size; /* Number of elements representing the spectrum */ 39 const void* buffer; /* Pointer toward the spectrum data */ 40 }; 41 #define HTRDR_PLANETS_SOURCE_SPECTRUM_NULL__ {NULL, {0,0}, 0, NULL} 42 static const struct htrdr_planets_source_spectrum 43 HTRDR_PLANETS_SOURCE_SPECTRUM_NULL = HTRDR_PLANETS_SOURCE_SPECTRUM_NULL__; 44 45 extern LOCAL_SYM res_T 46 htrdr_planets_source_create 47 (struct htrdr* htrdr, 48 const struct htrdr_planets_source_args* args, 49 struct htrdr_planets_source** source); 50 51 extern LOCAL_SYM void 52 htrdr_planets_source_ref_get 53 (struct htrdr_planets_source* source); 54 55 extern LOCAL_SYM void 56 htrdr_planets_source_ref_put 57 (struct htrdr_planets_source* source); 58 59 /* Return the pdf of the sampled direction */ 60 extern LOCAL_SYM double 61 htrdr_planets_source_sample_direction 62 (const struct htrdr_planets_source* source, 63 struct ssp_rng* rng, 64 const double pos[3], /* Position from which direction is sampled */ 65 double dir[3]); 66 67 extern LOCAL_SYM double /* In W/m²/sr/m */ 68 htrdr_planets_source_get_radiance 69 (const struct htrdr_planets_source* source, 70 const double wlen); /* In nanometers */ 71 72 /* Return the distance between the source surface and the input position. Can 73 * be negative if the position is in the source */ 74 extern LOCAL_SYM double /* In m */ 75 htrdr_planets_source_distance_to 76 (const struct htrdr_planets_source* source, 77 const double pos[3]); 78 79 /* Return 1 if the source is targeted by the submitted ray and 0 otherwise */ 80 extern LOCAL_SYM int 81 htrdr_planets_source_is_targeted 82 (const struct htrdr_planets_source* source, 83 const double pos[3], /* Ray origin */ 84 const double dir[3]);/* Ray direction */ 85 86 extern LOCAL_SYM res_T 87 htrdr_planets_source_get_spectral_range 88 (const struct htrdr_planets_source* source, 89 double range[2]); /* In nm. Limits are inclusive */ 90 91 extern LOCAL_SYM int 92 htrdr_planets_source_does_radiance_vary_spectrally 93 (const struct htrdr_planets_source* source); 94 95 /* Get discrete spectrum data for a given range. If the boundaries of the 96 * spectral range do not coincide with a discrete element, their radiance is 97 * recovered from the htrdr_planets_source_get_radiance function. Note that 98 * this function returns an error if the radiance from the source does not vary 99 * spectrally, that is, its radiance is recovered from a constant temperature */ 100 extern LOCAL_SYM res_T 101 htrdr_planets_source_get_spectrum 102 (const struct htrdr_planets_source* source, 103 const double range[2], /* In nm. Limits are inclusive */ 104 struct htrdr_planets_source_spectrum* spectrum); 105 106 /* Note that the following function profile corresponds to the type expected by 107 * the discrete wavelength distribution 108 * (see htrdr_ran_wlen_discrete_create_args structure) */ 109 extern LOCAL_SYM void 110 htrdr_planets_source_spectrum_at 111 (void* spectrum, 112 size_t i, /* between [0, spectrum->size[ */ 113 double* wavelength, /* In nm */ 114 double* radiance); /* In W/m²/sr/m */ 115 116 #endif /* HTRDR_PLANETS_SOURCE_H */