• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LERP函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LERP函数的典型用法代码示例。如果您正苦于以下问题:C++ LERP函数的具体用法?C++ LERP怎么用?C++ LERP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LERP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: memset

void APerlinNoise2D::GetValue(float x, float y, float * pvValue, int nNumValue)
{
  int      i, k;
  float    vx, sx, vy, sy;
  int      x1, x2, y1, y2;
  float    value1[3], value2[3];
  float    valueX1[3], valueX2[3];
  float    value[3];
  float    vFinal[3];

  memset(vFinal, 0, sizeof(float) * nNumValue);
  for(i=0; i<m_nOctaveNum; i++)
  {
    if( m_nActiveOctave != -1 && m_nActiveOctave != i )
      continue;

    // Get Horizon interpolated value;
    vx = m_nStartPos[i] % m_nBufferWidth + x / m_nWaveLength[i];
    x1 = int(vx);
    sx = vx - x1;
    sx = S_CURVE(sx);
    x2 = x1 + 1;

    vy = m_nStartPos[i] / m_nBufferWidth + y / m_nWaveLength[i];
    y1 = int(vy);
    sy = vy - y1;
    sy = S_CURVE(sy);
    y2 = y1 + 1;
    
    GetRandValues(x1, y1, value1, nNumValue);
    GetRandValues(x2, y1, value2, nNumValue);
    for(k=0; k<nNumValue; k++)
      valueX1[k] = LERP(sx, value1[k], value2[k]);

    GetRandValues(x1, y2, value1, nNumValue);
    GetRandValues(x2, y2, value2, nNumValue);
    for(k=0; k<nNumValue; k++)
      valueX2[k] = LERP(sx, value1[k], value2[k]);

    if( m_bTurbulence )
    {
      for(k=0; k<nNumValue; k++)
      {
        value[k] = (float)fabs(LERP(sy, valueX1[k], valueX2[k]));
        vFinal[k] += m_vAmplitude[i] * value[k];
      }
    }
    else
    {
      for(k=0; k<nNumValue; k++)
      {
        value[k] = LERP(sy, valueX1[k], valueX2[k]);
        vFinal[k] += m_vAmplitude[i] * value[k];
      }
    }
  }

  for(k=0; k<nNumValue; k++)
    pvValue[k] = vFinal[k];
}
开发者ID:fengqk,项目名称:Art,代码行数:60,代码来源:APerlinNoise2D.cpp


示例2: LERP

void TBWidgetAnimationRect::OnAnimationUpdate(float progress)
{
    if (m_mode == MODE_DELTA_IN || m_mode == MODE_DELTA_OUT)
    {
        m_dst_rect = m_src_rect = m_widget->GetRect();
        if (m_dst_rect.Equals(TBRect()))
        {
            // Widget hasn't been laid out yet,
            // the animation was started too soon.
            TBAnimationManager::AbortAnimation(this, true);
            return;
        }
        if (m_mode == MODE_DELTA_IN)
        {
            m_dst_rect.x += m_delta_rect.x;
            m_dst_rect.y += m_delta_rect.y;
            m_dst_rect.w += m_delta_rect.w;
            m_dst_rect.h += m_delta_rect.h;
        }
        else
        {
            m_src_rect.x += m_delta_rect.x;
            m_src_rect.y += m_delta_rect.y;
            m_src_rect.w += m_delta_rect.w;
            m_src_rect.h += m_delta_rect.h;
        }
        m_mode = MODE_SRC_TO_DST;
    }
    TBRect rect;
    rect.x = (int) LERP(m_src_rect.x, m_dst_rect.x, progress);
    rect.y = (int) LERP(m_src_rect.y, m_dst_rect.y, progress);
    rect.w = (int) LERP(m_src_rect.w, m_dst_rect.w, progress);
    rect.h = (int) LERP(m_src_rect.h, m_dst_rect.h, progress);
    m_widget->SetRect(rect);
}
开发者ID:Nocte-,项目名称:hexahedra,代码行数:35,代码来源:tb_widget_animation.cpp


示例3: pnoise

