当前位置: 首页>>代码示例>>C++>>正文


C++ Noise类代码示例

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


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

示例1: checkobject

int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L)
{
    NO_MAP_LOCK_REQUIRED;

    LuaPerlinNoiseMap *o = checkobject(L, 1);
    v3f p                = check_v3f(L, 2);
    bool use_buffer      = lua_istable(L, 3);

    if (!o->m_is3d)
        return 0;

    Noise *n = o->noise;
    n->perlinMap3D(p.X, p.Y, p.Z);

    size_t maplen = n->sx * n->sy * n->sz;

    if (use_buffer)
        lua_pushvalue(L, 3);
    else
        lua_newtable(L);

    for (size_t i = 0; i != maplen; i++) {
        lua_pushnumber(L, n->result[i]);
        lua_rawseti(L, -2, i + 1);
    }
    return 1;
}
开发者ID:rwmpelstilzchen,项目名称:minetest,代码行数:27,代码来源:l_noise.cpp

示例2: checkobject

int LuaPerlinNoiseMap::l_get3dMap(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;
	int i = 0;

	LuaPerlinNoiseMap *o = checkobject(L, 1);
	v3f p = read_v3f(L, 2);

	Noise *n = o->noise;
	n->perlinMap3D(p.X, p.Y, p.Z);

	lua_newtable(L);
	for (int z = 0; z != n->sz; z++) {
		lua_newtable(L);
		for (int y = 0; y != n->sy; y++) {
			lua_newtable(L);
			for (int x = 0; x != n->sx; x++) {
				lua_pushnumber(L, n->np->offset + n->np->scale * n->result[i++]);
				lua_rawseti(L, -2, x + 1);
			}
			lua_rawseti(L, -2, y + 1);
		}
		lua_rawseti(L, -2, z + 1);
	}
	return 1;
}
开发者ID:0151n,项目名称:minetest,代码行数:26,代码来源:l_noise.cpp

示例3: ROS_DEBUG

Particle Predictor::genNoise(float sigma, Particle pConstraint, unsigned int type){
	if(sigma == 0.0f)
                ROS_DEBUG("[Predictor::genNoise] Warning standard deviation sigma is 0.0");
	
	Particle epsilon;
	Noise N;
	
	//epsilon.r.x = noise(sigma, type) * pConstraint.r.x;
	//epsilon.r.y = noise(sigma, type) * pConstraint.r.y;
	//epsilon.r.z = noise(sigma, type) * pConstraint.r.z;
	//epsilon.t.x = noise(sigma, type) * pConstraint.t.x;
	//epsilon.t.y = noise(sigma, type) * pConstraint.t.y;
	//epsilon.t.z = noise(sigma, type) * pConstraint.t.z;
	//
	//epsilon.z   = noise(sigma, type) * pConstraint.z;
	
	epsilon.r.x = N.randn_notrig(0.0f, sigma * pConstraint.r.x);
	epsilon.r.y = N.randn_notrig(0.0f, sigma * pConstraint.r.y);
	epsilon.r.z = N.randn_notrig(0.0f, sigma * pConstraint.r.z);
	epsilon.t.x = N.randn_notrig(0.0f, sigma * pConstraint.t.x);
	epsilon.t.y = N.randn_notrig(0.0f, sigma * pConstraint.t.y);
	epsilon.t.z = N.randn_notrig(0.0f, sigma * pConstraint.t.z);
	
	epsilon.z = N.randn_notrig(0.0f, sigma * pConstraint.z);
		
	return epsilon;
}
开发者ID:achuwilson,项目名称:perception_blort,代码行数:27,代码来源:Predictor.cpp

示例4: getArgVec

