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


C++ DEG_TO_RAD函数代码示例

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


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

示例1: left_end

static gfloat
left_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,代码来源:color-rotate.c

示例2: ProcessVectorTrackLinear

void 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,代码来源:CCamera.cpp

示例3: sg_camera_rotate_hat

void
sg_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,代码来源:camera.c

示例4: ooGeoEllipseAreaSeg

OOellipse* 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,代码来源:ellipse.c

示例5: entityWait

static 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,代码来源:skull.c

示例6: swing

static 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,代码来源:skull.c

示例7: shudder

static 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,代码来源:large_book.c

示例8: calc_dist_to_waypoint

// Returns the distance (in meters) to the current waypoint
static 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,代码来源:kintobor.c

示例9: hover

static 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,代码来源:sorceror_2.c

示例10: hover

static 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,代码来源:ghost.c

示例11: hover

static 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,代码来源:sorceror_dark_summoner.c

示例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,代码来源:snaps.cpp

示例13: DEG_TO_RAD

Quaternion 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,代码来源:quaternion.cpp

示例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,代码来源:Matrix.cpp

示例15: polar_to_rect

Rect_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,代码来源:Ex3.c


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