本文整理汇总了C++中rad2deg函数的典型用法代码示例。如果您正苦于以下问题:C++ rad2deg函数的具体用法?C++ rad2deg怎么用?C++ rad2deg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rad2deg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
main()
{
double X;
for (X = 0.0; X <= 360.0; X += 45.0)
printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X));
puts("");
for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 6))
printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X));
return 0;
}
示例2: mympu_update
int mympu_update() {
do {
ret = dmp_read_fifo(gyro,NULL,q._l,NULL,&sensors,&fifoCount);
/* will return:
0 - if ok
1 - no packet available
2 - if BIT_FIFO_OVERFLOWN is set
3 - if frame corrupted
<0 - if error
*/
if (ret!=0) return ret;
} while (fifoCount>1);
q._f.w = (float)q._l[0] / (float)QUAT_SENS;
q._f.x = (float)q._l[1] / (float)QUAT_SENS;
q._f.y = (float)q._l[2] / (float)QUAT_SENS;
q._f.z = (float)q._l[3] / (float)QUAT_SENS;
mympu.quat.w = q._f.w;
mympu.quat.x = q._f.x;
mympu.quat.y = q._f.y;
mympu.quat.z = q._f.z;
quaternionToEuler( &q._f, &mympu.ypr[2], &mympu.ypr[1], &mympu.ypr[0] );
/* need to adjust signs and do the wraps depending on the MPU mount orientation */
/* if axis is no centered around 0 but around i.e 90 degree due to mount orientation */
/* then do: mympu.ypr[x] = wrap_180(90.f+rad2deg(mympu.ypr[x])); */
mympu.ypr[0] = rad2deg(mympu.ypr[0]);
mympu.ypr[1] = rad2deg(mympu.ypr[1]);
mympu.ypr[2] = rad2deg(mympu.ypr[2]);
/* need to adjust signs depending on the MPU mount orientation */
mympu.gyro[0] = -(float)gyro[2] / GYRO_SENS;
mympu.gyro[1] = (float)gyro[1] / GYRO_SENS;
mympu.gyro[2] = (float)gyro[0] / GYRO_SENS;
return 0;
}
示例3: return
TCFloat LDExporter::getHFov(void)
{
if (m_width > m_height)
{
return (TCFloat)(2.0 * rad2deg(atan(tan(deg2rad(m_fov / 2.0)) *
(double)m_width / (double)m_height)));
}
else
{
return m_fov;
}
}
示例4: calcEquationOfTime
/* Purpose: calculate the difference between true solar time and mean
* solar time (minutes)
*/
double calcEquationOfTime(double t) {
double l0 = deg2rad(calcGeomMeanLongSun(t));
double e = calcEccentricityEarthOrbit(t);
double m = deg2rad(calcGeomMeanAnomalySun(t));
double y = tan(deg2rad(calcObliquityCorrection(t))/2.0);
double sinm = sin(m);
y *= y;
return rad2deg(y*sin(2.0*l0) - 2.0*e*sinm + 4.0*e*y*sinm*cos(2.0*l0)
- 0.5*y*y*sin(4.0*l0) - 1.25*e*e*sin(2.0*m))*4.0;
}
示例5: sin
void rpi_vector::calc(){
if (calcd) return;
if (mode) {
x = r * sin(deg2rad(lat)) * cos(deg2rad(longit));
y = r * sin(deg2rad(lat)) * sin(deg2rad(longit));
z = r * cos(deg2rad(lat)) ;
}else{
r = sqrt(x*x+y*y+z*z);
if (z!=0)
{
lat = rad2deg(acos(z/r));
longit = rad2deg(acos(x/(r * sin(deg2rad(lat)))));
}else{
lat=0;
longit = rad2deg(atan(y/x));
}
}
calcd = true;
}
示例6: sun_hour_angle_at_rise_set
double sun_hour_angle_at_rise_set(double latitude, double delta_zero, double h0_prime)
{
double h0 = -99999;
double latitude_rad = deg2rad(latitude);
double delta_zero_rad = deg2rad(delta_zero);
double argument = (sin(deg2rad(h0_prime)) - sin(latitude_rad)*sin(delta_zero_rad)) /
(cos(latitude_rad)*cos(delta_zero_rad));
if (fabs(argument) <= 1) h0 = limit_degrees180(rad2deg(acos(argument)));
return h0;
}
示例7: acos
/*
VA == 0
A = undefined
VB == 0
A = W
/ 2 2 2 \
-1 | VA + VB - VW |
A = cos | ------------ |
\ 2 VA VB /
-1 / VW \
A = sin | -- sin W |
\ VA /
*/
double Polar::DirectionApparentWind(double VA, double VB, double W, double VW)
{
if(VA == 0) /* apparent wind direction is not defined */
return 0;
if(VB == 0) /* trig identity breaks down, but if we aren't */
return W; /* moving, apparent wind is true wind */
double cosA = (VA*VA + VB*VB - VW*VW) / (2*VA*VB);
if(cosA > 1) cosA = 1; else if(cosA < -1) cosA = -1; /* slight arithmatic errors */
double ac = acos(cosA);
while(W > 180) W-=360;
while(W < -180) W+=360;
return rad2deg(W > 0 ? ac : -ac);
}
示例8: maep_geonames_entry_request
/* request geotagged wikipedia entries for current map view */
void maep_geonames_entry_request(coord_t *pt1, coord_t *pt2,
MaepGeonamesRequestCallback cb, gpointer obj)
{
request_cb_t *context;
/* create ascii (dot decimal point) strings */
char str[4][16];
g_ascii_formatd(str[0], sizeof(str[0]), "%.07f", rad2deg(pt1->rlat));
g_ascii_formatd(str[1], sizeof(str[1]), "%.07f", rad2deg(pt2->rlat));
g_ascii_formatd(str[2], sizeof(str[2]), "%.07f", rad2deg(pt1->rlon));
g_ascii_formatd(str[3], sizeof(str[3]), "%.07f", rad2deg(pt2->rlon));
gchar *locale, lang[3] = { 0,0,0 };
gchar *lang_avail[] = {"de", "en", "es", "fr", "it", "nl", "pl", "pt", "ru", "zh", NULL};
int i;
locale = setlocale (LC_MESSAGES, NULL);
g_utf8_strncpy (lang, locale, 2);
/* currently only "de" and "en" are supported by geonames.org */
/* force to "en" in any other case */
g_message("Look for entries in %s", lang);
for (i = 0; lang_avail[i] && strcasecmp(lang, lang_avail[i]); i++);
if (!lang_avail[i])
strncpy(lang, "en", 2);
/* build complete url for request */
char *url = g_strdup_printf(
GEONAMES "wikipediaBoundingBox?"
"north=%s&south=%s&west=%s&east=%s&lang=%s&maxRows=%u&username=" PACKAGE,
str[0], str[1], str[2], str[3], lang, MAX_RESULT);
/* start download in background */
g_message("start asynchronous geonames download.");
context = g_malloc0(sizeof(request_cb_t));
context->cb = cb;
context->obj = obj;
net_io_download_async(url, geonames_request_cb, context);
g_free(url);
}
示例9: computeCorr
void
computeCorr( logtools_rpos2_t pos, logtools_rpos2_t map, logtools_rpos2_t *corr )
{
logtools_rpos2_t map2, pos2;
map2 = map;
map2.o = rad2deg( map.o );
pos2 = pos;
pos2.o = 90.0 - pos.o;
compute_correction_parameters( pos2, map2, corr );
}
示例10: GetInfoNext
void TfraEmitter::GetInfoNext(const PS::SEmitterDef& E){
pcEmitterType->ActivePageIndex = E.m_EmitterType;
// cone
seConeDirH->ObjNextInit (rad2deg(E.m_ConeHPB.x));
seConeDirP->ObjNextInit (rad2deg(E.m_ConeHPB.y));
seConeDirB->ObjNextInit (rad2deg(E.m_ConeHPB.z));
seConeAngle->ObjNextInit (rad2deg(E.m_ConeAngle));
// sphere
seSphereRadius->ObjNextInit (E.m_SphereRadius);
// box
seBoxSizeX->ObjNextInit (E.m_BoxSize.x);
seBoxSizeY->ObjNextInit (E.m_BoxSize.y);
seBoxSizeZ->ObjNextInit (E.m_BoxSize.z);
// birth
seBirthRate->ObjNextInit (E.m_fBirthRate);
ebBirthFunc->Down = E.m_Flags.is(PS_EM_BIRTHFUNC);
seParticleLimit->ObjNextInit (E.m_ParticleLimit);
// burst
cbBurst->ObjNextInit ((E.m_Flags.is(PS_EM_BURST))?cbChecked:cbUnchecked);
// play once
cbPlayOnce->ObjNextInit ((E.m_Flags.is(PS_EM_PLAY_ONCE))?cbChecked:cbUnchecked);
}
示例11: distance
double distance(double lat1, double lon1)
{
double theta, dist;
fprintf(stderr, "lastlat %f lastlon %f\n", lastlat, lastlon);
theta = lon1 - lastlon;
dist = sin(deg2rad(lat1)) * sin(deg2rad(lastlat)) + cos(deg2rad(lat1)) * cos(deg2rad(lastlat)) * cos(deg2rad(theta));
dist = acos(dist);
dist = rad2deg(dist);
dist = dist * 60 * 1.1515;
dist = dist * (1.609344);
dist=dist*1000;
c.distance[i]=dist;
double dLon = deg2rad(theta);
double y = sin(dLon) * cos(lat1);
double x = cos(lastlat)*sin(lat1) -
sin(lastlat)*cos(lat1)*cos(dLon);
double brng =atan2(y,x);
c.angle[i]=brng;
fprintf(stderr,"brng %f\n",brng);
lastlat =lat1;
lastlon=lon1;
c.header.frame_id="cmd";
c.header.stamp = ros::Time::now();
c.num_of_waypoints=i+1;
//c.distance[]={0,0,0,0,0};
//c.angle[]={0,0,0,0,0};
//temp1[i]=dist;
//m++;
//if(m==5)
//{
//for(i=0;i=5;i++)
//c.distance[i]=temp1[i];
//}
if(i==5)
{
pub_cmd.publish(c);
}
i++;
for(int j=0;j<=5;j++)
{
fprintf(stderr,"temp %f\n",c.distance[j]);
}
fprintf(stderr,"m %d\n",m);
return (dist);
}
示例12: GetGlobalColor
void DashboardInstrument_Compass::DrawCompassRose(wxBufferedDC* dc)
{
wxPoint TextPoint, points[3];
wxString Value;
int width, height;
wxString CompassArray[] = {_("N"),_("NE"),_("E"),_("SE"),_("S"),_("SW"),_("W"),_("NW"),_("N")};
int tmpradius = m_radius * 0.75;
dc->SetFont(*g_pFontSmall);
wxColour cl;
wxPen pen;
pen.SetStyle(wxSOLID);
GetGlobalColor(_T("BLUE1"), &cl);
pen.SetColour(cl);
dc->SetPen(pen);
dc->SetTextForeground(cl);
//dc->SetPen(*wxTRANSPARENT_PEN);
int offset = 0;
for(double tmpangle = m_AngleStart - ANGLE_OFFSET;
tmpangle <= m_AngleStart + 360 - ANGLE_OFFSET; tmpangle+=45)
{
Value = CompassArray[offset];
dc->GetTextExtent(Value, &width, &height, 0, 0, g_pFontSmall);
double x = width/2;
long double anglefortext = asin((x/tmpradius));
anglefortext = tmpangle - rad2deg(anglefortext);
TextPoint.x = m_cx + tmpradius * cos(deg2rad(anglefortext));
TextPoint.y = m_cy + tmpradius * sin(deg2rad(anglefortext));
dc->DrawRotatedText(Value, TextPoint.x,
TextPoint.y, -90 - tmpangle);
dc->SetBrush(*wxTRANSPARENT_BRUSH);
points[0].x = m_cx;
points[0].y = m_cy;
points[1].x = m_cx + tmpradius * 0.1 * cos(deg2rad(tmpangle-45));
points[1].y = m_cy + tmpradius * 0.1 * sin(deg2rad(tmpangle-45));
double size = (offset % 2 ? 0.50 : 0.80);
points[2].x = m_cx + tmpradius * size * cos(deg2rad(tmpangle));
points[2].y = m_cy + tmpradius * size * sin(deg2rad(tmpangle));
dc->DrawPolygon(3, points, 0, 0);
points[1].x = m_cx + tmpradius * 0.1 * cos(deg2rad(tmpangle+45));
points[1].y = m_cy + tmpradius * 0.1 * sin(deg2rad(tmpangle+45));
dc->SetBrush(cl);
dc->DrawPolygon(3, points, 0, 0);
offset++;
}
}
示例13: q
void pose_esti::vslam_poseCallback(const geometry_msgs::PoseWithCovarianceStampedPtr &msg)
{
yaw_now=ros::Time::now();
ptam_pose = *msg;
if( pick_ptam_yaw_init_time && (vslam_states.data=="PTAM_initialized"))
{
//ROS_INFO("%f %f %f\n",ptam_pose.pose.pose.position.x,ptam_pose.pose.pose.position.y,ptam_pose.pose.pose.position.z);
tf::Quaternion temp;
//
tf::Quaternion q(0,0,0,0);
tf::quaternionMsgToTF(ptam_pose.pose.pose.orientation, temp);
tfScalar ptam_yaw, ptam_pitch, ptam_roll;
tf::Matrix3x3(temp).getRPY(ptam_roll, ptam_pitch, ptam_yaw);
double cmd_temp_yaw;
double ptam_yaw_temp = rad2deg(-(ptam_yaw+M_PI/2));
//double ptam_yaw_temp = rad2deg(ptam_yaw);
PTAM_Yaw=ptam_yaw_temp;
cmd_temp_yaw=pid_yaw.updatePid(ptam_yaw_temp-goal_pose.yaw,yaw_now-yaw_past);
cout<<"pid output yaw = "<<cmd_temp_yaw<<endl;
cmd_yaw.linear.x=0;
cmd_yaw.linear.y=0;
cmd_yaw.linear.z=0;
cmd_yaw.angular.x=0;
cmd_yaw.angular.y=0;
cmd_yaw.angular.z=cmd_temp_yaw;
cmd_yaw_pub.publish(cmd_yaw);
cout<<"imu yaw = "<<rad2deg(yaw_test)<<endl<<
"ptam yaw= "<<ptam_yaw_temp<<endl;
}
else
{
yaw_past = yaw_now;
pick_ptam_yaw_init_time=1;
}
}
示例14: Euler_matrix2angles
// Michael's method
void Euler_matrix2angles(Matrix2D<DOUBLE> A, DOUBLE *alpha, DOUBLE *beta,
DOUBLE *gamma)
{
DOUBLE abs_sb;
if (ABS(A(1, 1)) > FLT_EPSILON)
{
abs_sb = sqrt((-A(2, 2) * A(1, 2) * A(2, 1) - A(0, 2) * A(2, 0)) / A(1, 1));
}
else if (ABS(A(0, 1)) > FLT_EPSILON)
{
abs_sb = sqrt((-A(2, 1) * A(2, 2) * A(0, 2) + A(2, 0) * A(1, 2)) / A(0, 1));
}
else if (ABS(A(0, 0)) > FLT_EPSILON)
{
abs_sb = sqrt((-A(2, 0) * A(2, 2) * A(0, 2) - A(2, 1) * A(1, 2)) / A(0, 0));
}
else
EXIT_ERROR(1, "Don't know how to extract angles");
if (abs_sb > FLT_EPSILON)
{
*beta = atan2(abs_sb, A(2, 2));
*alpha = atan2(A(2, 1) / abs_sb, A(2, 0) / abs_sb);
*gamma = atan2(A(1, 2) / abs_sb, -A(0, 2) / abs_sb);
}
else
{
*alpha = 0;
*beta = 0;
*gamma = atan2(A(1, 0), A(0, 0));
}
*gamma = rad2deg(*gamma);
*beta = rad2deg(*beta);
*alpha = rad2deg(*alpha);
}
示例15: followStraightPath
float followStraightPath(float* waypointDirection, float* targetWaypoint, float* position, float heading){ //Heading in degrees (magnetic)
heading = deg2rad(90 - heading);//90 - heading = magnetic heading to cartesian heading
float courseAngle = atan2(waypointDirection[1], waypointDirection[0]); // (y,x) format
while (courseAngle - heading < -PI){
courseAngle += 2 * PI;
}
while (courseAngle - heading > PI){
courseAngle -= 2 * PI;
}
float pathError = -sin(courseAngle) * (position[0] - targetWaypoint[0]) + cos(courseAngle) * (position[1] - targetWaypoint[1]);
float calcHeading = 90 - rad2deg(courseAngle - MAX_PATH_APPROACH_ANGLE * 2/PI * atan(k_gain[PATH] * pathError)); //Heading in degrees (magnetic)
return calcHeading;
}