MStatus mDbl3dNoise::doIt( const MArgList& args )
{
	if (args.length() == 1)
	{
    	// vector array
		// get the arguments
    	MDoubleArray dblA;
	    unsigned int count;
		MStatus stat = getArgVec(args, dblA, count);
		ERROR_FAIL(stat);
    
		// do the job
		MDoubleArray result = MDoubleArray(count);		

        Noise noiseGen;
        for(int i=0;i<count;i++)
        {
        	int id = ELEMENTS_VEC *i;
	    	result[i] = noiseGen.improvedPerlin3dS(float(dblA[id]), float(dblA[id+1]),float(dblA[id+2]));
        }
            
        setResult(result);
        
	}
	else if (args.length() == 3)
	{
		// get the arguments
	    MDoubleArray dblA, dblB, dblC;
    	unsigned int incA, incB, incC, count;
		MStatus stat = getArgDblDblDbl(args, dblA, dblB, dblC, incA, incB, incC, count);
		ERROR_FAIL(stat);
	
		// do the actual job
		unsigned int iterA, iterB, iterC;
		iterA = iterB = iterC = 0;

		MDoubleArray result(count);
		Noise noiseGen;

		for (unsigned int i=0;i<count;i++)
		{
        	result[i] = noiseGen.improvedPerlin3dS(float(dblA[iterA]), float(dblB[iterB]),  float(dblC[iterC]));

			iterA += incA;
			iterB += incB;
			iterC += incC;            
		}
		
        setResult(result);
	}
	else
	{
		USER_ERROR_CHECK(MS::kFailure,("mDbl3dNoise: wrong number of arguments, should be 1 vecArray or 3 dblArrays!"));
	}
    
	return MS::kSuccess;

}
开发者ID:jonntd,项目名称:melfunctions,代码行数:58,代码来源:mNoiseCmd.cpp

示例5: transform

