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


C++ sincos函数代码示例

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


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

示例1: GetSphericalBearingFinal

  /**
   * Taken the path from A to B over a sphere return the bearing (0..2PI) at the destination point B.
   */
  double GetSphericalBearingFinal(double aLon, double aLat,
                                  double bLon, double bLat)
  {
    aLon=aLon*M_PI/180;
    aLat=aLat*M_PI/180;

    bLon=bLon*M_PI/180;
    bLat=bLat*M_PI/180;

    double dLon=aLon-bLon;

    double sindLon, sinaLat, sinbLat;
    double cosdLon, cosaLat, cosbLat;
    sincos(dLon, sindLon, cosdLon);
    sincos(aLat, sinaLat, cosaLat);
    sincos(bLat, sinbLat, cosbLat);

    double y=sindLon*cosaLat;
    double x=cosbLat*sinaLat-sinbLat*cosaLat*cosdLon;

    double bearing=atan2(y,x);

    if (bearing>=0) {
      bearing-=M_PI;
    }
    else {
      bearing+=M_PI;
    }

    //double bearing=fmod(atan2(y,x)+3*M_PI,2*M_PI);

    return bearing;
  }
开发者ID:hjanetzek,项目名称:libosmscout-exp,代码行数:36,代码来源:Geometry.cpp

示例2: p_sincos

int
p_sincos(value val_arg, type tag_arg,
	value val_sin, type tag_sin,
	value val_cos, type tag_cos)
{
        extern void sincos();       /* from the math library */
        double s, c;
        Prepare_Requests;

        Error_If_Ref(tag_arg);
        Check_Output_Float(tag_sin);
        Check_Output_Float(tag_cos);

        if (IsDouble(tag_arg))
            sincos(Dbl(val_arg), &s, &c);
        else if (IsInteger(tag_arg))
            sincos((double) val_arg.nint, &s, &c);
        else
        {
            Error(TYPE_ERROR);
        }
        Request_Unify_Float(val_sin, tag_sin, s);
        Request_Unify_Float(val_cos, tag_cos, c);
        Return_Unify;
}
开发者ID:CoryXie,项目名称:BarrelfishOS,代码行数:25,代码来源:manual_examples.c

示例3: e_inverse

static LP e_inverse (XY xy, PJ *P) {          /* Ellipsoidal, inverse */
    LP lp = {0.0,0.0};
    struct pj_opaque *Q = P->opaque;
    double sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe;
    double Cn = xy.y, Ce = xy.x;

    /* normalize N, E */
    Cn = (Cn - Q->Zb)/Q->Qn;
    Ce = Ce/Q->Qn;

    if (fabs(Ce) <= 2.623395162778) { /* 150 degrees */
        /* norm. N, E -> compl. sph. LAT, LNG */
        Cn += clenS(Q->utg, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe);
        Ce += dCe;
        Ce = atan (sinh (Ce)); /* Replaces: Ce = 2*(atan(exp(Ce)) - FORTPI); */
        /* compl. sph. LAT -> Gaussian LAT, LNG */
#ifdef _GNU_SOURCE
        sincos (Cn, &sin_Cn, &cos_Cn);
        sincos (Ce, &sin_Ce, &cos_Ce);
#else
        sin_Cn = sin (Cn);
        cos_Cn = cos (Cn);
        sin_Ce = sin (Ce);
        cos_Ce = cos (Ce);
#endif
        Ce     = atan2 (sin_Ce, cos_Ce*cos_Cn);
        Cn     = atan2 (sin_Cn*cos_Ce,  hypot (sin_Ce, cos_Ce*cos_Cn));
        /* Gaussian LAT, LNG -> ell. LAT, LNG */
        lp.phi = gatg (Q->cgb,  PROJ_ETMERC_ORDER, Cn);
        lp.lam = Ce;
    }
    else
        lp.phi = lp.lam = HUGE_VAL;
    return lp;
}
开发者ID:Kitware,项目名称:VTK,代码行数:35,代码来源:proj_etmerc.c

示例4: make_proj_mat

