PICCANTE  0.4
The hottest HDR imaging library!
warp_samples.hpp
Go to the documentation of this file.
1 /*
2 
3 PICCANTE
4 The hottest HDR imaging library!
5 http://vcg.isti.cnr.it/piccante
6 
7 Copyright (C) 2014
8 Visual Computing Laboratory - ISTI CNR
9 http://vcg.isti.cnr.it
10 First author: Francesco Banterle
11 
12 This Source Code Form is subject to the terms of the Mozilla Public
13 License, v. 2.0. If a copy of the MPL was not distributed with this
14 file, You can obtain one at http://mozilla.org/MPL/2.0/.
15 
16 */
17 
18 #ifndef PIC_UTIL_WARP_SQUARE_CIRCLE_HPP
19 #define PIC_UTIL_WARP_SQUARE_CIRCLE_HPP
20 
21 #include "../base.hpp"
22 
23 #include "../util/math.hpp"
24 
25 namespace pic {
26 
34 PIC_INLINE void warpSquareCircle(float x, float y, float *xo, float *yo)
35 {
36  float phi, r;
37 
38 
39  if(x * x > y * y) {
40  r = x;
41  phi = (C_PI / 4.0f) * (y / x);
42  } else {
43  r = y;
44  phi = (C_PI / 4.0f) * (x / y) + (C_PI / 2.0f);
45  }
46 
47  *xo = r * cos(phi);
48  *yo = r * sin(phi);
49 }
50 
56 PIC_INLINE float warpNormalDistribution(float u0, float u1)
57 {
58  return sqrtf(MAX(-2.0f * logf(u0), 0.0f)) * cosf(u1);
59 }
60 
69 PIC_INLINE float warpGaussianDistribution(float u0, float u1, float mu, float sigma)
70 {
71  float x = warpNormalDistribution(u0, u1);
72  return (x + mu) * sigma;
73 }
74 
75 } // end namespace pic
76 
77 #endif /* PIC_UTIL_WARP_SQUARE_CIRCLE_HPP */
78 
const float C_PI
Definition: math.hpp:50
#define PIC_INLINE
Definition: base.hpp:33
PIC_INLINE float warpNormalDistribution(float u0, float u1)
warpNormalDistribution warps from uniform distribution to a normal distribution
Definition: warp_samples.hpp:56
Definition: bilateral_separation.hpp:25
#define MAX(a, b)
Definition: math.hpp:73
PIC_INLINE void warpSquareCircle(float x, float y, float *xo, float *yo)
warpSquareCircle warps from a square to a circle distribution.
Definition: warp_samples.hpp:34
PIC_INLINE float warpGaussianDistribution(float u0, float u1, float mu, float sigma)
warpGaussianDistribution
Definition: warp_samples.hpp:69