template <class T>	T  pnoise(T x,T y, int px, int py,const unsigned char *perm) {
    int ix0, iy0, ix1, iy1;
    T	fx0, fy0, fx1, fy1;
    T	s, t, nx0, nx1, n0, n1;

	px	=	max(px,1);
	py	=	max(py,1);

    ix0 = FASTFLOOR( x );
    iy0 = FASTFLOOR( y );
    fx0 = x - ix0;
    fy0 = y - iy0;
    fx1 = fx0 - 1.0f;
    fy1 = fy0 - 1.0f;
    ix1 = (( ix0 + 1 ) % px) & 0xff;
    iy1 = (( iy0 + 1 ) % py) & 0xff;
    ix0 = ( ix0 % px ) & 0xff;
    iy0 = ( iy0 % py ) & 0xff;
    
    t = FADE( fy0 );
    s = FADE( fx0 );

    nx0 = grad(perm[ix0 + perm[iy0]], fx0, fy0);
    nx1 = grad(perm[ix0 + perm[iy1]], fx0, fy1);
    n0 = LERP( t, nx0, nx1 );

    nx0 = grad(perm[ix1 + perm[iy0]], fx1, fy0);
    nx1 = grad(perm[ix1 + perm[iy1]], fx1, fy1);
    n1 = LERP(t, nx0, nx1);

    return 0.5f * (1.0f + 0.507f * ( LERP( s, n0, n1 ) ) );
}
开发者ID:ataibarkai,项目名称:Pixie-iOS,代码行数:32,代码来源:noise.cpp


示例4: MAX

void	EffectScene::Object::Primitive::SetLayerMaterials( Texture2D& _LayeredTextures, int _Mat0, int _Mat1, int _Mat2, int _Mat3 )
{
	const MaterialBank::Material::DynamicParameters*	ppMats[4] =
	{
		&m_Owner.m_Owner.m_pMaterials->GetMaterialAt( _Mat0 ).GetDynamic(),
		&m_Owner.m_Owner.m_pMaterials->GetMaterialAt( _Mat1 ).GetDynamic(),
		&m_Owner.m_Owner.m_pMaterials->GetMaterialAt( _Mat2 ).GetDynamic(),
		&m_Owner.m_Owner.m_pMaterials->GetMaterialAt( _Mat3 ).GetDynamic(),
	};

	m_pTextures = &_LayeredTextures;

	m_pCB_Primitive->m.MatIDs[0] = _Mat0;
	m_pCB_Primitive->m.MatIDs[1] = _Mat1;
	m_pCB_Primitive->m.MatIDs[2] = _Mat2;
	m_pCB_Primitive->m.MatIDs[3] = _Mat3;

	m_pCB_Primitive->m.Thickness.Set( MAX( 1e-6f, ppMats[0]->Thickness ), MAX( 1e-6f, ppMats[1]->Thickness ), MAX( 1e-6f, ppMats[2]->Thickness ), MAX( 1e-6f, ppMats[3]->Thickness ) );
	m_pCB_Primitive->m.IOR.Set( ppMats[1]->IOR, ppMats[2]->IOR, ppMats[3]->IOR );
	m_pCB_Primitive->m.Frosting.Set( ppMats[1]->Frosting, ppMats[2]->Frosting, ppMats[3]->Frosting );
	m_pCB_Primitive->m.NoDiffuse.Set( ppMats[0]->NoDiffuse, ppMats[1]->NoDiffuse, ppMats[2]->NoDiffuse, ppMats[3]->NoDiffuse );

	// Extinctions are given as [0,1] numbers from totally transparent to completely opaque
	// We need to convert them into actual extinction values to be used in the classical exp( -Sigma_t * Distance(millimeters) ) formula
	// We simply assume the opacity of the layer below should be a very low value for extinction=1 when the ray of light travels the layer's whole thickness:
	const float	LOW_OPACITY_VALUE = 1e-3;
	NjFloat3	TargetValueAtThickness(
		logf( LERP( LOW_OPACITY_VALUE, 1.0f, ppMats[1]->Opacity ) ) / m_pCB_Primitive->m.Thickness.y,
		logf( LERP( LOW_OPACITY_VALUE, 1.0f, ppMats[2]->Opacity ) ) / m_pCB_Primitive->m.Thickness.z,
		logf( LERP( LOW_OPACITY_VALUE, 1.0f, ppMats[3]->Opacity ) ) / m_pCB_Primitive->m.Thickness.w
		);

	m_pCB_Primitive->m.Extinction = TargetValueAtThickness;
}
开发者ID:Samana,项目名称:GodComplex,代码行数:34,代码来源:Scene.cpp