// This might be a convenient function to use in fgcalc, rather than repeating the same code six times
int make_proj_mat(float phi, float theta, float psi, float * dm)
{
//     float cphi=cos(phi);
//     float sphi=sin(phi);
//     float cthe=cos(theta);
//     float sthe=sin(theta);
//     float cpsi=cos(psi);
//     float spsi=sin(psi);

    double cphi, sphi, cthe, sthe, cpsi, spsi;
    double dphi = phi;
    double dthe = theta;
    double dpsi = psi;
    sincos(dphi, &sphi, &cphi);
    sincos(dthe, &sthe, &cthe);
    sincos(dpsi, &spsi, &cpsi);

    dm[0]=cphi*cthe*cpsi-sphi*spsi;
    dm[1]=sphi*cthe*cpsi+cphi*spsi;
    dm[2]=-sthe*cpsi;
    dm[3]=-cphi*cthe*spsi-sphi*cpsi;
    dm[4]=-sphi*cthe*spsi+cphi*cpsi;
    dm[5]=sthe*spsi;

    return 0;
}
开发者ID:C-CINA,项目名称:2dx,代码行数:27,代码来源:project3d.cpp

示例5: small_circle_lambda_by_phi

int small_circle_lambda_by_phi(double phi0, double lambda0, double d, double phi, double * p) {

    double sin_phi0, cos_phi0;
    double sin_phi, cos_phi;
    double cos_mult, cos_div;

    sincos(phi0, &sin_phi0, &cos_phi0);
    sincos(phi, &sin_phi, &cos_phi);

    cos_mult = cos_phi0 * cos_phi;
    if (cos_mult == 0.0) {
        return 0;
    }

    cos_div = (cos(d) - sin_phi0 * sin_phi) / cos_mult;
    if (cos_div == -1.0 || cos_div == 1.0) {
        *p = 0.0;
        return 1;
    }
    if (cos_div < -1.0 || cos_div > 1.0) {
        return 0;
    }

    *p = acos(cos_div);
    return 1;

}
开发者ID:keynslug,项目名称:erstar,代码行数:27,代码来源:erstar_geo_math.c

示例6: e_forward

static XY e_forward (LP lp, PJ *P) {          /* Ellipsoidal, forward */
    XY xy = {0.0,0.0};
    struct pj_opaque *Q = P->opaque;
    double sin_Cn, cos_Cn, cos_Ce, sin_Ce, dCn, dCe;
    double Cn = lp.phi, Ce = lp.lam;

    /* ell. LAT, LNG -> Gaussian LAT, LNG */
    Cn  = gatg (Q->cbg, PROJ_ETMERC_ORDER, Cn);
    /* Gaussian LAT, LNG -> compl. sph. LAT */
#ifdef _GNU_SOURCE
    sincos (Cn, &sin_Cn, &cos_Cn);
    sincos (Ce, &sin_Ce, &cos_Ce);
#else
    sin_Cn = sin (Cn);
    cos_Cn = cos (Cn);
    sin_Ce = sin (Ce);
    cos_Ce = cos (Ce);
#endif

    Cn     = atan2 (sin_Cn, cos_Ce*cos_Cn);
    Ce     = atan2 (sin_Ce*cos_Cn,  hypot (sin_Cn, cos_Cn*cos_Ce));

    /* compl. sph. N, E -> ell. norm. N, E */
    Ce  = asinhy ( tan (Ce) );     /* Replaces: Ce  = log(tan(FORTPI + Ce*0.5)); */
    Cn += clenS (Q->gtu, PROJ_ETMERC_ORDER, 2*Cn, 2*Ce, &dCn, &dCe);
    Ce += dCe;
    if (fabs (Ce) <= 2.623395162778) {
        xy.y  = Q->Qn * Cn + Q->Zb;  /* Northing */
        xy.x  = Q->Qn * Ce;          /* Easting  */
    } else
        xy.x = xy.y = HUGE_VAL;
    return xy;
}
开发者ID:Kitware,项目名称:VTK,代码行数:33,代码来源:proj_etmerc.c

示例7: small_circle_phi_by_lambda

int small_circle_phi_by_lambda(
    double phi0, double lambda0, double d, double lambda, double * phi1, double * phi2
) {

    double sin_phi0, cos_phi0;
    double d_lambda, sin_d_lambda, cos_d_lambda;
    double cos_mult, denom, phi, gamma, cos_div;

    d_lambda = lambda - lambda0;
    sincos(phi0, &sin_phi0, &cos_phi0);
    sincos(d_lambda, &sin_d_lambda, &cos_d_lambda);

    cos_mult = cos_phi0 * cos_d_lambda;
    denom = sqrt(sin_phi0 * sin_phi0 + cos_mult * cos_mult);
    if (denom == 0.0) {
        return 0;
    }

    cos_div = cos(d) / denom;
    if (cos_div < -1.0 || cos_div > 1.0) {
        return 0;
    }

    phi = asin(cos_div);
    gamma = acos(sin_phi0 / denom);
    *phi1 = phi - gamma;
    if (phi == M_PI_2) {
        return 0;
    }
    *phi2 = M_PI - phi - gamma;
    return 1;

}
开发者ID:keynslug,项目名称:erstar,代码行数:33,代码来源:erstar_geo_math.c

