示例#1
0
int main() {
    double x = 1.0;
    double y = 1.0;
    int i = 1;
    acosh(x);
    asinh(x);
    atanh(x);
    cbrt(x);
    expm1(x);
    erf(x);
    erfc(x);
    isnan(x);
    j0(x);
    j1(x);
    jn(i,x);
    ilogb(x);
    logb(x);
    log1p(x);
    rint(x);
    y0(x);
    y1(x);
    yn(i,x);
#   ifdef _THREAD_SAFE
    gamma_r(x,&i);
    lgamma_r(x,&i);
#   else
    gamma(x);
    lgamma(x);
#   endif
    hypot(x,y);
    nextafter(x,y);
    remainder(x,y);
    scalb(x,y);
    return 0;
}
示例#2
0
void Ambix_wideningAudioProcessor::calcParams()
{
    checkBuffer();
    
    if (param_changed) {
        
        // set new latency
        if (single_sided)
            setLatencySamples(0);
        else
            setLatencySamples(Q*BESSEL_APPR);
        
        // parameters in rad
        
        double phi_hat = ((double)mod_depth_param)*2*M_PI;
        double rot_offset = M_PI - ((double)rot_offset_param + 0.002)*2*M_PI; // offset needed - why??
        
        // std::cout << "MATRIX:" << std::endl;
        
        for (int m=1; m <= AMBI_ORDER; m++) {
            
            // String output_cos = "cos: ";
            // String output_sin = "sin: ";
            
            for (int lambda = 0; lambda <= BESSEL_APPR; lambda++) {
                
                double bessel = jn(lambda, (double)m*phi_hat);
                
                double d_cos_coeff = cos(M_PI_2*lambda + m*rot_offset)*bessel;
                double d_sin_coeff = sin(M_PI_2*lambda + m*rot_offset)*bessel;
                
                //////
                // set zero if lower then threshold defined in .h file
                if (fabs(d_cos_coeff) < TRUNCATE) {
                    d_cos_coeff = 0.f;
                }
                if (fabs(d_cos_coeff) < TRUNCATE) {
                    d_sin_coeff = 0.f;
                }
                
                cos_coeffs[m-1][lambda] = (float)d_cos_coeff;
                sin_coeffs[m-1][lambda] = (float)d_sin_coeff;
                
                
                // output_cos << String(cos_coeffs[m-1][lambda]).substring(0, 4);
                // output_cos << " ";
                
                
                // output_sin << String(sin_coeffs[m-1][lambda]).substring(0, 4);
                // output_sin << " ";
                
            }
            // std::cout << output_cos << std::endl;
            // std::cout << output_sin << std::endl;
        }
        
        param_changed = false;
    }
    
}
示例#3
0
double lommel(int n, double mu, double nu)
{
  
  double val, x;
  int k, kmax;
  double eps = 1e-15;

  kmax = 100;

   val = 0.0;

  for(k=0; k<=kmax; k++){

    x = pow(-1.0, k)*pow(mu/nu, n + 2*k) * jn(n+2*k, PI*mu*nu);

    if(fabs(x) < eps){
      val += x;
      break;
    }else{
      val += x;
    }
  }

  return val;

}
示例#4
0
int main(void)
{
	#pragma STDC FENV_ACCESS ON
	double y;
	float d;
	int e, i, err = 0;
	struct di_d *p;

	for (i = 0; i < sizeof t/sizeof *t; i++) {
		p = t + i;

		if (p->r < 0)
			continue;
		fesetround(p->r);
		feclearexcept(FE_ALL_EXCEPT);
		y = jn(p->i, p->x);
		e = fetestexcept(INEXACT|INVALID|DIVBYZERO|UNDERFLOW|OVERFLOW);

		if (!checkexcept(e, p->e, p->r)) {
			printf("%s:%d: bad fp exception: %s jn(%lld, %a)=%a, want %s",
				p->file, p->line, rstr(p->r), p->i, p->x, p->y, estr(p->e));
			printf(" got %s\n", estr(e));
			err++;
		}
		d = ulperr(y, p->y, p->dy);
		if (!checkulp(d, p->r)) {
			printf("%s:%d: %s jn(%lld, %a) want %a got %a, ulperr %.3f = %a + %a\n",
				p->file, p->line, rstr(p->r), p->i, p->x, p->y, y, d, d-p->dy, p->dy);
			err++;
		}
	}
	return !!err;
}
示例#5
0
void main()
  {
     double x, y, z;

     x = j0( 2.4 );
     y = y1( 1.58 );
     z = jn( 3, 2.4 );
     printf( "j0(2.4) = %f, y1(1.58) = %f\n", x, y );
     printf( "jn(3,2.4) = %f\n", z );
  }
