这篇教程C++ DEG_TO_RAD函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DEG_TO_RAD函数的典型用法代码示例。如果您正苦于以下问题:C++ DEG_TO_RAD函数的具体用法?C++ DEG_TO_RAD怎么用?C++ DEG_TO_RAD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DEG_TO_RAD函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: left_endstatic gfloatleft_end (gfloat from, gfloat to, gboolean cl){ gfloat alpha = DEG_TO_RAD (from); gfloat beta = DEG_TO_RAD (to); gint cw_ccw = cl ? -1 : 1; switch (cw_ccw) { case -1: if (alpha < beta) return alpha + TWO_PI; default: return alpha; /* 1 */ }}
开发者ID:elEnemigo,项目名称:GEGL-OpenCL,代码行数:19,
示例2: ProcessVectorTrackLinearvoid CCamera::ProcessVectorTrackLinear(float time){ m_processedVectorTrackLinear = true; float weight = time; if (m_vectorTrackLinearConstSpeed) { weight = (sin(DEG_TO_RAD(270.0f - time * 180.0f)) + 1.0f) / 2.0f; } m_vectorTrackLinearCurrent = Lerp(m_vectorTrackLinearStart, weight, m_vectorTrackLinearEnd);}
开发者ID:WLSF,项目名称:GTASA,代码行数:10,
示例3: sg_camera_rotate_hatvoidsg_camera_rotate_hat(int buttonVal, void *data){ //log_info("hat pushed %d", buttonVal); sg_scene_t *sc = sim_get_scene(); sg_camera_t *cam = sg_scene_get_cam(sc); ASSERT_CAM(cam); // Note that the camera control will rotate the camera based on WCT. // This differ from the normal rotation of objects which is based on SRT. // The interpolation doesn't really care, it just expresses time as a // normalized value where 0 is the time of the last physics system sync // and 1.0 is the expected time of the next sync. // We thus need to take the frequency (not the SRT period) here. float wct_freq; config_get_float_def("openorbit/sim/freq", &wct_freq, 20.0); // Hz if ((cam->src == cam->tgt) && cam->src) { // We are targeting our follow object this means orbiting it if (buttonVal == -1) { cam->dq = QD_IDENT; } else { cam->dq = qd_rot(0.0, cosf(DEG_TO_RAD(buttonVal)), sinf(DEG_TO_RAD(buttonVal)), M_PI_2 / wct_freq); } cam->q1 = qd_mul(cam->q0, cam->dq); } else { if (buttonVal == -1) { cam->dq = QD_IDENT; } else { cam->dq = qd_rot(0.0, cosf(DEG_TO_RAD(buttonVal)), sinf(DEG_TO_RAD(buttonVal)), M_PI_2 / wct_freq); } cam->q1 = qd_mul(cam->q0, cam->dq); } ASSERT_CAM(cam);}
开发者ID:JohanOtto,项目名称:openorbit,代码行数:43,
示例4: ooGeoEllipseAreaSegOOellipse* ooGeoEllipseAreaSeg(size_t segs, float semiMajor, float semiMinor){ OOellipse *e = smalloc(sizeof(OOellipse)); ooVecArrayInit(&e->vec); //uint64_t totalIterations = 0; e->semiMajor = semiMajor; e->semiMinor = semiMinor; e->ecc = ooGeoEllipseEcc(e); double area = ooGeoEllipseArea(e); double sweep = area / (double)segs; ooVecArrayPushC(&e->vec, semiMajor * cos(0.0) - e->ecc * semiMajor, semiMinor * sin(0.0), 0.0f, 0.0f); double segArea, tol; double prevAngle = 0.0f; double newAngle = prevAngle + 1.0*DEG_TO_RAD(360.0/(double)segs); double delta; for (size_t i = 1 ; i < segs ; i ++) { int count = 0; segArea = ooGeoEllipseSegmentArea(e, prevAngle, newAngle); delta = (newAngle-prevAngle); do { if (segArea > sweep) { delta -= delta/STEPSIZE; } else { delta += delta/STEPSIZE; } newAngle = prevAngle + delta; segArea = ooGeoEllipseSegmentArea(e, prevAngle, newAngle); tol = fabs(1.0 - segArea/sweep); count ++; } while (tol > 0.00001 && count < ITERSTOP); if (count >= ITERSTOP) { log_warn("ellipse segment did not converge in %d iterations", ITERSTOP); } //segArea = segmentArea(prevAngle, newAngle, semimajor, ecc); // Insert vec in array, note that center is in foci ooVecArrayPushC(&e->vec, semiMajor * cos(newAngle) - e->ecc * semiMajor, semiMinor * sin(newAngle), 0.0f, 0.0f); double nextNewAngle = newAngle + (newAngle-prevAngle); prevAngle = newAngle; newAngle = nextNewAngle; } return e;}
开发者ID:JohanOtto,项目名称:openorbit,代码行数:55,
示例5: entityWaitstatic void entityWait(){ self->thinkTime += 2; if (self->thinkTime >= 360) { self->thinkTime = 0; } self->y = self->startY + sin(DEG_TO_RAD(self->thinkTime)) * 16;}
开发者ID:revcozmo,项目名称:edgar,代码行数:11,
示例6: swingstatic void swing(){ self->thinkTime += 2; if (self->thinkTime >= 360) { self->thinkTime = 0; } self->x = self->endX + sin(DEG_TO_RAD(self->thinkTime)) * 8;}
开发者ID:revcozmo,项目名称:edgar,代码行数:11,
示例7: shudderstatic void shudder(){ self->startY += 90; self->x = self->startX + sin(DEG_TO_RAD(self->startY)) * 4; if (self->startY >= 360) { self->startY = 0; }}
开发者ID:LibreGames,项目名称:edgar,代码行数:11,
示例8: calc_dist_to_waypoint// Returns the distance (in meters) to the current waypointstatic float calc_dist_to_waypoint(float lat_1, float long_1, float lat_2, float long_2) { float lat_1_rad = DEG_TO_RAD(lat_1); float long_1_rad = DEG_TO_RAD(long_1); float lat_2_rad = DEG_TO_RAD(lat_2); float long_2_rad = DEG_TO_RAD(long_2); float diff_lat = lat_2_rad - lat_1_rad; float diff_long = long_2_rad - long_1_rad; float a = ( pow(sin(diff_lat / 2), 2) ) + cos(lat_1_rad) * cos(lat_2_rad) * ( pow(sin(diff_long / 2), 2) ); float c = 2 * asin(sqrt(a)); float distance_m = EARTH_RADIUS_M * c; return distance_m;}
开发者ID:mr-augustine,项目名称:kintobor,代码行数:21,
示例9: hoverstatic void hover(){ self->endX++; if (self->endX >= 360) { self->endX = 0; } self->y = self->endY + sin(DEG_TO_RAD(self->endX)) * 8;}
开发者ID:revcozmo,项目名称:edgar,代码行数:11,
示例10: hoverstatic void hover(){ self->endX += 4; if (self->endX >= 360) { self->endX = 0; } self->y = self->startY + sin(DEG_TO_RAD(self->endX)) * 4;}
开发者ID:polluks,项目名称:edgar,代码行数:11,
示例11: hoverstatic void hover(){ self->startX++; if (self->startX >= 360) { self->startX = 0; } self->y = self->startY + sin(DEG_TO_RAD(self->startX)) * 8;}
开发者ID:LibreGames,项目名称:edgar,代码行数:11,
示例12: angle/** * snaps a vector to the nearest angle that is a multiple of snapAngle * * @param vector the Vector to be modified */Vector3& angle( Vector3& vector, float snapAngle ){ float pitch; float yaw; bool flipYaw; if (vector.x != 0.f) { yaw = atanf( vector.z / vector.x ); flipYaw = ( vector.x < 0 ); } else { yaw = MATH_PI / 2; flipYaw = ( vector.z < 0 ); } pitch = acosf( Math::clamp(-1.0f, vector.y, +1.0f) ); //snap the angles yaw = value( yaw, DEG_TO_RAD( snapAngle ) ); //snap the angle pitch = value( pitch, DEG_TO_RAD( snapAngle ) ); //mirror octants if ( flipYaw ) yaw = yaw - MATH_PI; //recalc the orientation float cosYaw = cosf( yaw ); float sinYaw = sinf( yaw ); float cosPitch = cosf( pitch ); float sinPitch = sinf( pitch ); vector.set( cosYaw * sinPitch, cosPitch, sinYaw * sinPitch ); vector.normalise(); return vector;}
开发者ID:siredblood,项目名称:tree-bumpkin-project,代码行数:46,
示例13: DEG_TO_RADQuaternion Quaternion::rotationQuaternion(GLfloat angle, vec3_t<GLfloat> axis){ Quaternion q; GLfloat radians = DEG_TO_RAD(angle); GLfloat angBy2 = radians / 2.f; q.w = cosf(angBy2); q.x = axis.x * sinf(angBy2); q.y = axis.y * sinf(angBy2); q.z = axis.z * sinf(angBy2); return q;}
开发者ID:Zoetermeer,项目名称:trailblazer,代码行数:12,
示例14: axis// --[ Method ]---------------------------------------------------------------//// - Class : CMatrix//// - prototype : BuildRotation(float fAngle, float fAxisX, float fAxisY, float fAxisZ)//// - Purpose : Builds a rotation matrix of fAngle degrees around the axis// given by (fAxisX, fAxisY, fAxisZ).//// -----------------------------------------------------------------------------void CMatrix::BuildRotation(float fAngle, float fAxisX, float fAxisY, float fAxisZ){ CVector3 axis(fAxisX, fAxisY, fAxisZ); axis.Normalize(); float fRad = DEG_TO_RAD(fAngle * 0.5f); float fSine = sinf(fRad); CQuaternion quat(cosf(fRad), fSine * fAxisX, fSine * fAxisY, fSine * fAxisZ); *this = quat.Matrix();}
开发者ID:fernandojsg,项目名称:sgzsourcepack,代码行数:22,
示例15: polar_to_rectRect_V polar_to_rect(Polar_V pv){ #define PI (4.0*atan(1)) #define DEG_TO_RAD(X) ((X)*(PI/180.0)) Rect_V rv; register double A = DEG_TO_RAD(pv.angle); rv.x = pv.magnitude*cos(A); rv.y = pv.magnitude*sin(A); return rv; }
开发者ID:marrusian,项目名称:C,代码行数:12,
示例16: updateFrustumvoid updateFrustum(){ // build view frustum from projection and view matrix frustum.SetFromMatrix( Gs::ProjectionMatrix4::Perspective( static_cast<Gs::Real>(resolution.x) / resolution.y, 0.1f, 100.0f, DEG_TO_RAD(fov) ).ToMatrix4()// * viewMatrix.ToMatrix4() );}
开发者ID:LukasBanana,项目名称:GeometronLib,代码行数:12,
示例17: DEG_TO_RADQuaternion::Quaternion(const Vector3f &axis, float angleInDegrees){ float a = DEG_TO_RAD(angleInDegrees) * 0.5f; float s = sin(a); float norm = axis.Length(); if (norm < 0.00001f) norm = 0.00001f; x = s * axis.x / norm; y = s * axis.y / norm; z = s * axis.z / norm; w = cos(a);}
开发者ID:alexgaiv,项目名称:cubex,代码行数:12,
示例18: calc_derived_valuesstatic void calc_derived_values(rift_priv *priv){ priv->base.properties.hsize = priv->display_info.h_screen_size; priv->base.properties.vsize = priv->display_info.v_screen_size; priv->base.properties.hres = priv->display_info.h_resolution; priv->base.properties.vres = priv->display_info.v_resolution; priv->base.properties.lens_sep = priv->display_info.lens_separation; priv->base.properties.lens_vpos = priv->display_info.v_center; priv->base.properties.fov = DEG_TO_RAD(125.5144f); // TODO calculate. // Calculate the screen ratio of each subscreen. float full_ratio = (float)priv->display_info.h_resolution / (float)priv->display_info.v_resolution; float ratio = full_ratio / 2.0f; priv->base.properties.ratio = ratio; // Calculate where the lens is on each screen, // and with the given value offset the projection matrix. float screen_center = priv->display_info.h_screen_size / 4.0f; float lens_shift = screen_center - priv->display_info.lens_separation / 2.0f; float proj_offset = 4.0f * lens_shift / priv->display_info.h_screen_size; priv->calc_values.proj_offset = proj_offset; // Setup the base projection matrix. Each eye mostly have the // same projection matrix with the exception of the offset. omat4x4f_init_perspective(&priv->calc_values.proj_base, priv->base.properties.fov, priv->base.properties.ratio, priv->base.properties.znear, priv->base.properties.zfar); // Setup the two adjusted projection matricies. Each is setup to deal // with the fact that the lens is not in the center of the screen. // These matrices only change of the hardware changes, so static. mat4x4f translate; omat4x4f_init_translate(&translate, proj_offset, 0, 0); omat4x4f_mult(&translate, &priv->calc_values.proj_base, &priv->base.properties.proj_left); omat4x4f_init_translate(&translate, -proj_offset, 0, 0); omat4x4f_mult(&translate, &priv->calc_values.proj_base, &priv->base.properties.proj_right);}
开发者ID:Fredz66,项目名称:OpenHMD,代码行数:53,
示例19: cosbool CBlock::CheckCollision (sf::Sprite *p_pSprite, sf::Vector2f p_fPos){ bool bCollided = false; int iNbSteps = 0; float fDirection = p_pSprite->getRotation (); if (p_pSprite->getOrigin () != sf::Vector2f (0.f, 0.f)) { fDirection -= 90.f; p_fPos.x += p_pSprite->getOrigin ().x * cos (DEG_TO_RAD(fDirection)); p_fPos.y += p_pSprite->getOrigin ().y * sin (DEG_TO_RAD(fDirection)); fDirection += 90.f; p_fPos.x += p_pSprite->getOrigin ().x * cos (DEG_TO_RAD(fDirection)); p_fPos.y += p_pSprite->getOrigin ().y * sin (DEG_TO_RAD(fDirection)); } for (int i = 0; i < 4; i++) { fDirection += 90.f; if (i % 2 == 1) iNbSteps = p_pSprite->getTextureRect ().height; else iNbSteps = p_pSprite->getTextureRect ().width; for (int j = 0; j < iNbSteps; j++) { p_fPos.x += 1.f * cos (DEG_TO_RAD(fDirection)); p_fPos.y += 1.f * sin (DEG_TO_RAD(fDirection)); if ((p_fPos.x >= m_fPos.x - static_cast<float> (m_iSize.x) / 2) && (p_fPos.x <= m_fPos.x + static_cast<float> (m_iSize.x) / 2) && (p_fPos.y >= m_fPos.y - static_cast<float> (m_iSize.y) / 2) && (p_fPos.y <= m_fPos.y + static_cast<float> (m_iSize.y) / 2)) bCollided = true; } } return bCollided;}
开发者ID:Ch4ll3ng3r,项目名称:cs2d,代码行数:33,
示例20: headWaitstatic void headWait(){ int x; /* Sway back and forth */ self->dirX += 0.5; if (self->dirX >= 360) { self->dirX = 0; } x = 24; self->x = self->targetX + (sin(DEG_TO_RAD(self->dirX)) * x); alignBodyToHead(); self->thinkTime--; if (self->thinkTime <= 0 && player.health > 0) { self->thinkTime = 0; x = prand() % 4; switch (x) { case 0: self->action = &biteAttackInit; break; case 1: self->action = &changeSidesInit; break; case 2: self->action = &shotAttackInit; break; default: self->action = &crushAttackInit; break; } } if (prand() % 180 == 0) { playSoundToMap("sound/boss/snake_boss/hiss", BOSS_CHANNEL, self->x, self->y, 0); }}
开发者ID:carriercomm,项目名称:edgar,代码行数:52,
示例21: MatrixMatrix Camera::GetProjectionMatrix() { double c = -Near / Far; double a = -1.0/(c+1.0); double b = c/(c+1.0); Matrix M = Matrix(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, a, b, 0, 0, -1, 0); double sx = 1.0/(tan(DEG_TO_RAD(view*width/height/2))*Far); double sy = 1.0/(tan(DEG_TO_RAD(view/2))*Far); double sz = 1.0/Far; Matrix S = Matrix(sx, 0, 0, 0, 0, sy, 0, 0, 0, 0, sz, 0, 0, 0, 0, 1); return M * S;}
开发者ID:AustinAnderson,项目名称:2048Cubed,代码行数:22,
示例22: DEG_TO_RAD// --[ Method ]---------------------------------------------------------------//// - Class : CMatrix//// - prototype : void BuildRotationZ(float fDegrees)//// - Purpose : Builds a rotation matrix around z axis. Angle in degrees.//// -----------------------------------------------------------------------------void CMatrix::BuildRotationZ(float fDegrees){ float fRad = DEG_TO_RAD(fDegrees); float fSine = sinf(fRad); float fCosine = cosf(fRad); SetIdentity(); m_fM[0][0] = fCosine; m_fM[0][1] = -fSine; m_fM[1][0] = fSine; m_fM[1][1] = fCosine;}
开发者ID:fernandojsg,项目名称:sgzsourcepack,代码行数:22,
示例23: createVehiclestatic void createVehicle( Vector2 pos, Color clr ){ SteeringVehicle v; v.pos = pos; v.vel = vec2( 0.0f, 0.0f ); v.maxSpeed = 200.0f; v.rotRad = 0.0f; v.rotSpdRad = DEG_TO_RAD( 0.0f ); v.maxRotSpeedRad = DEG_TO_RAD( 720.0f ); v.linearAccel = VEC2_ZERO; v.angularAccelRad = 0.0f; v.radius = 10.0f; v.clr = clr; v.wanderTarget = pos; sb_Push( sbVehicles, v );}
开发者ID:JesseRahikainen,项目名称:Xturos,代码行数:22,
示例24: glClearColorvoid TaskCubeMap::update( void ){ glClearColor( 0.2f, 0.2f, 0.2f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); const horizon::input::PadState& pad = horizon::input::getPadState( 0 ); if( pad.stick.right.y != 0.0f ) { mCamera.rotation().x -= DEG_TO_RAD( pad.stick.right.y ); } if( pad.stick.right.x != 0.0f ) { mCamera.rotation().y -= DEG_TO_RAD( pad.stick.right.x ); } glm::vec4 direction( -pad.stick.left.x, 0.0f, - pad.stick.left.y, 0.0f ); glm::mat4 identityMtx( 1.0f ); direction = glm::rotate( identityMtx, mCamera.rotation().x, GLM_X_AXIS ) * direction; direction = glm::rotate( identityMtx, mCamera.rotation().y, GLM_Y_AXIS ) * direction; mCamera.position().x += direction.x; mCamera.position().y += direction.y; mCamera.position().z += direction.z; mCamera.apply(); mCubeMap.useProgram(); mCubeMap.bindTexture( 0, mTextureCubeChapel ); mCubeMap.getProgram().setUniform( "SkyBox", 1 ); mSkyBox.draw(); glClear( GL_DEPTH_BUFFER_BIT ); mCubeMap.getProgram().setUniform( "SkyBox", 0 ); mSphere.draw(); mShader_PresentNormal.useProgram(); mSphere.draw();}
开发者ID:devgoeson,项目名称:sandbox,代码行数:39,
|