示例8: horizontal_to_equatorial

void horizontal_to_equatorial(double az_deg, double el_deg, time_t lst_s, double lat_deg,
                              double* ra_hours, double* dec_deg)
{
    double ha = 0.0;
    double dec = 0.0;

    double sa, ca, se, ce, sp, cp, x, y, z, r;

    sincos(from_degrees(az_deg), &sa, &ca);
    sincos(from_degrees(el_deg), &se, &ce);
    sincos(from_degrees(lat_deg), &sp, &cp);

    /* HA,Dec as x,y,z */
    x = -ca * ce * sp + se * cp;
    y = -sa * ce;
    z = ca * ce * cp + se * sp;

    /* To spherical */
    r = sqrt(x * x + y * y);
    ha = (r == 0.0) ? 0.0 : atan2(y, x);
    dec = atan2(z, r);

    *ra_hours = to_hours(from_seconds(lst_s) - ha);
    *ra_hours = wrap_to(*ra_hours, 24.0);
    *dec_deg = to_degrees(dec);
}
开发者ID:BlastTNG,项目名称:flight,代码行数:26,代码来源:angles.c

示例9: norm

void
norm(struct place *gg, struct place *pp, struct coord *tw)
{
	register struct place *g;	/*geographic coords */
	register struct place *p;	/* new pole in old coords*/
	struct place m;			/* standard map coords*/
	g = gg;
	p = pp;
	if(p->nlat.s == 1.) {
		if(p->wlon.l+tw->l == 0.)
			return;
		g->wlon.l -= p->wlon.l+tw->l;
	} else {
		if(p->wlon.l != 0) {
			g->wlon.l -= p->wlon.l;
			sincos(&g->wlon);
		}
		m.nlat.s = p->nlat.s * g->nlat.s
			+ p->nlat.c * g->nlat.c * g->wlon.c;
		m.nlat.c = sqrt(1. - m.nlat.s * m.nlat.s);
		m.nlat.l = atan2(m.nlat.s, m.nlat.c);
		m.wlon.s = g->nlat.c * g->wlon.s;
		m.wlon.c = p->nlat.c * g->nlat.s
			- p->nlat.s * g->nlat.c * g->wlon.c;
		m.wlon.l = atan2(m.wlon.s, - m.wlon.c)
			- tw->l;
		*g = m;
	}
	sincos(&g->wlon);
	if(g->wlon.l>PI)
		g->wlon.l -= 2*PI;
	else if(g->wlon.l<-PI)
		g->wlon.l += 2*PI;
}
开发者ID:aahud,项目名称:harvey,代码行数:34,代码来源:zcoord.c

示例10: azimuth

static int
azimuth(struct place *place)
{
	if(place->nlat.c < FUZZ) {
		az.l = PI/2 + place->nlat.l - place->wlon.l;
		sincos(&az);
		rad.l = fabs(place->nlat.l - p0.l);
		if(rad.l > PI)
			rad.l = 2*PI - rad.l;
		sincos(&rad);
		return 1;
	}
	rad.c = trigclamp(p0.s*place->nlat.s +	/* law of cosines */
		p0.c*place->nlat.c*place->wlon.c);
	rad.s = sqrt(1 - rad.c*rad.c);
	if(fabs(rad.s) < .001) {
		az.s = 0;
		az.c = 1;
	} else {
		az.s = trigclamp(p0.c*place->wlon.s/rad.s); /* sines */
		az.c = trigclamp((p0.s - rad.c*place->nlat.s)
				/(rad.s*place->nlat.c));
	}
	rad.l = atan2(rad.s, rad.c);
	return 1;
}
开发者ID:00001,项目名称:plan9port,代码行数:26,代码来源:homing.c

示例11: GetSphericalBearingInitial

  /**
   * Taken the path from A to B over a sphere return the bearing (0..2PI) at the starting point A.
   */
  double GetSphericalBearingInitial(double aLon, double aLat,
                                    double bLon, double bLat)
  {
    aLon=aLon*M_PI/180;
    aLat=aLat*M_PI/180;

    bLon=bLon*M_PI/180;
    bLat=bLat*M_PI/180;

    double dLon=bLon-aLon;

    double sindLon, sinaLat, sinbLat;
    double cosdLon, cosaLat, cosbLat;
    sincos(dLon, sindLon, cosdLon);
    sincos(aLat, sinaLat, cosaLat);
    sincos(bLat, sinbLat, cosbLat);

    double y=sindLon*cosbLat;
    double x=cosaLat*sinbLat-sinaLat*cosbLat*cosdLon;

    double bearing=atan2(y,x);
    //double bearing=fmod(atan2(y,x)+2*M_PI,2*M_PI);

    return bearing;
  }
