本文整理汇总了C++中s_curve函数的典型用法代码示例。如果您正苦于以下问题:C++ s_curve函数的具体用法?C++ s_curve怎么用?C++ s_curve使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了s_curve函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
float PerlinNoise::noise2(float x, float y) {
float vec[2] = { x, y };
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, sx, sy, a, b, t, u, v;
const float* q;
register int i, j;
setup(0, bx0,bx1, rx0,rx1);
setup(1, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
#define at2(rx,ry) (rx * q[0] + ry * q[1])
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = lerp(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例2: srand
double Perlin::noise2(double vec[2])
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
if (mStart)
{
srand(mSeed);
mStart = false;
init();
}
setup(0,bx0,bx1,rx0,rx1);
setup(1,by0,by1,ry0,ry1); i = p[bx0];
j = p[bx1]; b00 = p[i + by0];
b10 = p[j + by0];
b01 = p[i + by1];
b11 = p[j + by1];
sx = s_curve(rx0);
sy = s_curve(ry0);
#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
q = g2[b00];
u = at2(rx0,ry0);
q = g2[b10];
v = at2(rx1,ry0);
a = lerp(sx, u, v); q = g2[b01];
u = at2(rx0,ry1);
q = g2[b11];
v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例3: noise2
T
noise2 (
T vec[2])
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
T rx0, rx1, ry0, ry1, sx, sy, a, b, u, v;
int i, j;
setup(vec[0],bx0,bx1,rx0,rx1);
setup(vec[1],by0,by1,ry0,ry1);
i = p[bx0];
j = p[bx1];
b00 = p[i + by0];
b10 = p[j + by0];
b01 = p[i + by1];
b11 = p[j + by1];
sx = s_curve(rx0);
sy = s_curve(ry0);
u = at2(rx0,ry0,b00);
v = at2(rx1,ry0,b10);
a = lerp(sx, u, v);
u = at2(rx0,ry1,b01);
v = at2(rx1,ry1,b11);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例4: setup
float PerlinNoise::Noise2(float x, float y)
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
setup(x, bx0,bx1, rx0,rx1);
setup(y, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = lerp(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例5: noise2
double noise2(double vec[2])
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
if (start) {
start = 0;
noiseinit();
}
setup(0, bx0,bx1, rx0,rx1);
setup(1, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = lerp(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例6: noise2
float noise2(float vec[2])
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
register int i, j;
if (start) {
start = 0;
init();
}
setup(0, bx0,bx1, rx0,rx1);
setup(1, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
#define at2(rx,ry) ( rx * q[0] + ry * q[1] )
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = lerp(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例7: noise2
float noise2(const float x, const float y){
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
setup(x, bx0,bx1, rx0,rx1);
setup(y, by0,by1, ry0,ry1);
i = p[bx0];
j = p[bx1];
b00 = p[i + by0];
b10 = p[j + by0];
b01 = p[i + by1];
b11 = p[j + by1];
sx = s_curve(rx0);
sy = s_curve(ry0);
q = g2[b00]; u = at2(rx0,ry0);
q = g2[b10]; v = at2(rx1,ry0);
a = lerp(sx, u, v);
q = g2[b01]; u = at2(rx0,ry1);
q = g2[b11]; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例8: setup
double PerlinGenerator::noise2(double vec[2])
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
setup(0, t,vec, bx0,bx1, rx0,rx1);
setup(1, t,vec, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = perlin_lerp(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = perlin_lerp(sx, u, v);
return perlin_lerp(sy, a, b);
}
示例9: setup
I noisetest::noise2(I vec[2])
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
I rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
int i, j;
setup(0, bx0,bx1, rx0,rx1);
setup(1, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = lerp(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例10: Init
//----------------------------------------------------------------------------
float FvPerlinNoise::Noise2(const FvVector2& vec)
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
register int i, j;
if (start) {
start = false;
Init();
}
setup(0, bx0,bx1, rx0,rx1);
setup(1, by0,by1, ry0,ry1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
sx = s_curve(rx0);
sy = s_curve(ry0);
q = g2[ b00 ] ; u = at2(rx0,ry0);
q = g2[ b10 ] ; v = at2(rx1,ry0);
a = FV_LERP(sx, u, v);
q = g2[ b01 ] ; u = at2(rx0,ry1);
q = g2[ b11 ] ; v = at2(rx1,ry1);
b = FV_LERP(sx, u, v);
return FV_LERP(sy, a, b);
}
示例11: init
double PerlinNoise::noise3(double f1, double f2, double f3)
{
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;
register int i, j;
double vec[3];
vec[0] = f1;
vec[1] = f2;
vec[2] = f3;
if (start) {
start = 0;
init();
}
setup(0, bx0,bx1, rx0,rx1);
setup(1, by0,by1, ry0,ry1);
setup(2, bz0,bz1, rz0,rz1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
t = s_curve(rx0);
sy = s_curve(ry0);
sz = s_curve(rz0);
#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
q = g3[ b00 + bz0 ] ; u = at3(rx0,ry0,rz0);
q = g3[ b10 + bz0 ] ; v = at3(rx1,ry0,rz0);
a = lerp(t, u, v);
q = g3[ b01 + bz0 ] ; u = at3(rx0,ry1,rz0);
q = g3[ b11 + bz0 ] ; v = at3(rx1,ry1,rz0);
b = lerp(t, u, v);
c = lerp(sy, a, b);
q = g3[ b00 + bz1 ] ; u = at3(rx0,ry0,rz1);
q = g3[ b10 + bz1 ] ; v = at3(rx1,ry0,rz1);
a = lerp(t, u, v);
q = g3[ b01 + bz1 ] ; u = at3(rx0,ry1,rz1);
q = g3[ b11 + bz1 ] ; v = at3(rx1,ry1,rz1);
b = lerp(t, u, v);
d = lerp(sy, a, b);
return lerp(sz, c, d);
}
示例12: noise3
scalar_t noise3(scalar_t x, scalar_t y, scalar_t z)
{
int i, j;
int bx0, bx1, by0, by1, bz0, bz1;
int b00, b10, b01, b11;
scalar_t rx0, rx1, ry0, ry1, rz0, rz1;
scalar_t sx, sy, sz;
scalar_t u, v, a, b, c, d;
if(!tables_valid) {
init_noise();
tables_valid = 1;
}
setup(x, bx0, bx1, rx0, rx1);
setup(y, by0, by1, ry0, ry1);
setup(z, bz0, bz1, rz0, rz1);
i = perm[bx0];
j = perm[bx1];
b00 = perm[i + by0];
b10 = perm[j + by0];
b01 = perm[i + by1];
b11 = perm[j + by1];
/* calculate hermite interpolating factors */
sx = s_curve(rx0);
sy = s_curve(ry0);
sz = s_curve(rz0);
/* interpolate along the top slice of the cell */
u = v3_dot(grad3[b00 + bz0], v3_cons(rx0, ry0, rz0));
v = v3_dot(grad3[b10 + bz0], v3_cons(rx1, ry0, rz0));
a = lerp(u, v, sx);
u = v3_dot(grad3[b01 + bz0], v3_cons(rx0, ry1, rz0));
v = v3_dot(grad3[b11 + bz0], v3_cons(rx1, ry1, rz0));
b = lerp(u, v, sx);
c = lerp(a, b, sy);
/* interpolate along the bottom slice of the cell */
u = v3_dot(grad3[b00 + bz0], v3_cons(rx0, ry0, rz1));
v = v3_dot(grad3[b10 + bz0], v3_cons(rx1, ry0, rz1));
a = lerp(u, v, sx);
u = v3_dot(grad3[b01 + bz0], v3_cons(rx0, ry1, rz1));
v = v3_dot(grad3[b11 + bz0], v3_cons(rx1, ry1, rz1));
b = lerp(u, v, sx);
d = lerp(a, b, sy);
/* interpolate between slices */
return lerp(c, d, sz);
}
示例13: init
F32 LLPerlinNoise::noise3(F32 x, F32 y, F32 z)
{
U8 bx0, bx1, by0, by1, bz0, bz1;
S32 b00, b10, b01, b11;
F32 rx0, rx1, ry0, ry1, rz0, rz1, *q, sy, sz, a, b, c, d, t, u, v;
S32 i, j;
if (!sInitialized)
init();
fast_setup(x, bx0,bx1, rx0,rx1);
fast_setup(y, by0,by1, ry0,ry1);
fast_setup(z, bz0,bz1, rz0,rz1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
t = s_curve(rx0);
sy = s_curve(ry0);
sz = s_curve(rz0);
q = g3[ b00 + bz0 ];
u = fast_at3(rx0,ry0,rz0,q);
q = g3[ b10 + bz0 ];
v = fast_at3(rx1,ry0,rz0,q);
a = lerp_m(t, u, v);
q = g3[ b01 + bz0 ];
u = fast_at3(rx0,ry1,rz0,q);
q = g3[ b11 + bz0 ];
v = fast_at3(rx1,ry1,rz0,q);
b = lerp_m(t, u, v);
c = lerp_m(sy, a, b);
q = g3[ b00 + bz1 ];
u = fast_at3(rx0,ry0,rz1,q);
q = g3[ b10 + bz1 ];
v = fast_at3(rx1,ry0,rz1,q);
a = lerp_m(t, u, v);
q = g3[ b01 + bz1 ];
u = fast_at3(rx0,ry1,rz1,q);
q = g3[ b11 + bz1 ];
v = fast_at3(rx1,ry1,rz1,q);
b = lerp_m(t, u, v);
d = lerp_m(sy, a, b);
return lerp_m(sz, c, d);
}
示例14: perlin_noise2
static double
perlin_noise2(int nColorChannel, double vec[2], StitchInfo *pStitchInfo)
{
int bx0, bx1, by0, by1, b00, b10, b01, b11;
double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
register int i, j;
t = vec[0] + (double) PerlinN;
bx0 = (int)t;
bx1 = bx0+1;
rx0 = t - (int)t;
rx1 = rx0 - 1.0f;
t = vec[1] + (double) PerlinN;
by0 = (int)t;
by1 = by0+1;
ry0 = t - (int)t;
ry1 = ry0 - 1.0f;
/* If stitching, adjust lattice points accordingly. */
if(pStitchInfo != NULL)
{
if(bx0 >= pStitchInfo->nWrapX)
bx0 -= pStitchInfo->nWidth;
if(bx1 >= pStitchInfo->nWrapX)
bx1 -= pStitchInfo->nWidth;
if(by0 >= pStitchInfo->nWrapY)
by0 -= pStitchInfo->nHeight;
if(by1 >= pStitchInfo->nWrapY)
by1 -= pStitchInfo->nHeight;
}
bx0 &= BM;
bx1 &= BM;
by0 &= BM;
by1 &= BM;
i = perlin_uLatticeSelector[bx0];
j = perlin_uLatticeSelector[bx1];
b00 = perlin_uLatticeSelector[i + by0];
b10 = perlin_uLatticeSelector[j + by0];
b01 = perlin_uLatticeSelector[i + by1];
b11 = perlin_uLatticeSelector[j + by1];
sx = (double) (s_curve(rx0));
sy = (double) (s_curve(ry0));
q = perlin_fGradient[nColorChannel][b00]; u = rx0 * q[0] + ry0 * q[1];
q = perlin_fGradient[nColorChannel][b10]; v = rx1 * q[0] + ry0 * q[1];
a = lerp(sx, u, v);
q = perlin_fGradient[nColorChannel][b01]; u = rx0 * q[0] + ry1 * q[1];
q = perlin_fGradient[nColorChannel][b11]; v = rx1 * q[0] + ry1 * q[1];
b = lerp(sx, u, v);
return lerp(sy, a, b);
}
示例15: init
float noise3::pnoise3(float vx, float vy, float vz)
{
int bx0, bx1, by0, by1, bz0, bz1, b00, b10, b01, b11;
float rx0, rx1, ry0, ry1, rz0, rz1, *q, sx, sy, sz, a, b, c, d, t, u, v;
register int i, j;
if (start)
{
start = 0;
init();
}
setup(vx, bx0,bx1, rx0,rx1);
setup(vy, by0,by1, ry0,ry1);
setup(vz, bz0,bz1, rz0,rz1);
i = p[ bx0 ];
j = p[ bx1 ];
b00 = p[ i + by0 ];
b10 = p[ j + by0 ];
b01 = p[ i + by1 ];
b11 = p[ j + by1 ];
#define at(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
#define s_curve(t) ( t * t * (3.0f - 2.0f * t) )
#define lerp(t, a, b) ( a + t * (b - a) )
sx = s_curve(rx0);
sy = s_curve(ry0);
sz = s_curve(rz0);
q = g[ b00 + bz0 ] ;
u = at(rx0,ry0,rz0);
q = g[ b10 + bz0 ] ;
v = at(rx1,ry0,rz0);
a = lerp(sx, u, v);
q = g[ b01 + bz0 ] ;
u = at(rx0,ry1,rz0);
q = g[ b11 + bz0 ] ;
v = at(rx1,ry1,rz0);
b = lerp(sx, u, v);
c = lerp(sy, a, b); // interpolate in y at lo x
q = g[ b00 + bz1 ] ;
u = at(rx0,ry0,rz1);
q = g[ b10 + bz1 ] ;
v = at(rx1,ry0,rz1);
a = lerp(sx, u, v);
q = g[ b01 + bz1 ] ;
u = at(rx0,ry1,rz1);
q = g[ b11 + bz1 ] ;
v = at(rx1,ry1,rz1);
b = lerp(sx, u, v);
d = lerp(sy, a, b); // interpolate in y at hi x
return 1.5f * lerp(sz, c, d); // interpolate in z
}