示例5: noise2

/** 2D float Perlin noise.
 */
float noise2( float x, float y )
{
    int ix0, iy0, ix1, iy1;
    float fx0, fy0, fx1, fy1;
    float s, t, nx0, nx1, n0, n1;

    ix0 = FASTFLOOR( x ); // Integer part of x
    iy0 = FASTFLOOR( y ); // Integer part of y
    fx0 = x - ix0;        // Fractional part of x
    fy0 = y - iy0;        // Fractional part of y
    fx1 = fx0 - 1.0f;
    fy1 = fy0 - 1.0f;
    ix1 = (ix0 + 1) & 0xff;  // Wrap to 0..255
    iy1 = (iy0 + 1) & 0xff;
    ix0 = ix0 & 0xff;
    iy0 = iy0 & 0xff;
    
    t = FADE( fy0 );
    s = FADE( fx0 );

    nx0 = noise_grad2(noise_perm[ix0 + noise_perm[iy0]], fx0, fy0);
    nx1 = noise_grad2(noise_perm[ix0 + noise_perm[iy1]], fx0, fy1);
    n0 = LERP( t, nx0, nx1 );

    nx0 = noise_grad2(noise_perm[ix1 + noise_perm[iy0]], fx1, fy0);
    nx1 = noise_grad2(noise_perm[ix1 + noise_perm[iy1]], fx1, fy1);
    n1 = LERP(t, nx0, nx1);

    return 0.507f * ( LERP( s, n0, n1 ) );
}
开发者ID:mmluqman,项目名称:vimjay,代码行数:32,代码来源:noise1234.c


示例6: pnoise2

/** 2D float Perlin periodic noise.
 */
float pnoise2( float x, float y, int px, int py )
{
    int ix0, iy0, ix1, iy1;
    float fx0, fy0, fx1, fy1;
    float s, t, nx0, nx1, n0, n1;

    ix0 = FASTFLOOR( x ); // Integer part of x
    iy0 = FASTFLOOR( y ); // Integer part of y
    fx0 = x - ix0;        // Fractional part of x
    fy0 = y - iy0;        // Fractional part of y
    fx1 = fx0 - 1.0f;
    fy1 = fy0 - 1.0f;
    ix1 = (( ix0 + 1 ) % px) & 0xff;  // Wrap to 0..px-1 and wrap to 0..255
    iy1 = (( iy0 + 1 ) % py) & 0xff;  // Wrap to 0..py-1 and wrap to 0..255
    ix0 = ( ix0 % px ) & 0xff;
    iy0 = ( iy0 % py ) & 0xff;
    
    t = FADE( fy0 );
    s = FADE( fx0 );

    nx0 = grad2(perm[ix0 + perm[iy0]], fx0, fy0);
    nx1 = grad2(perm[ix0 + perm[iy1]], fx0, fy1);
    n0 = LERP( t, nx0, nx1 );

    nx0 = grad2(perm[ix1 + perm[iy0]], fx1, fy0);
    nx1 = grad2(perm[ix1 + perm[iy1]], fx1, fy1);
    n1 = LERP(t, nx0, nx1);

    return 0.507f * ( LERP( s, n0, n1 ) );
}
开发者ID:torule,项目名称:rss-glx,代码行数:32,代码来源:noise1234.c


示例7: lerp_vec4

t_vec4		lerp_vec4(t_vec4 a, t_vec4 b, t_vec4 x, t_vec4 max)
{
    a.x = LERP(a.x, b.x, x.x, max.x);
    a.y = LERP(a.y, b.y, x.y, max.y);
    a.z = LERP(a.z, b.z, x.z, max.z);
    a.w = LERP(a.w, b.w, x.w, max.w);
    return (a);
}
开发者ID:jgan42,项目名称:rt,代码行数:8,代码来源:lerp_vec4.c


示例8: lerp_vec4_1