开发者ID:hjanetzek,项目名称:libosmscout-exp,代码行数:28,代码来源:Geometry.cpp

示例12: gwsincos12by2_weighted

void gwsincos12by2_weighted (
	void	*dd_data_arg,
	unsigned long x,
	unsigned long upper_x,
	unsigned long N,
	unsigned long col,
	double	*results)
{
	dd_real twopi_over_N, sine, cosine, sine2, cosine2;
	dd_real temp, bpower, weight, inv_weight;

	x86_FIX
	temp = (double) col * dd_data->gw__num_b_per_word;
	bpower = gwceil (temp) - temp;
	if (! dd_data->gw__c_is_one) bpower += dd_data->gw__logb_abs_c_div_fftlen * (double) col;
	weight = exp (dd_data->gw__logb * bpower);
	inv_weight = dd_data->gw__over_fftlen / weight;

	twopi_over_N = dd_real::_2pi / (double) N;
	sincos (twopi_over_N * (double) x, sine, cosine);

	sine2 = sine * cosine * 2.0;
	cosine2 = sqr (cosine) - sqr (sine);

	sine = sine + epsilon;		// Hack to avoid divide-by-zero errors
	sine2 = sine2 + epsilon;

	results[0] = weight;
	results[2] = inv_weight;

	results[4] = sine * weight;
	results[6] = cosine / sine;
	results[8] = sine * inv_weight;

	results[10] = sine2 * weight;
	results[12] = cosine2 / sine2;
	results[14] = sine2 * inv_weight;

	sincos (twopi_over_N * (double) upper_x, sine, cosine);

	sine2 = sine * cosine * 2.0;
	cosine2 = sqr (cosine) - sqr (sine);

	sine = sine + epsilon;		// Hack to avoid divide-by-zero errors
	sine2 = sine2 + epsilon;

	results[1] = weight;
	results[3] = inv_weight;

	results[5] = sine * weight;
	results[7] = cosine / sine;
	results[9] = sine * inv_weight;

	results[11] = sine2 * weight;
	results[13] = cosine2 / sine2;
	results[15] = sine2 * inv_weight;
	END_x86_FIX
}
开发者ID:irukasti,项目名称:mprime,代码行数:58,代码来源:gwdbldbl.cpp

示例13: from_euler_angles

	static mat3 from_euler_angles(scalar_t x, scalar_t y, scalar_t z)
	{
		scalar_t cx, sx, cy, sy, cz, sz;
		sincos(x, sx, cx);
		sincos(y, sy, cy);
		sincos(z, sz, cz);
		return mat3(
			vec3(cy * cz, sy * sx - cy * sz * cx, cy * sz * sx + sy * cx),
			vec3(sz, cz * cx, -cz * sx),
			vec3(-sy * cz, sy * sz * cx + cy * sx, cy * cx - sy * sz * sx));
	}
开发者ID:redeemarr,项目名称:math,代码行数:11,代码来源:mat3.hpp

示例14: sincos

	quaternion<Real> quaternion<Real>::fromAnglesInertialToObject(Real pitch, Real bank, Real heading)
	{
		Real sp, sb, sh, cp, cb, ch;
		sincos(pitch, &sp, &cp);
		sincos(bank, &sb, &cb);
		sincos(heading, &sh, &ch);
		return quaternion<Real>(
			cp*cb*ch + sp*sb*sh,
			-ch*sp*cb - sh*cp*sb,
			ch*sp*sb - sh*cp*cb,
			sh*sp*cb - ch*cp*sb);
	}
开发者ID:habanero3d,项目名称:habanero3d-legacy,代码行数:12,代码来源:quaternion.cpp

示例15: sincos

