GSDP:GAM100/CProcessing/CP Math Radians()

CP_Math_Radians()

Description

Takes an input number of degrees as a float, then returns it converted to radians as a float

Parameters

CP_Math_Radians(float degrees)

  • degrees - (float) The number to convert to radians from degrees.

Example

void init()
{
  CP_Settings_EllipseMode(CP_POSITION_CENTER);
  CP_Font_Set(CP_Font_GetDefault(), 30);
  CP_Settings_Fill(CP_Color_Create(0, 0, 0, 255));
}

float r_degrees;
float counter = 2.0f;
void update()
{
  CP_Settings_Background(CP_Color_Create(255, 255, 255, 255));

  // Change degrees every few seconds
  if (counter >= 2.0f)
  {
    r_degrees = CP_Random_RangeFloat(0.0f, 360.0f);
    counter = 0.0f;
  }
  else
    counter += dt();

  // Print out number of degrees and convert to radians
  char buffer[128] = { 0 };
  sprintf_s(buffer, 128, "Degrees: %.3f\nis equal to\nRadians: %.3f", r_degrees, CP_Math_Radians(r_degrees));
  CP_Font_DrawTextBox(buffer, 100, 150, 200);
}

Related