本文整理汇总了C++中cosd函数的典型用法代码示例。如果您正苦于以下问题:C++ cosd函数的具体用法?C++ cosd怎么用?C++ cosd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cosd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SunRightAscensionRad
/* p. 165, 25.6 */
double SunRightAscensionRad( double centuryTime)
{
double omegaRad = OmegaRad(centuryTime);
double oc = ObliquityCorrectionEx( centuryTime, omegaRad);
double al = ApparentLongitudeSunEx( centuryTime, omegaRad);
return atan2(cosd(oc) * sind(al), cosd(al));
}
示例2: astro_sunpos
static void astro_sunpos(double d, double *lon, double *r)
{
double M, /* Mean anomaly of the Sun */
w, /* Mean longitude of perihelion */
/* Note: Sun's mean longitude = M + w */
e, /* Eccentricity of Earth's orbit */
E, /* Eccentric anomaly */
x, y, /* x, y coordinates in orbit */
v; /* True anomaly */
/* Compute mean elements */
M = astro_revolution(356.0470 + 0.9856002585 * d);
w = 282.9404 + 4.70935E-5 * d;
e = 0.016709 - 1.151E-9 * d;
/* Compute true longitude and radius vector */
E = M + e * RADEG * sind(M) * (1.0 + e * cosd(M));
x = cosd(E) - e;
y = sqrt(1.0 - e*e) * sind(E);
*r = sqrt(x*x + y*y); /* Solar distance */
v = atan2d(y, x); /* True anomaly */
*lon = v + w; /* True solar longitude */
if (*lon >= 360.0) {
*lon -= 360.0; /* Make it 0..360 degrees */
}
}
示例3: sunpos
void sunpos( double d, double *lon, double *r )
/******************************************************/
/* Computes the Sun's ecliptic longitude and distance */
/* at an instant given in d, number of days since */
/* 2000 Jan 0.0. The Sun's ecliptic latitude is not */
/* computed, since it's always very near 0. */
/******************************************************/
{
double M, /* Mean anomaly of the Sun */
w, /* Mean longitude of perihelion */
/* Note: Sun's mean longitude = M + w */
e, /* Eccentricity of Earth's orbit */
E, /* Eccentric anomaly */
x, y, /* x, y coordinates in orbit */
v; /* True anomaly */
/* Compute mean elements */
M = revolution( 356.0470 + 0.9856002585 * d );
w = 282.9404 + 4.70935E-5 * d;
e = 0.016709 - 1.151E-9 * d;
/* Compute true longitude and radius vector */
E = M + e * RADEG * sind(M) * ( 1.0 + e * cosd(M) );
x = cosd(E) - e;
y = sqrt( 1.0 - e*e ) * sind(E);
*r = sqrt( x*x + y*y ); /* Solar distance */
v = atan2d( y, x ); /* True anomaly */
*lon = v + w; /* True solar longitude */
if ( *lon >= 360.0 )
*lon -= 360.0; /* Make it 0..360 degrees */
}
示例4: rotate_z
void rotate_z(vector *v,double theta)
{
double xNew,yNew;
xNew = v->x*cosd(theta)+v->y*sind(theta);
yNew = -v->x*sind(theta)+v->y*cosd(theta);
v->x = xNew; v->y = yNew;
}
示例5: rotate_y
void rotate_y(vector *v,double theta)
{
double xNew,zNew;
zNew = v->z*cosd(theta)+v->x*sind(theta);
xNew = -v->z*sind(theta)+v->x*cosd(theta);
v->x = xNew; v->z = zNew;
}
示例6: set_proj
/* -------------------------------------------------------------------------- */
void set_proj()
{
double psx;
double cell;
double cell2;
double r;
double phictr;
dddd = cntrj0 * pj.cds;
sign = (pj.cenlat >= 0.0) ? 1.0 : -1.0;
xn = 0.0;
psi1 = 0.0;
pole = sign*90.0;
psi0 = (pole - pj.cenlat) * DEG_TO_RAD;
if (pj.code == LAMBERT)
{
xn = log10(cosd(pj.stdlat1)) - log10(cosd(pj.stdlat2));
xn = xn/(log10(tand(45.0-sign*pj.stdlat1*0.50)) -
log10(tand(45.0-sign*pj.stdlat2*0.50)));
psi1 = (90.0-sign*pj.stdlat1) * DEG_TO_RAD;
psi1 = sign*psi1;
}
else if (pj.code == POLAR)
{
xn = 1.0;
psi1 = (90.0-sign*pj.stdlat1) * DEG_TO_RAD;
psi1 = sign*psi1;
}
if (pj.code != MERCATOR)
{
psx = (pole-pj.cenlat) * DEG_TO_RAD;
if (pj.code == LAMBERT)
{
cell = RADIUS_EARTH*sin(psi1)/xn;
cell2 = tan(psx*0.50) / tan(psi1*0.50);
}
else
{
cell = RADIUS_EARTH*sin(psx)/xn;
cell2 = (1.0 + cos(psi1))/(1.0 + cos(psx));
}
r = cell*pow(cell2,xn);
xcntr = 0.0;
ycntr = -r;
xc = 0.0;
yc = -RADIUS_EARTH/xn*sin(psi1)*pow(tan(psi0*0.5)/tan(psi1*0.5),xn);
}
else {
c2 = RADIUS_EARTH*cos(psi1);
xcntr = 0.0;
phictr = pj.cenlat * DEG_TO_RAD;
cell = cos(phictr)/(1.0+sin(phictr));
ycntr = -c2*log(cell);
xc = xcntr;
yc = ycntr;
}
return;
}
示例7: fldpnt
void fldpnt(double rrho,double rlat,double rlon,double ral,
double rel,double r,double *frho,double *flat,
double *flon) {
double rx,ry,rz,sx,sy,sz,tx,ty,tz;
double sinteta;
/* convert from global spherical to global cartesian*/
sinteta=sind(90.0-rlat);
rx=rrho*sinteta*cosd(rlon);
ry=rrho*sinteta*sind(rlon);
rz=rrho*cosd(90.0-rlat);
sx=-r*cosd(rel)*cosd(ral);
sy=r*cosd(rel)*sind(ral);
sz=r*sind(rel);
tx = cosd(90.0-rlat)*sx + sind(90.0-rlat)*sz;
ty = sy;
tz = -sind(90.0-rlat)*sx + cosd(90.0-rlat)*sz;
sx = cosd(rlon)*tx - sind(rlon)*ty;
sy = sind(rlon)*tx + cosd(rlon)*ty;
sz = tz;
tx=rx+sx;
ty=ry+sy;
tz=rz+sz;
/* convert from cartesian back to global spherical*/
*frho=sqrt((tx*tx)+(ty*ty)+(tz*tz));
*flat=90.0-acosd(tz/(*frho));
if ((tx==0) && (ty==0)) *flon=0;
else *flon=atan2d(ty,tx);
}
示例8: ikine
// Input x, y ,z and the angle vector
bool ikine(vector<double> *coords, vector<double> *angles, int grip) {
//cout << endl << "Andy Ikine says, hello world" << endl << endl;
double x = coords->at(0);
double y = coords->at(1);
double z = coords->at(2) - L1;
// calculate the closes reach
double reach_limit = L1*cosd(90) + L2*cosd(90 + (asin((-L1*sind(90))/L2) * 180 / M_PI) );
//cout << "Min reach: " << reach_limit << endl;
// Note that the dynamixel and rotate 150(degree) from origin
double magnitude = sqrt( pow(x,2) + pow(y,2) + pow(z,2) );
#if DEBUG
cerr << "Resultant Vector: " << magnitude << endl;
#endif
if ( magnitude > (L2 + L3) ) {
cerr << "Out of reach" << endl;
//return false;
}
// (horizontal, vertical) theta A
angles->at(0) = atan2(x,y);
// converted hypotenuse as the new y value
y = y / cos(angles->at(0));
// equation from the online source
double temp1 = (pow(y,2) + pow(z,2) - pow(L2,2) - pow(L3,2)) / (2 * L2 * L3);
double temp2 = -sqrt( 1 - pow(temp1, 2) );
// theta C
angles->at(2) = atan2( temp2, temp1);
double k1 = L2 + L3 * cos(angles->at(2));
double k2 = L3 * sin(angles->at(2));
// theta B
angles->at(1) = atan2( z, y ) - atan2( k2, k1 );
angles->at(2) += M_PI / 2 - M_PI / 6;
angles->at(1) -= M_PI / 2;
// open : close
angles->at(3) = grip ? 1.3 : -1.4;//(-GRIP_ANGLE / 180.0 * M_PI) ;
//print_values(angles);
return check_angle_range(angles);
}
示例9: iterate
void iterate(int value)
{
int j, k;
// ITERATIONS_PER_SEC is used to divide
const double ITERATIONS_PER_SEC = 1000.0 / value;
// call this function again in value milliseconds
glutTimerFunc(value, iterate, value);
// detect and resolve collisions
// note: for simplicity, we assume that there are only 2 robots in the ring
for(j = 1; j < robots_size; j++)
{
for(k = 0; k < j; k++)
{
double avg_width = (robots[j].width + robots[k].width) / 2.0;
// if there's a collision between robots[j] and robots[k]
if(magnitude(robots[j].pos.x - robots[k].pos.x, robots[j].pos.y - robots[k].pos.y) < avg_width)
{
point_t robot_j_corner;
double half_j_width = robots[j].width / 2.0;
robot_j_corner = offset_from_robot(&robots[j], half_j_width, half_j_width);
if(point_in_robot(&robots[k], &robot_j_corner))
{
// place code to figure out where the robots hit, now that we know there's a collision
}
}
}
}
// update robots positions and angle (with the velocity and angular velocity)
for(j = 0; j < robots_size; j++)
{
// If the robot's angular velocity is great enough, use a more accurate model
if(fabs(robots[j].rotv) < 10.0)
{
robots[j].pos.x += robots[j].v * cosd(robots[j].rot) / ITERATIONS_PER_SEC;
robots[j].pos.y += robots[j].v * sind(robots[j].rot) / ITERATIONS_PER_SEC;
}
else
{
robots[j].pos.x += robots[j].v * 180.0 / M_PI
* (sind(robots[j].rotv / ITERATIONS_PER_SEC + robots[j].rot)
- sind(robots[j].rot)) / robots[j].rotv;
robots[j].pos.y += robots[j].v * 180.0 / M_PI
* (-cosd(robots[j].rotv / ITERATIONS_PER_SEC
+ robots[j].rot) + cosd(robots[j].rot)) / robots[j].rotv;
}
robots[j].rot += robots[j].rotv / ITERATIONS_PER_SEC;
}
}
示例10: ObservationPointSet
void ObservationPointSet(long double NS,long double EW,long double ro)
{
if (NS < -90) NS = -90;
if (NS > 90) NS = -90;
if (EW < -180) EW = -180;
if (EW > 180) EW = 180;
longitude = EW;
LAT = NS - 0.19241666667 * sind(NS * 2); /* 天文緯度 */
RLT = ((0.998327112 + 0.001676399 * cosd(NS * 2) - 0.000003519 * cosd(NS * 4)) * 6378140 + ro) / 6371012;
if (RLT < 0) RLT = 0;
return;
}
示例11: rotateXYZ
QVector3D rotateXYZ(QVector3D vector, QVector3D rotation) {
float x, y, z, x_ = vector.x(), y_ = vector.y(), z_ = vector.z();
//Rotation autour de X
x = x_, y = y_ * cosd(rotation.x()) - z_ * sind(rotation.x()), z = y_ * sind(rotation.x()) + z_ * cosd(rotation.x());
//Rotation autour de Y
x_ = x * cosd(rotation.y()) + z * sind(rotation.y()), y_ = y, z_ = z * cosd(rotation.y()) - x * sind(rotation.y());
//Rotation autour de Z
x = x_ * cosd(rotation.z()) - y_ * sind(rotation.z()), y = x_ * sind(rotation.z()) + y_ * cosd(rotation.z()), z = z_;
return QVector3D(x, y, -z);
}
示例12: sphpad
int sphpad(
int nfield,
double lng0,
double lat0,
const double dist[],
const double pa[],
double lng[],
double lat[])
{
int i;
double eul[5];
/* Set the Euler angles for the coordinate transformation. */
eul[0] = lng0;
eul[1] = 90.0 - lat0;
eul[2] = 0.0;
eul[3] = cosd(eul[1]);
eul[4] = sind(eul[1]);
for (i = 0; i < nfield; i++) {
/* Latitude in the new frame is obtained from angular distance. */
lat[i] = 90.0 - dist[i];
/* Longitude in the new frame is obtained from position angle. */
lng[i] = -pa[i];
}
/* Transform field points to the old system. */
sphx2s(eul, nfield, 0, 1, 1, lng, lat, lng, lat);
return 0;
}
示例13: sphdpa
int sphdpa(
int nfield,
double lng0,
double lat0,
const double lng[],
const double lat[],
double dist[],
double pa[])
{
int i;
double eul[5];
/* Set the Euler angles for the coordinate transformation. */
eul[0] = lng0;
eul[1] = 90.0 - lat0;
eul[2] = 0.0;
eul[3] = cosd(eul[1]);
eul[4] = sind(eul[1]);
/* Transform field points to the new system. */
sphs2x(eul, nfield, 0, 1, 1, lng, lat, pa, dist);
for (i = 0; i < nfield; i++) {
/* Angular distance is obtained from latitude in the new frame. */
dist[i] = 90.0 - dist[i];
/* Position angle is obtained from longitude in the new frame. */
pa[i] = -pa[i];
if (pa[i] < -180.0) pa[i] += 360.0;
}
return 0;
}
示例14: gse_twixt_hee
/*
** Hapgood defines a transformation between GSE and HEE in his 1992
** paper (section 6), but this part isn't online.
**
** The gist of it is, we rotate 180 degrees about Z, and then translate
** along X.
**
** But we also need to add "R", a constant vector defined by
**
** R = [ Rsun, 0, 0 ]
**
** where
**
** r0 (1 - e^2)
** Rsun = ------------
** 1 + e cos(v)
**
** r0 = 1.495985E8 km mean distance of the Sun from Earth.
**
** e = 0.016709 - 0.0000418T0 eccentricity of the Sun's apparent
** orbit around the Earth.
**
** w = 282.94 + 1.72 T0 longitude of perigee of that orbit
**
** v = lambda0 - w (see lambda0 above)
**
**
** Implemented by Ed Santiago, Updated by Kristi Keller
*/
int
gse_twixt_hee(const double et, Vec v_in, Vec v_out, Direction direction)
{
Mat mat;
double r0,e, w,v, Rsun;
hapgood_matrix(180, Z, mat);
/*
** Note that there's no transposition here if the direction is "back";
** the operation works identically in both directions.
*/
mat_times_vec(mat, v_in, v_out);
/* Translate the X axis about the earth-sun distance */
r0 = (double)1.495985e8;
e = 0.016709 - 0.0000418*T0(et);
w = 282.94 + 1.72*T0(et);
v = lambda0(et) - w;
Rsun = r0*(1-e*e)/(1.+e*cosd(v));
/* v_out[0] += (double)1.5e8; */
v_out[0] += Rsun;
return 0;
}
示例15: latlon_to_ij
/* -------------------------------------------------------------------------- */
void latlon_to_ij(float latitude, float longitude, float *ri, float *rj)
{
double cell;
double ylon;
double flp;
double psx;
double xx = 0;
double yy = 0;
double r;
if (! is_init)
{
fprintf(stderr, "Using latlon_to_ij without projection init !!!\n");
*ri = -999;
*rj = -999;
return;
}
if (pj.code == MERCATOR)
{
if (latitude != -90.0)
{
cell = cosd(latitude)/(1.0+sind(latitude));
yy = -c2*log(cell);
xx = c2*((longitude-pj.cenlon)*DEG_TO_RAD);
if (pj.cenlon > 0.0 && xx < -dddd)
{
xx = xx + 2.0*c2*((180.0+pj.cenlon)*DEG_TO_RAD);
}
else if (pj.cenlon < 0.0 && xx > dddd)
{
xx = xx - c2*(360.0*DEG_TO_RAD);
}
}
}
else
{
ylon = longitude - pj.cenlon;
if (ylon > 180.0) ylon -= 360.0;
if (ylon < -180.0) ylon += 360.0;
flp = xn*(ylon*DEG_TO_RAD);
psx = (pole - latitude) * DEG_TO_RAD;
r = -RADIUS_EARTH/xn*sin(psi1)*pow(tan(psx*0.50)/tan(psi1*0.50),xn);
if (pj.cenlat < 0)
{
xx = r*sin(flp);
yy = r*cos(flp);
}
else
{
xx = -r*sin(flp);
yy = r*cos(flp);
}
}
*ri = (xx - xc) / pj.ds + cntrj;
*rj = (yy - yc) / pj.ds + cntri;
return;
}