stardis-solver

Solve coupled heat transfers
git clone git://git.meso-star.fr/stardis-solver.git
Log | Files | Refs | README | LICENSE

sdis_camera.h (1718B)


      1 /* Copyright (C) 2016-2025 |Méso|Star> (contact@meso-star.com)
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #ifndef SDIS_CAMERA_H
     17 #define SDIS_CAMERA_H
     18 
     19 #include <rsys/double3.h>
     20 #include <rsys/ref_count.h>
     21 
     22 struct sdis_device;
     23 
     24 struct sdis_camera {
     25   /* Orthogonal camera frame */
     26   double axis_x[3];
     27   double axis_y[3];
     28   double axis_z[3];
     29 
     30   double position[3];
     31   double fov_x; /* Field of view in radians */
     32   double rcp_proj_ratio; /* height / width */
     33 
     34   ref_T ref;
     35   struct sdis_device* dev;
     36 };
     37 
     38 static FINLINE void
     39 camera_ray
     40   (const struct sdis_camera* cam,
     41    const double sample[2], /* In [0, 1[ */
     42    double org[3],
     43    double dir[3])
     44 {
     45   double x[3], y[3], len;
     46   (void)len; /* Avoid warning in debug */
     47   ASSERT(cam && sample && org && dir);
     48   ASSERT(sample[0] >= 0.0 || sample[0] < 1.0);
     49   ASSERT(sample[1] >= 0.0 || sample[1] < 1.0);
     50 
     51   d3_muld(x, cam->axis_x, sample[0]*2.0 - 1.0);
     52   d3_muld(y, cam->axis_y, sample[1]*2.0 - 1.0);
     53   d3_add(dir, d3_add(dir, x, y), cam->axis_z);
     54   len = d3_normalize(dir, dir);
     55   ASSERT(len >= 1.e-6);
     56   d3_set(org, cam->position);
     57 }
     58 
     59 #endif /* SDIS_CAMERA_H */
     60