t_vec4		lerp_vec4_1(t_vec4 a, t_vec4 b, t_float x, t_float max)
{
    a.x = LERP(a.x, b.x, x, max);
    a.y = LERP(a.y, b.y, x, max);
    a.z = LERP(a.z, b.z, x, max);
    a.w = LERP(a.w, b.w, x, max);
    return (a);
}
开发者ID:jgan42,项目名称:rt,代码行数:8,代码来源:lerp_vec4.c


示例9: lerp_2d

static INLINE GLfloat
lerp_2d(GLfloat a, GLfloat b,
        GLfloat v00, GLfloat v10, GLfloat v01, GLfloat v11)
{
   const GLfloat temp0 = LERP(a, v00, v10);
   const GLfloat temp1 = LERP(a, v01, v11);
   return LERP(b, temp0, temp1);
}
开发者ID:nikai3d,项目名称:mesa,代码行数:8,代码来源:s_blit.c


示例10: eval_vlerp

void eval_vlerp(Expr *expr)
{
	expr->l->l->fn(expr->l->l);
	expr->l->r->fn(expr->l->r);
	expr->r->fn(expr->r);
	expr->v.x = LERP(expr->l->l->v.x, expr->l->r->v.x, expr->r->v.x);
	expr->v.y = LERP(expr->l->l->v.x, expr->l->r->v.y, expr->r->v.y);
	expr->v.z = LERP(expr->l->l->v.x, expr->l->r->v.z, expr->r->v.z);
}
开发者ID:oleavitt,项目名称:gem,代码行数:9,代码来源:exeval.c


示例11: check_point

long check_point(Point3 p1, Point3 p2, float alpha, long mask)
{
Point3 plane_point;

   plane_point.x = LERP(alpha, p1.x, p2.x);
   plane_point.y = LERP(alpha, p1.y, p2.y);
   plane_point.z = LERP(alpha, p1.z, p2.z);
   return(face_plane(plane_point) & mask);
}
开发者ID:EduardMe,项目名称:GraphicsGems,代码行数:9,代码来源:triangleCube.c


示例12: CheckPoint

///
//	CheckPoint()
//
//	Test the point "alpha" of the way from P1 to P2 
//  See if it is on a face of the cube   
//	Consider only faces in "mask"                   
static
int CheckPoint(const vector3& p1, const vector3& p2, number alpha, long mask)
{
	vector3 plane_point;

	plane_point.x() = LERP(alpha, p1.x(), p2.x());
	plane_point.y() = LERP(alpha, p1.y(), p2.y());
	plane_point.z() = LERP(alpha, p1.z(), p2.z());
	return(FacePlane(plane_point) & mask);
}
开发者ID:bsumirak,项目名称:ugcore,代码行数:16,代码来源:tri_box.cpp


示例13: render

void render(uchar* image,
            uint width, uint height,
            uint max_iterations,
            float x_scale,
            float y_scale,
            float x_adjust,
            float y_adjust)
{
    for (uint x_dim = 0; x_dim < width; x_dim++) {
        for (uint y_dim = 0; y_dim < height; y_dim++) {
            uint index = BYTES_PER_PIXEL * (width * y_dim + x_dim);
            float x_origin = ((float) x_dim/width)*x_scale - x_adjust;
            float y_origin = ((float) y_dim/width)*y_scale - y_adjust;

            float x = 0.0;
            float y = 0.0;
            uint iteration = 0;

            // Escape time algorithm
            while(x*x + y*y < LIMIT && iteration < max_iterations) {
                float xtemp = x*x - y*y + x_origin;
                y = 2*x*y + y_origin;
                x = xtemp;
                iteration++;
            }

            if (iteration == max_iterations) {
                image[index    ] = 0;
                image[index + 1] = 0;
                image[index + 2] = 0;
                image[index + 3] = 0;
            }
            else {
                // Continous coloring
                // Computes the color as a linear interpolation of surrounding points
                // smoothing the color transition.
                float zn  = sqrt(x*x + y*y);
                float nu  = log10f(log10f(zn) / log10f(2)) / log10f(2);
                float itr = ((float) iteration) + 1 - nu;
                float t   = fmodf(itr, 1.0);
                iteration = (uint) itr;
                uint color1 = iteration;
                uint color2 = iteration+1;

                // Assign RGB values by multiplying the iteration count by a even multiples.
                // Should replace this with a predefined colormap.
                image[index    ] = 1;
                image[index + 1] = ((uint) LERP(color1, color2, t)*2) % max_iterations;
                image[index + 2] = ((uint) LERP(color1, color2, t)*4) % max_iterations;
                image[index + 3] = ((uint) LERP(color1, color2, t)*6) % max_iterations;
            }
        }
    }
}
开发者ID:sazl,项目名称:CMP494Project,代码行数:54,代码来源:mandelbrot.c


