GSDP:GAM100/CProcessing/CP Vector CrossProduct()

From Inside
Jump to: navigation, search

CP_Vector_CrossProduct()

Description

Returns the magnitude(length) of the cross product of two GSDP:GAM100/CProcessing/CP_Vectors as a float.

Parameters

CP_Vector_CrossProduct(CP_Vector a, CP_Vector b)

  • a - (CP_Vector) - First vector in calculation
  • b - (CP_Vector) - Second vector in calculation

Example

CP_Vector vector1;
CP_Vector vector2;
float cross1;
float cross2;

void init()
{
  vector1 = CP_Vector_Set(CP_Random_RangeFloat(0.0f, 50.0f), CP_Random_RangeFloat(0.0f, 50.0f));
  vector2 = CP_Vector_Set(CP_Random_RangeFloat(0.0f, 50.0f), CP_Random_RangeFloat(0.0f, 50.0f));

  cross1 = CP_Vector_CrossProduct(vector1, vector2);
  cross2 = CP_Vector_CrossProduct(vector2, vector1);

  CP_Font_SetFont(CP_Font_GetDefault());
  CP_Settings_Fill(CP_Color_Create(0, 0, 0, 255));
}

void update()
{
  // Print out the randomly generated vectors
  char vec_text[128] = { 0 };
  sprintf_s(vec_text, 128, "1st Vector: [%.2f, %.2f]", vector1.x, vector1.y);
  CP_Font_DrawText(vec_text, 0, 50);
  sprintf_s(vec_text, 128, "2st Vector: [%.2f, %.2f]", vector2.x, vector2.y);
  CP_Font_DrawText(vec_text, 0, 100);

  // Print out the first cross product
  sprintf_s(vec_text, 128, "Cross 1x2: %.2f", cross1);
  CP_Font_DrawText(vec_text, 0, 150);

  // Print out the second cross product
  sprintf_s(vec_text, 128, "Cross 2x1: %.2f", cross2);
  CP_Font_DrawText(vec_text, 0, 200);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>