void Foam::equationReader::evalScalarFieldJn
(
    const equationReader * eqnReader,
    const label index,
    const label i,
    const label storageOffset,
    label& storeIndex,
    scalarField& x,
    const scalarField& source
) const
{
    int xi(x[0]);
    jn(x, xi, source);
}
示例#7
0
void nonMaximaSuppression(const Mat& src, const int sz, Mat& dst, const Mat mask) {

    // initialise the block mask and destination
    const int M = src.rows;
    const int N = src.cols;
    const bool masked = !mask.empty();
    Mat block = 255*Mat_<uint8_t>::ones(Size(2*sz+1,2*sz+1));
    dst = Mat_<uint8_t>::zeros(src.size());

    // iterate over image blocks
    for (int m = 0; m < M; m+=sz+1) {
            for (int n = 0; n < N; n+=sz+1) {
                    Point  ijmax;
                    double vcmax, vnmax;

                    // get the maximal candidate within the block
                    Range ic(m, min(m+sz+1,M));
                    Range jc(n, min(n+sz+1,N));
                    minMaxLoc(src(ic,jc), NULL, &vcmax, NULL, &ijmax, masked ? mask(ic,jc) : noArray());
                    Point cc = ijmax + Point(jc.start,ic.start);

                    // search the neighbours centered around the candidate for the true maxima
                    Range in(max(cc.y-sz,0), min(cc.y+sz+1,M));
                    Range jn(max(cc.x-sz,0), min(cc.x+sz+1,N));

                    // mask out the block whose maxima we already know
                    Mat_<uint8_t> blockmask;
                    block(Range(0,in.size()), Range(0,jn.size())).copyTo(blockmask);
                    Range iis(ic.start-in.start, min(ic.start-in.start+sz+1, in.size()));
                    Range jis(jc.start-jn.start, min(jc.start-jn.start+sz+1, jn.size()));
                    blockmask(iis, jis) = Mat_<uint8_t>::zeros(Size(jis.size(),iis.size()));

                    minMaxLoc(src(in,jn), NULL, &vnmax, NULL, &ijmax, masked ? mask(in,jn).mul(blockmask) : blockmask);
                    Point cn = ijmax + Point(jn.start, in.start);

                    // if the block centre is also the neighbour centre, then it's a local maxima
                    if (vcmax > vnmax) {
                            dst.at<uint8_t>(cc.y, cc.x) = src.at<uint8_t>(cc.y, cc.x);
                    }

            }
    }
}
void
TestSourceNode() {
    tbb::flow::graph g;
    tbb::flow::source_node<int> sn(g, snode_body(4), false);
    REMARK("Testing source_node:");
    tbb::flow::queue_node<int> qin(g);
    tbb::flow::join_node<tbb::flow::tuple<int,int>, tbb::flow::reserving> jn(g);
    tbb::flow::queue_node<tbb::flow::tuple<int,int> > qout(g);
    
    REMARK(" make_edges");
    tbb::flow::make_edge(sn, tbb::flow::input_port<0>(jn));
    tbb::flow::make_edge(qin, tbb::flow::input_port<1>(jn));
    tbb::flow::make_edge(jn,qout);
    ASSERT(!sn.my_successors.empty(), "source node has no successor after make_edge");
    g.wait_for_all();
    g.reset();
    ASSERT(!sn.my_successors.empty(), "source node has no successor after reset");
#if TBB_PREVIEW_FLOW_GRAPH_FEATURES
    g.wait_for_all();
    g.reset(tbb::flow::rf_extract);
    ASSERT(sn.my_successors.empty(), "source node has successor after reset(rf_extract)");
    tbb::flow::make_edge(sn, tbb::flow::input_port<0>(jn));
    tbb::flow::make_edge(qin, tbb::flow::input_port<1>(jn));
    tbb::flow::make_edge(jn,qout);
    g.wait_for_all();
#endif
    REMARK(" activate");
    sn.activate();  // will forward to the fnode
    REMARK(" wait1");
    BACKOFF_WAIT( !sn.my_successors.empty(), "Timed out waiting for edge to reverse");
    ASSERT(sn.my_successors.empty(), "source node has no successor after forwarding message");

    g.wait_for_all();
    g.reset();
    ASSERT(!sn.my_successors.empty(), "source_node has no successors after reset");
    ASSERT(tbb::flow::input_port<0>(jn).my_predecessors.empty(), "successor if source_node has pred after reset.");
    REMARK(" done\n");
}
示例#9
0
int main(int argc, char *argv[])
{
  double x = 0.0;
  if (argv) x = jn((double) argc, (double) argc);
  return 0;
}
示例#10
0
static double
l_jn(char *nm)
{
    return(jn((int)(argument(1)+.5), argument(2)));
}
complex<double> BesselState::bessel_state2D(double x, double y) {
    return normalization * exp(complex<double>(0., phase)) * complex<double> (jn(int(angular_momentum), x * zero / grid->length_x) * cos(M_PI * double(n_y) / grid->length_y * y), 0.);
}
示例#12
0
int main(int argc, char *argv[])
{
  double x;
  x = jn((double) argc, (double) argc);
  return 0;
}
示例#13
0
文件: dbes.c 项目: sharugupta/OpenUH
double
G77_dbesjn_0 (const integer * n, double *x)
{
  return jn (*n, *x);
}
示例#14
0
文件: bes.c 项目: sharugupta/OpenUH
float
G77_besjn_0 (const integer * n, real * x)
{
  return (float) jn (*n, (double) *x);
}
示例#15
0
long double jnl(int n, long double x)
{
	return (long double) jn(n, (double)x);
}
示例#16
0
void test_fp_and_80x87_math( void )
{
    double      dnum;
    int         inum;
#ifdef __FPI__
    unsigned    fp_status, fp_control, fp_mask, origbits, bits;
#endif

    printf( "Testing other floating point " );
#ifdef __FPI__
    printf( "and 80x87 specific " );
#endif
    printf( "functions...\n" );
    VERIFY( CompDbl( j0( 2.387 ), 0.009288 ) );
    VERIFY( CompDbl( j1( 2.387 ), 0.522941 ) );
    VERIFY( CompDbl( jn( 2, 2.387 ), 0.428870 ) );
    VERIFY( CompDbl( y0( 2.387 ), 0.511681 ) );
    VERIFY( CompDbl( y1( 2.387 ), 0.094374 ) );
    VERIFY( CompDbl( yn( 2, 2.387 ), -0.432608 ) );
    VERIFY( ceil( 1.0001 ) == 2.0 );
    VERIFY( ceil( -1.0001 ) == -1.0 );
    VERIFY( floor( 1.0001 ) == 1.0 );
    VERIFY( floor( -1.0001 ) == -2.0 );
    VERIFY( CompDbl( exp( 1.0 ), E ) );
    VERIFY( CompDbl( exp( 3.0 ), E * E * E ) );
    VERIFY( exp( 0.0 ) == 1.0 );
    VERIFY( fabs( -1.5 ) == 1.5 );
    VERIFY( fabs( 2.5 ) == 2.5 );
    VERIFY( fabs( 0.0 ) == 0.0 );
    VERIFY( fmod( 2.5, 0.5 ) == 0.0 );
    VERIFY( fmod( 4.5, 2.0 ) == 0.5 );
    VERIFY( fmod( -4.5, 2.0 ) == -0.5 );
    VERIFY( fmod( -7.5, -2.0 ) == -1.5 );
    dnum = frexp( 65535.0, &inum );
    VERIFY( inum == 16 );
    VERIFY( CompDbl( ldexp( dnum, inum ), 65535.0 ) );
    while( inum-- > 0 ) dnum *= 2;
    VERIFY( CompDbl( dnum, 65535.0 ) );
    VERIFY( CompDbl( log( E ), 1.0 ) );
    VERIFY( CompDbl( log( 1.0 ), 0.0 ) );
    VERIFY( CompDbl( log( 1.0 / E ), -1.0 ) );
    VERIFY( CompDbl( log10( 10.0 ), 1.0 ) );
    VERIFY( CompDbl( log10( 1 ), 0.0 ) );
    VERIFY( CompDbl( log10( 0.1 ), -1.0 ) );
#ifdef __WATCOMC__      /* Not in Microsoft libs. */
    VERIFY( CompDbl( log2( 65536.0 ), 16.0 ) );
    VERIFY( CompDbl( log2( 1 ), 0.0 ) );
    VERIFY( CompDbl( log2( 0.25 ), -2.0 ) );
#endif
    VERIFY( CompDbl( sqrt( 99980001.0 ), 9999.0 ) );
    dnum = 1.0/DBL_MIN;
    VERIFY( CompDbl( 1.0 / dnum, DBL_MIN ) );
    VERIFY( CompDbl( modf( PI, &dnum ), PI - 3.0 ) );
    VERIFY( dnum == 3.0 );
    VERIFY( CompDbl( modf( -PI, &dnum ) , - PI + 3.0 ) );
    VERIFY( dnum == -3.0 );
    VERIFY( pow( 1.0, 123456789.0 ) == 1.0 );
    VERIFY( pow( 2.0, 16.0 ) == 65536.0 );
    VERIFY( CompDbl( pow( E, log(1234.0) ), 1234.0 ) );
#ifdef __FPI__
    VERIFY( sqrt( -1 ) == 1 );
    // Now my_matherrno should == DOMAIN after calling sqrt( -1 )
    // If not, matherr() fails
    VERIFY( my_matherrno == DOMAIN );
    my_matherrno = 0;   // reset
    VERIFY( sqrt( 0 ) == 0 );
    VERIFY( my_matherrno == 0 );
    _fpreset();
    fp_status = _clear87();
    VERIFY( fp_status == 0 );
    //
    fp_status = _status87();
    VERIFY( fp_status == 0 );
    //
    _fpreset();
    fp_control = _control87( 0, 0 );
    bits = fp_control & MCW_IC;
    bits = (bits == IC_AFFINE) ? IC_PROJECTIVE : IC_AFFINE;
    fp_control = _control87( bits, MCW_IC );
    VERIFY( (fp_control & MCW_IC) ==  bits );
    bits = (bits == IC_AFFINE) ? IC_PROJECTIVE : IC_AFFINE;
    fp_control = _control87( bits, MCW_IC );
    VERIFY( (fp_control & MCW_IC) ==  bits );
    //
    fp_control = _control87( 0, 0 );
    origbits = fp_control & MCW_RC;
    bits = (origbits == RC_NEAR) ? RC_CHOP : RC_NEAR;
    fp_control = _control87( bits, MCW_RC );
    VERIFY( (fp_control & MCW_RC) ==  bits );
    fp_control = _control87( origbits, MCW_RC );
    VERIFY( (fp_control & MCW_RC) ==  origbits );
    //
    _fpreset();
    fp_control = 0;
    fp_mask = _EM_INEXACT;
    signal( SIGFPE, (void (*)(int))my_handler );
    (void)_control87( fp_control, fp_mask );
    q = a / b;
    VERIFY( sig_count > 0 );
    fp_control = _EM_INEXACT;
    (void)_control87( fp_control, fp_mask );
    sig_count = 0;
    q = a / b;
    VERIFY( sig_count == 0 );
    signal( SIGFPE, SIG_DFL );
#endif
}
示例#17
0
TEST(math, jn) {
  ASSERT_DOUBLE_EQ(0.0, jn(4, 0.0));
  ASSERT_DOUBLE_EQ(0.0024766389641099553, jn(4, 1.0));
}
示例#18
0
double G77_besjn_0 (const integer *n, real *x) {
     return jn (*n, *x);
 }