示例14: apply_vbr_preset

static void
apply_vbr_preset(lame_global_flags * gfp, int a, int enforce)
{
    vbr_presets_t const *vbr_preset = lame_get_VBR(gfp) == vbr_rh ? &vbr_old_switch_map[0]
        : &vbr_psy_switch_map[0];
    float   x = gfp->VBR_q_frac;
    vbr_presets_t p = vbr_preset[a];
    vbr_presets_t q = vbr_preset[a + 1];
    vbr_presets_t const *set = &p;

    NOOP(vbr_q);
    NOOP(quant_comp);
    NOOP(quant_comp_s);
    NOOP(expY);
    LERP(st_lrm);
    LERP(st_s);
    LERP(masking_adj);
    LERP(masking_adj_short);
    LERP(ath_lower);
    LERP(ath_curve);
    LERP(ath_sensitivity);
    LERP(interch);
    NOOP(safejoint);
    NOOP(sfb21mod);
    LERP(msfix);

    (void) lame_set_VBR_q(gfp, set->vbr_q);
    SET_OPTION(quant_comp, set->quant_comp, -1);
    SET_OPTION(quant_comp_short, set->quant_comp_s, -1);
    if (set->expY) {
        (void) lame_set_experimentalY(gfp, set->expY);
    }
    SET_OPTION(short_threshold_lrm, set->st_lrm, -1);
    SET_OPTION(short_threshold_s, set->st_s, -1);
    SET_OPTION(maskingadjust, set->masking_adj, 0);
    SET_OPTION(maskingadjust_short, set->masking_adj_short, 0);
    SET_OPTION(ATHlower, set->ath_lower, 0);
    SET_OPTION(ATHcurve, set->ath_curve, -1);
    SET_OPTION(athaa_sensitivity, set->ath_sensitivity, 0);
    if (set->interch > 0) {
        SET_OPTION(interChRatio, set->interch, -1);
    }

    /* parameters for which there is no proper set/get interface */
    if (set->safejoint > 0) {
        (void) lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | set->safejoint);
    }
    if (set->sfb21mod > 0) {
        (void) lame_set_exp_nspsytune(gfp, lame_get_exp_nspsytune(gfp) | (set->sfb21mod << 20));
    }
    SET_OPTION(msfix, set->msfix, -1);

    if (enforce == 0) {
        gfp->VBR_q = a;
        gfp->VBR_q_frac = x;
    }
}
开发者ID:271845221,项目名称:Mp3VoiceRecorderSampleForAndroid,代码行数:57,代码来源:presets.c


示例15: double

