MEPP2 Project
flatfrequencycomputor.inl
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 
12 inline
13 int
14 cpd_to_pixel(int screen_resX,
15  int screen_resY,
16  double screen_size,
17  double user_distance,
18  double cpd)
19 {
20  double ppcm = sqrt(double(screen_resX * screen_resX) +
21  double(screen_resY * screen_resY)) /
22  screen_size;
23  double ppd = 0.0175 * user_distance * ppcm;
24  int nb_pixel = int(ppd / cpd);
25 
26  return nb_pixel;
27 }
28 
29 inline
30 double
31 pixel_to_wDistance(int camera_vportY,
32  double camera_fov,
33  double camera_distance,
34  int nb_pixel)
35 {
36  double dpp = 2.f * camera_distance * std::tan(0.5 * camera_fov) /
37  double(camera_vportY);
38  double wDistance = dpp * double(nb_pixel);
39 
40  return wDistance;
41 }
42 
43 inline
44 double
45 cpd_to_wDistance(int screen_resX,
46  int screen_resY,
47  double screen_size,
48  double user_distance,
49  int camera_vportY,
50  double camera_fov,
51  double camera_distance,
52  double cpd)
53 {
54  return pixel_to_wDistance(
55  camera_vportY,
56  camera_fov,
57  camera_distance,
58  cpd_to_pixel(screen_resX, screen_resY, screen_size, user_distance, cpd));
59 }
60 
61 inline
62 double
63 pixel_to_cpd(int screen_resX,
64  int screen_resY,
65  double screen_size,
66  double user_distance,
67  int nb_pixel)
68 {
69  double ppcm = std::sqrt(double(screen_resX * screen_resX) +
70  double(screen_resY * screen_resY)) /
71  screen_size;
72  double ppd = 0.0175 * user_distance * ppcm;
73  double cpd = ppd / double(nb_pixel);
74 
75  return cpd;
76 }
77 
78 inline
79 int
80 wDistance_to_pixel(int camera_vportY,
81  double camera_fov,
82  double camera_distance,
83  double wDistance)
84 {
85  double dpp = 2.f * camera_distance * std::tan(0.5 * camera_fov) /
86  double(camera_vportY);
87  int nb_pixel = int(wDistance / dpp);
88  return nb_pixel;
89 }
90 
91 inline
92 double
93 wDistance_to_cpd(int screen_resX,
94  int screen_resY,
95  double screen_size,
96  double user_distance,
97  int camera_vportY,
98  double camera_fov,
99  double camera_distance,
100  double wDistance)
101 {
102  return pixel_to_cpd(
103  screen_resX,
104  screen_resY,
105  screen_size,
106  user_distance,
108  camera_vportY, camera_fov, camera_distance, wDistance));
109 }
pixel_to_wDistance
double pixel_to_wDistance(int camera_vportY, double camera_fov, double camera_distance, int nb_pixel)
Definition: flatfrequencycomputor.inl:31
wDistance_to_pixel
int wDistance_to_pixel(int camera_vportY, double camera_fov, double camera_distance, double wDistance)
Definition: flatfrequencycomputor.inl:80
wDistance_to_cpd
double wDistance_to_cpd(int screen_resX, int screen_resY, double screen_size, double user_distance, int camera_vportY, double camera_fov, double camera_distance, double wDistance)
Definition: flatfrequencycomputor.inl:93
cpd_to_wDistance
double cpd_to_wDistance(int screen_resX, int screen_resY, double screen_size, double user_distance, int camera_vportY, double camera_fov, double camera_distance, double cpd)
Definition: flatfrequencycomputor.inl:45
pixel_to_cpd
double pixel_to_cpd(int screen_resX, int screen_resY, double screen_size, double user_distance, int nb_pixel)
Definition: flatfrequencycomputor.inl:63
cpd_to_pixel
int cpd_to_pixel(int screen_resX, int screen_resY, double screen_size, double user_distance, double cpd)
Definition: flatfrequencycomputor.inl:14