//--------------------------------------------------------------------
//(BODY INVERSE KINEMATICS)
//BodyRotX         - Global Input pitch of the body
//BodyRotY         - Global Input rotation of the body
//BodyRotZ         - Global Input roll of the body
//RotationY         - Input Rotation for the gait
//posX            - Input position of the feet X
//posZ            - Input position of the feet Z
//SinB                  - Sin buffer for BodyRotX
//CosB               - Cos buffer for BodyRotX
//SinG                  - Sin buffer for BodyRotZ
//CosG               - Cos buffer for BodyRotZ
//lBodyX         - Output Position X of feet with Rotation
//lBodyY         - Output Position Y of feet with Rotation
//lBodyZ         - Output Position Z of feet with Rotation
void PhoenixCore::getBodyIK(u8 leg, s16 posX, s16 posZ, s16 posY, s16 RotationY, long *x, long *y, long *z)
{
    s16            sinA4;          //Sin buffer for BodyRotX calculations
    s16            cosA4;          //Cos buffer for BodyRotX calculations
    s16            sinB4;          //Sin buffer for BodyRotX calculations
    s16            cosB4;          //Cos buffer for BodyRotX calculations
    s16            sinG4;          //Sin buffer for BodyRotZ calculations
    s16            cosG4;          //Cos buffer for BodyRotZ calculations
    s16            CPR_X;          //Final X value for centerpoint of rotation
    s16            CPR_Y;          //Final Y value for centerpoint of rotation
    s16            CPR_Z;          //Final Z value for centerpoint of rotation

    //Calculating totals from center of the body to the feet
    CPR_X = (s16)pgm_read_word(&TBL_OFFSET_X[leg])+posX + mPtrCtrlState->c3dBodyRotOff.x;
    CPR_Y = posY + mPtrCtrlState->c3dBodyRotOff.y;         //Define centerpoint for rotation along the Y-axis
    CPR_Z = (s16)pgm_read_word(&TBL_OFFSET_Z[leg]) + posZ + mPtrCtrlState->c3dBodyRotOff.z;

    //Successive global rotation matrix:
    //Math shorts for rotation: Alfa [A] = Xrotate, Beta [B] = Zrotate, Gamma [G] = Yrotate
    //Sinus Alfa = SinA, cosinus Alfa = cosA. and so on...

    //First calculate sinus and cosinus for each rotation:
    sincos(mPtrCtrlState->c3dBodyRot.x+mTotalXBal1, &sinG4, &cosG4);
    sincos(mPtrCtrlState->c3dBodyRot.z+mTotalZBal1, &sinB4, &cosB4);

    if (mBoolUpsideDown)
        sincos(-mPtrCtrlState->c3dBodyRot.y + (-RotationY * DEC_EXP_1) + mTotalYBal1, &sinA4, &cosA4) ;
    else
        sincos(mPtrCtrlState->c3dBodyRot.y + (RotationY * DEC_EXP_1) + mTotalYBal1, &sinA4, &cosA4) ;

    //Calcualtion of rotation matrix:
    *x = ((long)CPR_X*DEC_EXP_2 -
            ((long)CPR_X*DEC_EXP_2*cosA4/DEC_EXP_4*cosB4/DEC_EXP_4 -
             (long)CPR_Z*DEC_EXP_2*cosB4/DEC_EXP_4*sinA4/DEC_EXP_4 +
             (long)CPR_Y*DEC_EXP_2*sinB4/DEC_EXP_4)) / DEC_EXP_2;

    *z = ((long)CPR_Z*DEC_EXP_2 -
            ( (long)CPR_X*DEC_EXP_2*cosG4/DEC_EXP_4*sinA4/DEC_EXP_4 +
              (long)CPR_X*DEC_EXP_2*cosA4/DEC_EXP_4*sinB4/DEC_EXP_4*sinG4/DEC_EXP_4 +
              (long)CPR_Z*DEC_EXP_2*cosA4/DEC_EXP_4*cosG4/DEC_EXP_4 -
              (long)CPR_Z*DEC_EXP_2*sinA4/DEC_EXP_4*sinB4/DEC_EXP_4*sinG4/DEC_EXP_4 -
              (long)CPR_Y*DEC_EXP_2*cosB4/DEC_EXP_4*sinG4/DEC_EXP_4 )) / DEC_EXP_2;

    *y = ((long)CPR_Y  *DEC_EXP_2 -
            ( (long)CPR_X*DEC_EXP_2*sinA4/DEC_EXP_4*sinG4/DEC_EXP_4 -
              (long)CPR_X*DEC_EXP_2*cosA4/DEC_EXP_4*cosG4/DEC_EXP_4*sinB4/DEC_EXP_4 +
              (long)CPR_Z*DEC_EXP_2*cosA4/DEC_EXP_4*sinG4/DEC_EXP_4 +
              (long)CPR_Z*DEC_EXP_2*cosG4/DEC_EXP_4*sinA4/DEC_EXP_4*sinB4/DEC_EXP_4 +
              (long)CPR_Y*DEC_EXP_2*cosB4/DEC_EXP_4*cosG4/DEC_EXP_4 )) / DEC_EXP_2;
}
开发者ID:PingguSoft,项目名称:HexaPodMega,代码行数:65,代码来源:PhoenixCore.cpp


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