double
SVGFETurbulenceElement::Noise2(int aColorChannel, double aVec[2],
                               StitchInfo *aStitchInfo)
{
  int bx0, bx1, by0, by1, b00, b10, b01, b11;
  double rx0, rx1, ry0, ry1, *q, sx, sy, a, b, t, u, v;
  long i, j;
  t = aVec[0] + sPerlinN;
  bx0 = (int) t;
  bx1 = bx0 + 1;
  rx0 = t - (int) t;
  rx1 = rx0 - 1.0f;
  t = aVec[1] + sPerlinN;
  by0 = (int) t;
  by1 = by0 + 1;
  ry0 = t - (int) t;
  ry1 = ry0 - 1.0f;
  // If stitching, adjust lattice points accordingly.
  if (aStitchInfo != NULL) {
    if (bx0 >= aStitchInfo->mWrapX)
      bx0 -= aStitchInfo->mWidth;
    if (bx1 >= aStitchInfo->mWrapX)
      bx1 -= aStitchInfo->mWidth;
    if (by0 >= aStitchInfo->mWrapY)
      by0 -= aStitchInfo->mHeight;
    if (by1 >= aStitchInfo->mWrapY)
      by1 -= aStitchInfo->mHeight;
  }
  bx0 &= sBM;
  bx1 &= sBM;
  by0 &= sBM;
  by1 &= sBM;
  i = mLatticeSelector[bx0];
  j = mLatticeSelector[bx1];
  b00 = mLatticeSelector[i + by0];
  b10 = mLatticeSelector[j + by0];
  b01 = mLatticeSelector[i + by1];
  b11 = mLatticeSelector[j + by1];
  sx = double (S_CURVE(rx0));
  sy = double (S_CURVE(ry0));
  q = mGradient[aColorChannel][b00];
  u = rx0 * q[0] + ry0 * q[1];
  q = mGradient[aColorChannel][b10];
  v = rx1 * q[0] + ry0 * q[1];
  a = LERP(sx, u, v);
  q = mGradient[aColorChannel][b01];
  u = rx0 * q[0] + ry1 * q[1];
  q = mGradient[aColorChannel][b11];
  v = rx1 * q[0] + ry1 * q[1];
  b = LERP(sx, u, v);
  return LERP(sy, a, b);
}
开发者ID:Incognito,项目名称:mozilla-central,代码行数:52,代码来源:SVGFETurbulenceElement.cpp


示例16: Scene_LerpFaceVert

void	Scene_LerpFaceVert(float amt, scenefacevert_t *v1, scenefacevert_t *v2, scenefacevert_t *out)
{	
	out->vtx[0] = LERP(amt, v1->vtx[0], v2->vtx[0]);
	out->vtx[1] = LERP(amt, v1->vtx[1], v2->vtx[1]);
	out->vtx[2] = LERP(amt, v1->vtx[2], v2->vtx[2]);	
	out->tex[0] = LERP(amt, v1->tex[0], v2->tex[0]);
	out->tex[1] = LERP(amt, v1->tex[1], v2->tex[1]);
	out->col[0] = LERP(amt, (float)v1->col[0], (float)v2->col[0]);
	out->col[1] = LERP(amt, (float)v1->col[1], (float)v2->col[1]);
	out->col[2] = LERP(amt, (float)v1->col[2], (float)v2->col[2]);
	out->col[3] = LERP(amt, (float)v1->col[3], (float)v2->col[3]);
}
开发者ID:newerthcom,项目名称:savagerebirth,代码行数:12,代码来源:scene.cpp


示例17: eval_lerp

void eval_lerp(Expr *expr)
{
	expr->l->l->fn(expr->l->l);
	expr->l->r->fn(expr->l->r);
	expr->r->fn(expr->r);
	expr->v.x = LERP(expr->l->l->v.x, expr->l->r->v.x, expr->r->v.x);
}
开发者ID:oleavitt,项目名称:gem,代码行数:7,代码来源:exeval.c


示例18: if

void CBoidBird::ClampSpeed(SBoidContext& bc,float dt)
{
	if(m_status == Bird::ON_GROUND)
	{
		if(m_onGroundStatus == Bird::OGS_WALKING)
		{
			m_speed = m_walkSpeed;
		}
		else if(m_onGroundStatus == Bird::OGS_SLOWINGDOWN)
		{
			float elapsedTimeNormalized = clamp_tpl(m_elapsedSlowdownTime / bc.fWalkToIdleDuration, 0.0f, 1.0f);
			m_speed = LERP(m_walkSpeed, 0.0f, elapsedTimeNormalized);
		}
		else if(m_onGroundStatus == Bird::OGS_IDLE)
		{
			m_speed = 0.0f;
		}
	}
	else
	{
		if (m_speed > bc.MaxSpeed)
			m_speed = bc.MaxSpeed;
		if (m_speed < bc.MinSpeed)
			m_speed = bc.MinSpeed;
	}
}
开发者ID:aronarts,项目名称:FireNET,代码行数:26,代码来源:BoidBird.cpp


示例19: noise3