示例#19
0
文件: skeleton.cpp 项目: cpzhang/zen
// Load an animation clip
MStatus skeleton::loadClip(MString clipName,int start,int stop,int rate)
{
	uint fps = getFps();
	float frameTime = 1000.0f / fps;

	MStatus stat;
	int i,j;
	std::vector<int> times;
	if (m_joints.size() < 0)
		return MS::kFailure;

	times.clear();
	for (int t=start; t<stop; t+=rate)
		times.push_back(t);
	times.push_back(stop);

	// create the animation
	animation a;
	a.name = clipName.asChar();
	
	if(m_animations.size() == 0)
	{
		a.startTime = 0;
		a.endTime = times[times.size()-1] - times[0];
	}
	else
	{
		a.startTime = m_animations[m_animations.size()-1].endTime + 1;
		a.endTime = a.startTime + times[times.size()-1] - times[0];
	}

	m_animations.push_back(a);
	int animIdx = m_animations.size() - 1;

	for (i=0; i<times.size(); i++)
	{
		MAnimControl::setCurrentTime(MTime(times[i],MTime::uiUnit()));
		for (j=0; j<m_joints.size(); j++)
		{
			keyframeTranslation translation;
			keyframeRotation rotation;
			keyframeScale scale;

			joint &jt = m_joints[j];
			int time = times[i] - times[0] + a.startTime;
			loadKeyframe(m_joints[j],time,translation,rotation,scale);
			translation.time *= frameTime;
			rotation.time *= frameTime;
			scale.time *= frameTime;

			size_t size = jt.keyframesTranslation.size();
			if(size > 0)
			{
				keyframeTranslation& t = jt.keyframesTranslation[size - 1];
				if(!equal(translation.v[0],t.v[0]) || !equal(translation.v[1],t.v[1]) || !equal(translation.v[2],t.v[2]))
				{
					//如果跟上一次不一样,并且跨越了桢,那么需要补一桢
					int lastTime = Round(t.time / frameTime);
					if(time - 1 > lastTime)
					{
						keyframeTranslation temp = t;
						temp.time = (time - 1) * frameTime;
						jt.keyframesTranslation.push_back(temp);
					}
					jt.keyframesTranslation.push_back(translation);
				}
			}
			else
			{
				jt.keyframesTranslation.push_back(translation);
			}

			MFnIkJoint jn(jt.jointDag);
			if(jn.name() == "Hips")
			{
//				breakable;
			}
			size = jt.keyframesRotation.size();
			if(size > 0)
			{
				keyframeRotation& r = jt.keyframesRotation[size - 1];
				if(!equal(rotation.q[0],r.q[0]) || !equal(rotation.q[1],r.q[1]) || !equal(rotation.q[2],r.q[2]) || !equal(rotation.q[3],r.q[3]))
				{
					//如果跟上一次不一样,并且跨越了桢,那么需要补一桢
					int lastTime = Round(r.time / frameTime);
					if(time - 1 > lastTime)
					{
						keyframeRotation temp = r;
						temp.time = (time - 1) * frameTime;
						jt.keyframesRotation.push_back(temp);
					}
					jt.keyframesRotation.push_back(rotation);
				}
			}
			else
			{
				jt.keyframesRotation.push_back(rotation);
			}
			size = jt.keyframesScale.size();
			if(size > 0)
			{
				keyframeScale& s = jt.keyframesScale[size - 1];
				if(!equal(scale.v[0],s.v[0]) || !equal(scale.v[1],s.v[1]) || !equal(scale.v[2],s.v[2]))
				{
					//如果跟上一次不一样,并且跨越了桢,那么需要补一桢
					int lastTime = Round(s.time / frameTime);
					if(time - 1 > lastTime)
					{
						keyframeScale temp = s;
						temp.time = (time - 1) * frameTime;
						jt.keyframesScale.push_back(temp);
					}
					jt.keyframesScale.push_back(scale);
				}
			}
			else
			{
				jt.keyframesScale.push_back(scale);
			}

			if(jt.hasRibbonSystem)
			{
				keyframeT<bool> keyframeVisible;
				keyframeT<float> keyframeAbove;
				keyframeT<float> keyframeBelow;
				keyframeT<short> keyframeSlot;
				keyframeT<float3> keyframeColor;
				keyframeT<float> keyframeAlpha;

				MFnIkJoint jointFn(jt.jointDag);
				MPlug plug;

				plug = jointFn.findPlug("unRibbonVisible");
				bool visible;
				plug.getValue(visible);
				plug = jointFn.findPlug("unRibbonAbove");
				float above;
				plug.getValue(above);
				plug = jointFn.findPlug("unRibbonBelow");
				float below;
				plug.getValue(below);
				plug = jointFn.findPlug("unRibbonTextureSlot");
				short slot;
				plug.getValue(slot);
				plug = jointFn.findPlug("unRibbonVertexColor");
				MObject object;
				plug.getValue(object);
				MFnNumericData data(object);
				float r,g,b;
				data.getData(r,g,b);
				plug = jointFn.findPlug("unRibbonVertexAlpha");
				float alpha;
				plug.getValue(alpha);

				keyframeVisible.time = time * frameTime;
				keyframeAbove.time = time * frameTime;
				keyframeBelow.time = time * frameTime;
				keyframeSlot.time = time * frameTime;
				keyframeColor.time = time * frameTime;
				keyframeAlpha.time = time * frameTime;

				keyframeVisible.data = visible;
				keyframeAbove.data = above;
				keyframeBelow.data = below;
				keyframeSlot.data = slot;
				keyframeColor.data[0] = r;
				keyframeColor.data[1] = g;
				keyframeColor.data[2] = b;
				keyframeAlpha.data = alpha;

				addKeyFramesBool(&jt.ribbon.keyframesVisible,&keyframeVisible);
				addKeyFramesFloat(&jt.ribbon.keyframeAbove,&keyframeAbove);
				addKeyFramesFloat(&jt.ribbon.keyframeBelow,&keyframeBelow);
				size = jt.ribbon.keyframeSlot.size();
				if(size > 0)
				{
					keyframeT<short>& s = jt.ribbon.keyframeSlot[size - 1];
					if(s.data == slot)
					{
						jt.ribbon.keyframeSlot.push_back(keyframeSlot);
					}
				}
				else
				{
					jt.ribbon.keyframeSlot.push_back(keyframeSlot);
				}
				size = jt.ribbon.keyframeColor.size();
				if(size > 0)
				{
					keyframeT<float3>& s = jt.ribbon.keyframeColor[size - 1];
					if(!equal(s.data[0],r) || !equal(s.data[1],g) || !equal(s.data[2],b))
					{
						jt.ribbon.keyframeColor.push_back(keyframeColor);
					}
				}
				else
				{
					jt.ribbon.keyframeColor.push_back(keyframeColor);
				}
				addKeyFramesFloat(&jt.ribbon.keyframeAlpha,&keyframeAlpha);
			}
			if(jt.hasParticleSystem)
			{
				keyframeT<bool> keyframeVisible;
				keyframeT<float> keyframeSpeed;
				keyframeT<float> keyframeVariation;
				keyframeT<float> keyframeConeAngle;
				keyframeT<float> keyframeGravity;
				keyframeT<float> keyframeExplosiveForce;
				keyframeT<float> keyframeEmissionRate;
				keyframeT<float> keyframeWidth;
				keyframeT<float> keyframeLength;
				keyframeT<float> keyframeHeight;

				MFnIkJoint jointFn(jt.jointDag);
				MPlug plug;

				plug = jointFn.findPlug("unParticleVisible");
				bool visible;
				plug.getValue(visible);
				plug = jointFn.findPlug("unParticleSpeed");
				float speed;
				plug.getValue(speed);
				plug = jointFn.findPlug("unParticleVariationPercent");
				float variation;
				plug.getValue(variation);
				plug = jointFn.findPlug("unParticleConeAngle");
				float coneAngle;
				plug.getValue(coneAngle);
				plug = jointFn.findPlug("unParticleGravity");
				float gravity;
				plug.getValue(gravity);
				plug = jointFn.findPlug("unParticleExplosiveForce");
				float explosiveForce = 0.0f;
				if(!plug.isNull())
				{
					plug.getValue(explosiveForce);
				}
				plug = jointFn.findPlug("unParticleEmissionRate");
				float emissionRate;
				plug.getValue(emissionRate);
				plug = jointFn.findPlug("unParticleEmitterWidth");
				float width;
				plug.getValue(width);
				plug = jointFn.findPlug("unParticleEmitterLength");
				float length;
				plug.getValue(length);
				plug = jointFn.findPlug("unParticleEmitterHeight");
				float height = 0.0f;
				if(!plug.isNull())
				{
					plug.getValue(height);
				}

				keyframeVisible.time = time * frameTime;
				keyframeSpeed.time = time * frameTime;
				keyframeVariation.time = time * frameTime;
				keyframeConeAngle.time = time * frameTime;
				keyframeGravity.time = time * frameTime;
				keyframeExplosiveForce.time = time * frameTime;
				keyframeEmissionRate.time = time * frameTime;
				keyframeWidth.time = time * frameTime;
				keyframeLength.time = time * frameTime;
				keyframeHeight.time = time * frameTime;

				keyframeVisible.data = visible;
				keyframeSpeed.data = speed;
				keyframeVariation.data = variation / 100.0f;
				keyframeConeAngle.data = coneAngle;
				keyframeGravity.data = gravity;
				keyframeExplosiveForce.data = explosiveForce;
				keyframeEmissionRate.data = emissionRate;
				keyframeWidth.data = width;
				keyframeLength.data = length;
				keyframeHeight.data = height;

				addKeyFramesBool(&jt.particle.keyframesVisible,&keyframeVisible);
				addKeyFramesFloat(&jt.particle.keyframesSpeed,&keyframeSpeed);
				addKeyFramesFloat(&jt.particle.keyframesVariation,&keyframeVariation);
				addKeyFramesFloat(&jt.particle.keyframesConeAngle,&keyframeConeAngle);
				addKeyFramesFloat(&jt.particle.keyframesGravity,&keyframeGravity);
				addKeyFramesFloat(&jt.particle.keyframesExplosiveForce,&keyframeExplosiveForce);
				addKeyFramesFloat(&jt.particle.keyframesEmissionRate,&keyframeEmissionRate);
				addKeyFramesFloat(&jt.particle.keyframesWidth,&keyframeWidth);
				addKeyFramesFloat(&jt.particle.keyframesLength,&keyframeLength);
				addKeyFramesFloat(&jt.particle.keyframesHeight,&keyframeHeight);
			}
		}
	}

	return MS::kSuccess;
}
示例#20
0
文件: skeleton.cpp 项目: cpzhang/zen
//#include "d3dx10.h"
//#pragma comment(lib, "d3dx10.lib")
void skeleton::loadKeyframe(joint& j,int time,keyframeTranslation& translation,keyframeRotation& rotation,keyframeScale& scale)
{
	MVector position;

	int parentIdx = j.parentIndex;
int DEBUG_TIME = 7;
	MMatrix matrix;
	{
		matrix = j.jointDag.inclusiveMatrix();
		MFnIkJoint jn(j.jointDag);
		if(jn.name() == "L_toe2")
		{
			char str[256];
			sprintf(str,"%5.5f,%5.5f,%5.5f\n\n",matrix[3][0],matrix[3][1],matrix[3][2]);
			OutputDebugString(str);
		}
		if(time == DEBUG_TIME)
		{
			MFnIkJoint jn(j.jointDag);
			if(jn.name() == "L_knee")
			{
				char str[256];
				sprintf(str,"%5.5f,%5.5f,%5.5f,%5.5f\n%5.5f,%5.5f,%5.5f,%5.5f\n%5.5f,%5.5f,%5.5f,%5.5f\n%5.5f,%5.5f,%5.5f,%5.5f\n\n",
					matrix[0][0],matrix[0][1],matrix[0][2],matrix[0][3],
					matrix[1][0],matrix[1][1],matrix[1][2],matrix[1][3],
					matrix[2][0],matrix[2][1],matrix[2][2],matrix[2][3],
					matrix[3][0],matrix[3][1],matrix[3][2],matrix[3][3]);
				//sprintf(str,"%5.5f,%5.5f,%5.5f\n\n",matrix[3][0],matrix[3][1],matrix[3][2]);
				OutputDebugString(str);
//				breakable;
			}
		}

		//printMatrix(matrix);
		MMatrix worldMatrix = j.worldMatrix;
		//printMatrix(worldMatrix);

		MMatrix invWorldMatrix = worldMatrix.inverse();
		//matrix = invWorldMatrix * matrix;

		//MTransformationMatrix mtm = matrix;
		//double q_x,q_y,q_z,q_w;
		//mtm.getRotationQuaternion(q_x,q_y,q_z,q_w);
		//double s_xyz[3];
		//mtm.getScale(s_xyz,MSpace::kWorld);
		//MVector t_xyz = mtm.getTranslation(MSpace::kWorld);

		//D3DXMATRIX d3dM(matrix[0][0],matrix[0][1],matrix[0][2],matrix[0][3],
		//	matrix[1][0],matrix[1][1],matrix[1][2],matrix[1][3],
		//	matrix[2][0],matrix[2][1],matrix[2][2],matrix[2][3],
		//	matrix[3][0],matrix[3][1],matrix[3][2],matrix[3][3]);

		//D3DXVECTOR3 d3dS,d3dT;
		//D3DXQUATERNION d3dQ;
		//HRESULT hr = D3DXMatrixDecompose(&d3dS,&d3dQ,&d3dT,&d3dM);

		//MMatrix matrixT = worldMatrix * matrix;


		//float t[3],q[4],s[3];
		//extractTranMatrix(matrix,t,q,s);

		//Vector3 t1(t[0],t[1],t[2]);
		//Quaternion q1(q_x,q_y,q_z,q_w);//q[0],q[1],q[2],q[3]);
		//Vector3 s1(s[0],s[1],s[2]);
		//Matrix4 m;
		//m.transform(t1,s1,q1);

		//printMatrix(matrix);

		if(j.parentIndex >= 0)
		{
			MMatrix pMatrix = m_joints[parentIdx].jointDag.inclusiveMatrix();
			//printMatrix(pMatrix);
			MMatrix pWorldMatrix = m_joints[parentIdx].worldMatrix;
			//printMatrix(pWorldMatrix);
			MMatrix invpWorldMatrix = pWorldMatrix.inverse();
			//pMatrix = invpWorldMatrix * pMatrix;
			//printMatrix(pMatrix);

			MMatrix pInvMatrix = pMatrix.inverse();
			matrix = matrix * pInvMatrix;
			//printMatrix(matrix);
		}
	}
	if(time == DEBUG_TIME)
	{
		MFnIkJoint jn(j.jointDag);
		if(jn.name() == "L_knee")
		{
			char str[256];
			sprintf(str,"%5.5f,%5.5f,%5.5f,%5.5f\n%5.5f,%5.5f,%5.5f,%5.5f\n%5.5f,%5.5f,%5.5f,%5.5f\n%5.5f,%5.5f,%5.5f,%5.5f\n\n",
				matrix[0][0],matrix[0][1],matrix[0][2],matrix[0][3],
				matrix[1][0],matrix[1][1],matrix[1][2],matrix[1][3],
				matrix[2][0],matrix[2][1],matrix[2][2],matrix[2][3],
				matrix[3][0],matrix[3][1],matrix[3][2],matrix[3][3]);
			OutputDebugString(str);
//			breakable;
		}
	}
	{
		MMatrix matrix	= j.jointDag.inclusiveMatrix() * j.jointDag.exclusiveMatrixInverse();
		//printMatrix(matrix);
		MMatrix worldMatrix = j.localMatrix;
		//printMatrix(worldMatrix);

		MMatrix invWorldMatrix = worldMatrix.inverse();
		matrix = matrix * invWorldMatrix;
		if(j.parentIndex >= 0)
		{
			matrix = matrix * m_joints[j.parentIndex].localMatrix;
		}
		//printMatrix(matrix);
	}

	extractTranMatrix(matrix,translation.v,rotation.q,scale.v);
	if(time >= DEBUG_TIME)
	{
		MFnIkJoint jn(j.jointDag);
		if(jn.name() == "L_leg")
		{
			char str[256];
			sprintf(str,"%5.5f,%5.5f,%5.5f\n\n",translation.v[0],translation.v[1],translation.v[2]);
			OutputDebugString(str);
			sprintf(str,"%5.5f,%5.5f,%5.5f,%5.5f\n\n",rotation.q[0],rotation.q[1],rotation.q[2],rotation.q[3]);
			OutputDebugString(str);
			sprintf(str,"%5.5f,%5.5f,%5.5f\n\n",scale.v[0],scale.v[1],scale.v[2]);
			OutputDebugString(str);

			/*D3DXMATRIX d3dM(matrix[0][0],matrix[0][1],matrix[0][2],matrix[0][3],
				matrix[1][0],matrix[1][1],matrix[1][2],matrix[1][3],
				matrix[2][0],matrix[2][1],matrix[2][2],matrix[2][3],
				matrix[3][0],matrix[3][1],matrix[3][2],matrix[3][3]);

			D3DXVECTOR3 d3dS,d3dT;
			D3DXQUATERNION d3dQ;
			HRESULT hr = D3DXMatrixDecompose(&d3dS,&d3dQ,&d3dT,&d3dM);
			hr = hr;*/

			//rotation.q[0] = -rotation.q[0];
			//rotation.q[1] = -rotation.q[1];
			//rotation.q[2] = -rotation.q[2];
			//rotation.q[3] = -rotation.q[3];
		}
	}

	/*D3DXQUATERNION q1 = D3DXQUATERNION(0.14122,0.09228,-0.82219,0.54365);
	D3DXQUATERNION q2 = D3DXQUATERNION(-0.13556,-0.09684,0.85495,-0.49124);
	D3DXQUATERNION q3;
	D3DXQuaternionSlerp(&q3,&q1,&q2,1-0.63636363);*/
	translation.time = time;
	rotation.time = time;
	scale.time = time;
}
示例#21
0
double besjn_ (const integer *n, real *x) {
    return jn (*n, *x);
}
__device__ void double_precision_math_functions() {
    int iX;
    double fX, fY;

    acos(1.0);
    acosh(1.0);
    asin(0.0);
    asinh(0.0);
    atan(0.0);
    atan2(0.0, 1.0);
    atanh(0.0);
    cbrt(0.0);
    ceil(0.0);
    copysign(1.0, -2.0);
    cos(0.0);
    cosh(0.0);
    cospi(0.0);
    cyl_bessel_i0(0.0);
    cyl_bessel_i1(0.0);
    erf(0.0);
    erfc(0.0);
    erfcinv(2.0);
    erfcx(0.0);
    erfinv(1.0);
    exp(0.0);
    exp10(0.0);
    exp2(0.0);
    expm1(0.0);
    fabs(1.0);
    fdim(1.0, 0.0);
    floor(0.0);
    fma(1.0, 2.0, 3.0);
    fmax(0.0, 0.0);
    fmin(0.0, 0.0);
    fmod(0.0, 1.0);
    frexp(0.0, &iX);
    hypot(1.0, 0.0);
    ilogb(1.0);
    isfinite(0.0);
    isinf(0.0);
    isnan(0.0);
    j0(0.0);
    j1(0.0);
    jn(-1.0, 1.0);
    ldexp(0.0, 0);
    lgamma(1.0);
    llrint(0.0);
    llround(0.0);
    log(1.0);
    log10(1.0);
    log1p(-1.0);
    log2(1.0);
    logb(1.0);
    lrint(0.0);
    lround(0.0);
    modf(0.0, &fX);
    nan("1");
    nearbyint(0.0);
    nextafter(0.0, 0.0);
    fX = 1.0;
    norm(1, &fX);
    norm3d(1.0, 0.0, 0.0);
    norm4d(1.0, 0.0, 0.0, 0.0);
    normcdf(0.0);
    normcdfinv(1.0);
    pow(1.0, 0.0);
    rcbrt(1.0);
    remainder(2.0, 1.0);
    remquo(1.0, 2.0, &iX);
    rhypot(0.0, 1.0);
    rint(1.0);
    fX = 1.0;
    rnorm(1, &fX);
    rnorm3d(0.0, 0.0, 1.0);
    rnorm4d(0.0, 0.0, 0.0, 1.0);
    round(0.0);
    rsqrt(1.0);
    scalbln(0.0, 1);
    scalbn(0.0, 1);
    signbit(1.0);
    sin(0.0);
    sincos(0.0, &fX, &fY);
    sincospi(0.0, &fX, &fY);
    sinh(0.0);
    sinpi(0.0);
    sqrt(0.0);
    tan(0.0);
    tanh(0.0);
    tgamma(2.0);
    trunc(0.0);
    y0(1.0);
    y1(1.0);
    yn(1, 1.0);
}
示例#23
0
double dbesjn_ (const integer *n, double *x) {
    return jn (*n, *x);
}
void
domath  (void)
{
#ifndef NO_DOUBLE
  double f1;
  double f2;

  int i1;

  f1 = acos (0.0);
  fprintf( stdout, "acos           : %f\n", f1);

  f1 = acosh (0.0);
  fprintf( stdout, "acosh          : %f\n", f1);

  f1 = asin (1.0);
  fprintf( stdout, "asin           : %f\n", f1);

  f1 = asinh (1.0);
  fprintf( stdout, "asinh          : %f\n", f1);

  f1 = atan (M_PI_4);
  fprintf( stdout, "atan           : %f\n", f1);

  f1 = atan2 (2.3, 2.3);
  fprintf( stdout, "atan2          : %f\n", f1);

  f1 = atanh (1.0);
  fprintf( stdout, "atanh          : %f\n", f1);

  f1 = cbrt (27.0);
  fprintf( stdout, "cbrt           : %f\n", f1);

  f1 = ceil (3.5);
  fprintf( stdout, "ceil           : %f\n", f1);

  f1 = copysign (3.5, -2.5);
  fprintf( stdout, "copysign       : %f\n", f1);

  f1 = cos (M_PI_2);
  fprintf( stdout, "cos            : %f\n", f1);

  f1 = cosh (M_PI_2);
  fprintf( stdout, "cosh           : %f\n", f1);

  f1 = erf (42.0);
  fprintf( stdout, "erf            : %f\n", f1);

  f1 = erfc (42.0);
  fprintf( stdout, "erfc           : %f\n", f1);

  f1 = exp (0.42);
  fprintf( stdout, "exp            : %f\n", f1);

  f1 = exp2 (0.42);
  fprintf( stdout, "exp2           : %f\n", f1);

  f1 = expm1 (0.00042);
  fprintf( stdout, "expm1          : %f\n", f1);

  f1 = fabs (-1.123);
  fprintf( stdout, "fabs           : %f\n", f1);

  f1 = fdim (1.123, 2.123);
  fprintf( stdout, "fdim           : %f\n", f1);

  f1 = floor (0.5);
  fprintf( stdout, "floor          : %f\n", f1);
  f1 = floor (-0.5);
  fprintf( stdout, "floor          : %f\n", f1);

  f1 = fma (2.1, 2.2, 3.01);
  fprintf( stdout, "fma            : %f\n", f1);

  f1 = fmax (-0.42, 0.42);
  fprintf( stdout, "fmax           : %f\n", f1);

  f1 = fmin (-0.42, 0.42);
  fprintf( stdout, "fmin           : %f\n", f1);

  f1 = fmod (42.0, 3.0);
  fprintf( stdout, "fmod           : %f\n", f1);

  /* no type-specific variant */
  i1 = fpclassify(1.0);
  fprintf( stdout, "fpclassify     : %d\n", i1);

  f1 = frexp (42.0, &i1);
  fprintf( stdout, "frexp          : %f\n", f1);

  f1 = hypot (42.0, 42.0);
  fprintf( stdout, "hypot          : %f\n", f1);

  i1 = ilogb (42.0);
  fprintf( stdout, "ilogb          : %d\n", i1);

  /* no type-specific variant */
  i1 = isfinite(3.0);
  fprintf( stdout, "isfinite       : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreater(3.0, 3.1);
  fprintf( stdout, "isgreater      : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreaterequal(3.0, 3.1);
  fprintf( stdout, "isgreaterequal : %d\n", i1);

  /* no type-specific variant */
  i1 = isinf(3.0);
  fprintf( stdout, "isinf          : %d\n", i1);

  /* no type-specific variant */
  i1 = isless(3.0, 3.1);
  fprintf( stdout, "isless         : %d\n", i1);

  /* no type-specific variant */
  i1 = islessequal(3.0, 3.1);
  fprintf( stdout, "islessequal    : %d\n", i1);

  /* no type-specific variant */
  i1 = islessgreater(3.0, 3.1);
  fprintf( stdout, "islessgreater  : %d\n", i1);

  /* no type-specific variant */
  i1 = isnan(0.0);
  fprintf( stdout, "isnan          : %d\n", i1);

  /* no type-specific variant */
  i1 = isnormal(3.0);
  fprintf( stdout, "isnormal       : %d\n", i1);

  /* no type-specific variant */
  f1 = isunordered(1.0, 2.0);
  fprintf( stdout, "isunordered    : %d\n", i1);

  f1 = j0 (1.2);
  fprintf( stdout, "j0             : %f\n", f1);

  f1 = j1 (1.2);
  fprintf( stdout, "j1             : %f\n", f1);

  f1 = jn (2,1.2);
  fprintf( stdout, "jn             : %f\n", f1);

  f1 = ldexp (1.2,3);
  fprintf( stdout, "ldexp          : %f\n", f1);

  f1 = lgamma (42.0);
  fprintf( stdout, "lgamma         : %f\n", f1);

  f1 = llrint (-0.5);
  fprintf( stdout, "llrint         : %f\n", f1);
  f1 = llrint (0.5);
  fprintf( stdout, "llrint         : %f\n", f1);

  f1 = llround (-0.5);
  fprintf( stdout, "lround         : %f\n", f1);
  f1 = llround (0.5);
  fprintf( stdout, "lround         : %f\n", f1);

  f1 = log (42.0);
  fprintf( stdout, "log            : %f\n", f1);

  f1 = log10 (42.0);
  fprintf( stdout, "log10          : %f\n", f1);

  f1 = log1p (42.0);
  fprintf( stdout, "log1p          : %f\n", f1);

  f1 = log2 (42.0);
  fprintf( stdout, "log2           : %f\n", f1);

  f1 = logb (42.0);
  fprintf( stdout, "logb           : %f\n", f1);

  f1 = lrint (-0.5);
  fprintf( stdout, "lrint          : %f\n", f1);
  f1 = lrint (0.5);
  fprintf( stdout, "lrint          : %f\n", f1);

  f1 = lround (-0.5);
  fprintf( stdout, "lround         : %f\n", f1);
  f1 = lround (0.5);
  fprintf( stdout, "lround         : %f\n", f1);

  f1 = modf (42.0,&f2);
  fprintf( stdout, "lmodf          : %f\n", f1);

  f1 = nan ("");
  fprintf( stdout, "nan            : %f\n", f1);

  f1 = nearbyint (1.5);
  fprintf( stdout, "nearbyint      : %f\n", f1);

  f1 = nextafter (1.5,2.0);
  fprintf( stdout, "nextafter      : %f\n", f1);

  f1 = pow (3.01, 2.0);
  fprintf( stdout, "pow            : %f\n", f1);

  f1 = remainder (3.01,2.0);
  fprintf( stdout, "remainder      : %f\n", f1);

  f1 = remquo (29.0,3.0,&i1);
  fprintf( stdout, "remquo         : %f\n", f1);

  f1 = rint (0.5);
  fprintf( stdout, "rint           : %f\n", f1);
  f1 = rint (-0.5);
  fprintf( stdout, "rint           : %f\n", f1);

  f1 = round (0.5);
  fprintf( stdout, "round          : %f\n", f1);
  f1 = round (-0.5);
  fprintf( stdout, "round          : %f\n", f1);

  f1 = scalbln (1.2,3);
  fprintf( stdout, "scalbln        : %f\n", f1);

  f1 = scalbn (1.2,3);
  fprintf( stdout, "scalbn         : %f\n", f1);

  /* no type-specific variant */
  i1 = signbit(1.0);
  fprintf( stdout, "signbit        : %i\n", i1);

  f1 = sin (M_PI_4);
  fprintf( stdout, "sin            : %f\n", f1);

  f1 = sinh (M_PI_4);
  fprintf( stdout, "sinh           : %f\n", f1);

  f1 = sqrt (9.0);
  fprintf( stdout, "sqrt           : %f\n", f1);

  f1 = tan (M_PI_4);
  fprintf( stdout, "tan            : %f\n", f1);

  f1 = tanh (M_PI_4);
  fprintf( stdout, "tanh           : %f\n", f1);

  f1 = tgamma (2.1);
  fprintf( stdout, "tgamma         : %f\n", f1);

  f1 = trunc (3.5);
  fprintf( stdout, "trunc          : %f\n", f1);

  f1 = y0 (1.2);
  fprintf( stdout, "y0             : %f\n", f1);

  f1 = y1 (1.2);
  fprintf( stdout, "y1             : %f\n", f1);

  f1 = yn (3,1.2);
  fprintf( stdout, "yn             : %f\n", f1);
#endif
}
示例#25
0
ULONG MathFunc(CHAR *name, ULONG numargs, RXSTRING args[],
                        CHAR *queuename, RXSTRING *retstr)
{
	double x, y, result;
	int i, fn_id = -1;

#ifdef ENABLE_CACHE
   if (RxMathFncCache.id >= 0)
      fn_id = cache_func(name, numargs);

   if (fn_id < 0)
   {
   	fn_id = resolve_func(name, numargs);
	   if (fn_id < 0)           
		   return INVALID_ROUTINE;
   }
#else
  	fn_id = resolve_func(name, numargs);
   if (fn_id < 0)           
	   return INVALID_ROUTINE;
#endif

	x = atof(args[0].strptr);
	if (numargs > 1L)
	{
		y = atof(args[1].strptr);
		i = atoi(args[1].strptr);
	}

	switch (fn_id)
	{
	case fn_acos:
		result = acos(x);
		break;
	case fn_asin: 
		result = asin(x);
		break;
	case fn_atan: 
		result = atan(x);
		break;
	case fn_atan2:
		result = atan2(x, y);
		break;
	case fn_ceil: 
		result = ceil(x);
		break;
	case fn_cos:  
		result = cos(x);
		break;
	case fn_cosh: 
		result = cosh(x);
		break;
	case fn_exp:  
		result = exp(x);
		break;
	case fn_fabs: 
		result = fabs(x);
		break;
	case fn_floor:
		result = floor(x);
		break;
	case fn_fmod: 
		result = fmod(x, y);
		break;
	case fn_frexp:
		result = frexp(x, &i);
		break;
	case fn_ldexp:
		result = ldexp(x, i);
		break;
	case fn_log:  
		result = log(x);
		break;
	case fn_log10:
		result = log10(x);
		break;
	case fn_modf: 
		result = modf(x, &y);
		break;
	case fn_pow:  
		result = pow(x, y);
		break;
	case fn_sin:  
		result = sin(x);
		break;
	case fn_sinh: 
		result = sinh(x);
		break;
	case fn_sqrt: 
		result = sqrt(x);
		break;
	case fn_tan: 
		result = tan(x);
		break;
	case fn_tanh:
		result = tanh(x);
		break;
#ifdef __IBMC__
	case fn_erf:
      result = erf( x );
		break;
	case fn_erfc:  
      result = erfc( x );
		break;
	case fn_gamma: 
      result = gamma( x );
		break;
#endif
	case fn_hypot: 
      result = hypot( x, y );
		break;
	case fn_j0:    
      result = j0( x );
		break;
	case fn_j1:    
      result = j1( x );
		break;
	case fn_jn:    
      result = jn( i, x );
		break;
	case fn_y0:    
      result = y0( x );
		break;
	case fn_y1:    
      result = y1( x );
		break;
	case fn_yn:    
      result = yn( i, x );
		break;
	case fn_pi:    
      result = 3.1415926575;
		break;
   default:
	   return INVALID_ROUTINE;
	}

	switch (fn_id)
	{
	case fn_frexp:
		sprintf(retstr->strptr, "%lf %i", result, i);
		break;
	case fn_modf: 
		sprintf(retstr->strptr, "%lf %lf", result, y);
		break;
	default:
		sprintf(retstr->strptr, "%lf", result);
		break;
	}

	retstr->strlength = strlen(retstr->strptr);
	return VALID_ROUTINE;
}
complex<double> BesselState::bessel_state1D(double x) {
    return normalization * exp(complex<double>(0., phase)) * complex<double> (jn(int(angular_momentum), x * zero / grid->length_x), 0.);
}
float
jnf (int n, float x)
{
  return (float) jn (n, (double) x);
}
示例#28
0
TEST(math, jn) {
  ASSERT_FLOAT_EQ(0.0, jn(4, 0.0));
  ASSERT_FLOAT_EQ(0.0024766389, jn(4, 1.0));
}