void PeakFinder_SNR::findPeaks(const OrderedPairContainerRef& pairs,
                               vector<size_t>& resultIndices) const
{
    vector<OrderedPair> preprocessedData;
    if (config_.preprocessWithLogarithm)
        transform(pairs.begin(), pairs.end(), back_inserter(preprocessedData), ComputeLogarithm());  

    const OrderedPairContainerRef& data = config_.preprocessWithLogarithm ? preprocessedData : pairs;

    Noise noise = noiseCalculator_->calculateNoise(data); // TODO: investigate calculating noise on unprocessed data

    vector<double> pvalues;
    transform(data.begin(), data.end(), back_inserter(pvalues), CalculatePValue(noise));
    
    vector<double> rollingProducts = calculateRollingProducts(pvalues, config_.windowRadius);
    if (rollingProducts.size() != data.size()) 
        throw runtime_error("[PeakFinder_SNR::findPeaks()] This isn't happening"); 

    double thresholdValue = noise.mean + config_.zValueThreshold * noise.standardDeviation;
    double thresholdPValue = noise.pvalue(thresholdValue);
    double threshold = ((double(*)(double,int))std::pow)(thresholdPValue, 1+2*config_.windowRadius);

    // report local minima above the threshold
    for (size_t i=0; i<rollingProducts.size(); i++)
    {
        if ((i==0 || rollingProducts[i]<rollingProducts[i-1]) &&
            (i+1==rollingProducts.size() || rollingProducts[i]<rollingProducts[i+1]) &&
            rollingProducts[i] < threshold)
        { 
            resultIndices.push_back(i);
        }
    }

    if (config_.log) 
    {
        ostream& log = *config_.log;

        log << "[PeakFinder_SNR::findPeaks()]\n";

        log << "# noise: " << noise.mean << " " << noise.standardDeviation << endl;
        log << "# thresholdValue: " << thresholdValue << endl;
        log << "# thresholdPValue: " << thresholdPValue << endl;
        log << "# threshold: " << threshold << endl;
        log << "#\n";

        log << "# found data pvalue rollingProduct\n";
        for (size_t i=0; i<data.size(); ++i)
        {
            bool found = (find(resultIndices.begin(), resultIndices.end(), i) != resultIndices.end());
            log << (found?"* ":"  ") << fixed << setprecision(6) << data[i] << scientific << setw(15) << pvalues[i] << setw(15) << rollingProducts[i] << endl;
        }
        log << endl;

        log << "[PeakFinder_SNR::findPeaks()] end\n";
    }
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:56,代码来源:PeakFinder.cpp

示例6: getArgUV

MStatus mDbl2dNoise::doIt( const MArgList& args )
{
	if (args.length() == 1)
	{
		// get the arguments
    	MDoubleArray dblA;
	    unsigned int count;
		MStatus stat = getArgUV(args, dblA, count);
		ERROR_FAIL(stat);
    
		// do the job
		MDoubleArray result = MDoubleArray(count);		

        Noise noiseGen;
        for(int i=0;i<count;i++)
	    	result[i] = noiseGen.improvedPerlin2dS(float(dblA[i*ELEMENTS_UV]), float(dblA[i*ELEMENTS_UV+1]));
            
        setResult(result);
        
	}
	else if (args.length() == 2)
	{
		// get the arguments
	    MDoubleArray dblA, dblB;
    	unsigned int incA, incB, count;
		MStatus stat = getArgDblDbl(args, dblA, dblB, incA, incB, count);
		ERROR_FAIL(stat);
	
		// do the actual job
		unsigned int iterA, iterB;
		iterA = iterB = 0;

		MDoubleArray result(count);
		Noise noiseGen;

		for (unsigned int i=0;i<count;i++)
		{
        	result[i] = noiseGen.improvedPerlin2dS(float(dblA[iterA]), float(dblB[iterB]));

			iterA += incA;
			iterB += incB;
		}
		
        setResult(result);
	}
	else
	{
		USER_ERROR_CHECK(MS::kFailure,("mDbl2dNoise: wrong number of arguments, should be 1 uvArray or 2 dblArrays!"));
	}
    
	return MS::kSuccess;

}
开发者ID:jonntd,项目名称:melfunctions,代码行数:53,代码来源:mNoiseCmd.cpp

示例7: setBodyFile

void Guitar :: setBodyFile( std::string bodyfile )
{
  bool fileLoaded = false;
  if ( bodyfile != "" ) {
    try {
      FileWvIn file( bodyfile );
  
      // Fill the StkFrames variable with the (possibly interpolated)
      // file data.
      excitation_.resize( (unsigned long) ( 0.5 + ( file.getSize() * Stk::sampleRate() / file.getFileRate() ) ) );
      file.tick( excitation_ );
      fileLoaded = true;
    }
    catch ( StkError &error ) {
      oStream_ << "Guitar::setBodyFile: file error (" << error.getMessage() << ") ... using noise excitation.";
      handleError( StkError::WARNING );
    }
  }

  if ( !fileLoaded ) {
    unsigned int M = 200;  // arbitrary value
    excitation_.resize( M );
    Noise noise;
    noise.tick( excitation_ );
    // Smooth the start and end of the noise.
    unsigned int N = (unsigned int) M * 0.2; // arbitrary value
    for ( unsigned int n=0; n<N; n++ ) {
      StkFloat weight = 0.5 * ( 1.0 - cos( n * PI / (N-1) ) );
      excitation_[n] *= weight;
      excitation_[M-n-1] *= weight;
    }
  }

  // Filter the excitation to simulate pick hardness
  pickFilter_.tick( excitation_ );

  // Compute file mean and remove (to avoid DC bias).
  StkFloat mean = 0.0;
  for ( unsigned int i=0; i<excitation_.frames(); i++ )
    mean += excitation_[i];
  mean /= excitation_.frames();

  for ( unsigned int i=0; i<excitation_.frames(); i++ )
    excitation_[i] -= mean;

  // Reset all the file pointers.
  for ( unsigned int i=0; i<strings_.size(); i++ )
    filePointer_[i] = 0;
}
开发者ID:Ahbee,项目名称:stk,代码行数:49,代码来源:Guitar.cpp

示例8: c

void ParticleSystem::setFogModel(const Color4& color, int materialIndex) {
    const Color4unorm8 c(Color4(color.r, color.g, color.b, pow(color.a, 1.0f / SmokeVolumeSet::PARTICLE_GAMMA)));
    Random rnd;
    Noise noise;

    m_particle.resize(5000);
    m_physicsData.resize(m_particle.size());
    for (int i = 0; i < m_particle.size(); ++i) {
        SmokeVolumeSet::Particle& particle = m_particle[i];
        PhysicsData& physicsData = m_physicsData[i];

        // Fill sponza 
        particle.position = Point3(rnd.uniform(-16, 14), pow(rnd.uniform(0, 1), 4.0f) * 4 + 0.5f, rnd.uniform(-6.5, 6.5));

        /*
        if (rnd.uniform() < 0.3f) {
            // Arena bridge
            particle.position = Point3(rnd.uniform(-14, 14) - 2.0f, pow(rnd.uniform(0, 1), 5.0f) * 16.0f + 7.2f, rnd.uniform(-8, 8) - 28.0f);
        } else {
            // Arena everywhere
            particle.position = Point3(rnd.uniform(-20, 20), pow(rnd.uniform(0, 1), 5.0f) * 12.0f + 7.2f, rnd.uniform(-20, 20));
        }
        */

        particle.angle = rnd.uniform(0.0f, 2.0f) * pif(); 
        particle.materialIndex = materialIndex;
        particle.radius = 1.0f;
        particle.emissive = 0.0f;
        particle.color = c;
        int r = rnd.integer(0, 15);
        particle.color.r = unorm8::fromBits(r + particle.color.r.bits());
        particle.color.g = unorm8::fromBits(r + particle.color.g.bits());
        particle.color.b  = unorm8::fromBits(r + particle.color.b.bits());
        physicsData.angularVelocity = 0;//rnd.uniform(-1.0f, 1.0f) * (360.0f * units::degrees()) / (5.0f * units::seconds());

        // Unique values every 5m for the lowest frequencies
        const Vector3int32 intPos(particle.position * ((1 << 16) / (5 * units::meters())));
        const float acceptProbability = pow(max(0.0f, noise.sampleFloat(intPos.x, intPos.y, intPos.z, 5)), 2.0f);

        if (rnd.uniform() > acceptProbability) {
            // Reject this puff
            --i;
        }
    }

    // Ensure that this matches
    m_physicsData.resize(m_particle.size());
}
开发者ID:lieff,项目名称:g3d,代码行数:48,代码来源:ParticleSystemModel.cpp

示例9: predict_obsrv

    void predict_obsrv(Tuple& models_tuple,
                       double delta_time,
                       const State& state,
                       const Noise& noise,
                       Obsrv& prediction,
                       const int obsrv_offset = 0,
                       const int state_offset = 0,
                       const int noise_offset = 0)
    {
        auto&& model = std::get<k>(models_tuple);

        const auto obsrv_dim = model->obsrv_dimension();
        const auto state_dim = model->state_dimension();
        const auto noise_dim = model->noise_dimension();

        prediction.middleRows(obsrv_offset, obsrv_dim) =
            model->predict_obsrv(
                state.middleRows(state_offset, state_dim),
                noise.middleRows(noise_offset, noise_dim),
                delta_time
            );

        if (Size == k + 1) return;

        predict_obsrv<Size, k + (k + 1 < Size ? 1 : 0)>(
                    models_tuple,
                    delta_time,
                    state,
                    noise,
                    prediction,
                    obsrv_offset + obsrv_dim,
                    state_offset + state_dim,
                    noise_offset + noise_dim);
    }
开发者ID:cassinaj,项目名称:fl,代码行数:34,代码来源:joint_observation_model_id.hpp

示例10: main

int main(int argc, char* argv[]) {

  uint16_t length = 2048;

  Noise noise;
  noise.reg0 = 0;
  noise.reg1 = 0;
  noise.reg2 = 0;

  for (int i = 0; i < length; ++i) {
    noise.update();
    std::cout << (int)noise.sample();
  }
  std::cout << "\n";

}
开发者ID:crust,项目名称:nes,代码行数:16,代码来源:apu_test.cpp

示例11: ACADOERROR

returnValue Sensor::setOutputNoise(	const Noise& _noise,
									double _noiseSamplingTime
									)
{
	if ( _noise.getDim( ) != getNY( ) )
		return ACADOERROR( RET_INVALID_ARGUMENTS );

	for( uint i=0; i<getNY( ); ++i )
	{
		if ( additiveNoise[i] != 0 )
			delete additiveNoise[i];

		additiveNoise[i] = _noise.clone( i );
	}

	noiseSamplingTimes.setAll( _noiseSamplingTime );

	return SUCCESSFUL_RETURN;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:19,代码来源:sensor.cpp

示例12: checkobject

int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L)
{
	NO_MAP_LOCK_REQUIRED;

	LuaPerlinNoiseMap *o = checkobject(L, 1);
	v2f p = check_v2f(L, 2);

	Noise *n = o->noise;
	n->perlinMap2D(p.X, p.Y);

	size_t maplen = n->sx * n->sy;

	lua_newtable(L);
	for (size_t i = 0; i != maplen; i++) {
		lua_pushnumber(L, n->result[i]);
		lua_rawseti(L, -2, i + 1);
	}
	return 1;
}
开发者ID:Jetqvvf,项目名称:minetest,代码行数:19,代码来源:l_noise.cpp

示例13: getArgDbl

MStatus mDbl1dNoise::doIt( const MArgList& args )
{
	// get the arguments
    MDoubleArray dblA;
    unsigned int count;
	MStatus stat = getArgDbl(args, dblA, count);
	ERROR_FAIL(stat);
    
	// do the actual job
	Noise noiseGen;
    
	for (unsigned int i=0;i<dblA.length();i++)
	{
        dblA[i] = noiseGen.improvedPerlin1dS(float(dblA[i]));
	}

	setResult(dblA);
	return MS::kSuccess;
}
开发者ID:jonntd,项目名称:melfunctions,代码行数:19,代码来源:mNoiseCmd.cpp

示例14: main

OIIO_NAMESPACE_USING

int main()
{
  constexpr int xres = 1024, yres = 720;
  constexpr int channels = 1; // RGB
  int frame=0;

  std::unique_ptr<float []>pixels(new float[xres*yres*channels]);
  std::unique_ptr <ImageOutput> out( ImageOutput::create ("test.png"));
  ImageSpec spec (xres, yres, channels, TypeDesc::FLOAT);

  Noise<uint_fast8_t> n;

 // for(float no=0.001; no<1.0; no+=0.005)
  for(int f=0; f<200; ++f)
  {
    std::cout<<"frame "<<frame<<" "<<f<<"\n";
  int i=-1;
  n.setSeed(f);
  for(int y=0; y<yres; ++y)
  {
    for(int x=0; x<xres; ++x)
    {
//      pixels[++i]=n.complex(12,5.02,0.1,Point(x,y,0.0f));
      pixels[++i]=n.complex(13,3.02,0.1,Point(x,y,0.0f));
     // pixels[++i]=n.complex(8,8.02,no,Point(x,y,0.0f));
     //pixels[++i]=n.noise(0.55,Point(x,y,0.0f));
//     pixels[++i]=n.noise(0.2,Point(x,y,0.0f));
//     pixels[++i]=n.noise(0.3,Point(x,y,0.0f));
//    pixels[++i]=n.turbulance(0.9,Point(x,y,0.0f));
//    pixels[++i]=n.turbulance(1.09,Point(x,y,0.0f));
   // pixels[++i]=n.turbulance(no,Point(x,y,0.0f));
    }
  }
  char str[40];
  sprintf(str,"noiseSeed%03d.png",frame++);
  out->open (str, spec);
  out->write_image (TypeDesc::FLOAT, pixels.get());
  out->close();
  }
  return EXIT_SUCCESS;
}
开发者ID:NCCA,项目名称:RandomTests,代码行数:43,代码来源:main.cpp

示例15: DeleteNoise

bool DeleteNoise(char* src){
	Noise N;
	
	ofstream FS("pattern_elman.txt");

	int pattern_s = N.delete_noise(src);
	FS << pattern_s << " ";
	for (int i = pattern_s; i > 0; --i)
	{
		FS << i << ".bmp ";
		for (int j = pattern_s; j > 0; --j)
		{
			FS << (j == i)?"1":"0";
			FS << " ";
		}
	}
	
	FS.close();
	return 1;
}
开发者ID:PelinV,项目名称:Elman,代码行数:20,代码来源:main.cpp


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