static double noise3(int * p, double x, double y, double z)
{
  int X = (int)FASTFLOOR(x) & 255,                   /* FIND UNIT CUBE THAT */
      Y = (int)FASTFLOOR(y) & 255,                   /* CONTAINS POINT.     */
      Z = (int)FASTFLOOR(z) & 255;

  double u, v, w;

  int A = p[X  ]+Y, AA = p[A]+Z, AB = p[A+1]+Z,      /* HASH COORDINATES OF */
      B = p[X+1]+Y, BA = p[B]+Z, BB = p[B+1]+Z;      /* THE 8 CUBE CORNERS, */

  x -= FASTFLOOR(x);                                  /* FIND RELATIVE X,Y,Z */
  y -= FASTFLOOR(y);                                  /* OF POINT IN CUBE.   */
  z -= FASTFLOOR(z);

  u = FADE(x);                                       /* COMPUTE FADE CURVES */
  v = FADE(y);                                       /* FOR EACH OF X,Y,Z.  */
  w = FADE(z);

  return LERP(w, LERP(v, LERP(u, GRAD(p[AA  ], x    , y    , z     ),  /* AND ADD */
                                 GRAD(p[BA  ], x-1.0, y    , z     )), /* BLENDED */
                         LERP(u, GRAD(p[AB  ], x    , y-1.0, z     ),  /* RESULTS */
                                 GRAD(p[BB  ], x-1.0, y-1.0, z     ))),/* FROM  8 */
                 LERP(v, LERP(u, GRAD(p[AA+1], x    , y    , z-1.0 ),  /* CORNERS */
                                 GRAD(p[BA+1], x-1.0, y    , z-1.0 )), /* OF CUBE */
                         LERP(u, GRAD(p[AB+1], x    , y-1.0, z-1.0 ),
                                 GRAD(p[BB+1], x-1.0, y-1.0, z-1.0 ))));
}
开发者ID:agladysh,项目名称:lua-noise,代码行数:28,代码来源:perlin.c


示例20: texture_perlin_omega

fastf_t
texture_perlin_omega(struct texture_perlin_s *P, vect_t V)
{
    vect_t q;
    fastf_t r0[3], r1[3], sy, sz, a, b, c, d, t, u, v;
    int b0[3], b1[3], b00, b10, b01, b11;
    int i, j;


    for (i = 0; i < 3; i++) {
	t = V[i] + N;
	b0[i] = ((int)t) & BM;
	b1[i] = (b0[i]+1) & BM;
	r0[i] = t - (int)t;
	r1[i] = r0[i] - 1.0;
    }

    i = P->PV[b0[0]];
    j = P->PV[b1[0]];

    b00 = P->PV[i + b0[1]];
    b10 = P->PV[j + b0[1]];
    b01 = P->PV[i + b1[1]];
    b11 = P->PV[j + b1[1]];

    t = S_CURVE(r0[0]);
    sy = S_CURVE(r0[1]);
    sz = S_CURVE(r0[2]);

    VMOVE(q, P->RV[b00 + b0[2]]);
    u = AT3(r0[0], r0[1], r0[2]);
    VMOVE(q, P->RV[b10 + b0[2]]);
    v = AT3(r1[0], r0[1], r0[2]);
    a = LERP(t, u, v);

    VMOVE(q, P->RV[b01 + b0[2]]);
    u = AT3(r0[0], r1[1], r0[2]);
    VMOVE(q, P->RV[b11 + b0[2]]);
    v = AT3(r1[0], r1[1], r0[2]);
    b = LERP(t, u, v);

    c = LERP(sy, a, b);

    VMOVE(q, P->RV[b00 + b1[2]]);
    u = AT3(r0[0], r0[1], r1[2]);
    VMOVE(q, P->RV[b10 + b1[2]]);
    v = AT3(r1[0], r0[1], r1[2]);
    a = LERP(t, u, v);

    VMOVE(q, P->RV[b01 + b1[2]]);
    u = AT3(r0[0], r1[1], r1[2]);
    VMOVE(q, P->RV[b11 + b1[2]]);
    v = AT3(r1[0], r1[1], r1[2]);
    b = LERP(t, u, v);

    d = LERP(sy, a, b);

    return LERP(sz, c, d);
}
开发者ID:behollis,项目名称:brlcad-svn-rev65072-gsoc2015,代码行数:59,代码来源:texture_perlin.c



注:本文中的LERP函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LERROR函数代码示例发布时间:2022-05-30
下一篇:
C++ LEPT_FREE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap