[Solved] Structured Data: Nesting Triangles using structs and calculating


I think what you’re trying to do is this:

float cal_area(triangle aTriangle) {
   float Area;

   Area = (aTriangle.vertices[1].x - aTriangle.vertices[0].x) *
          (aTriangle.vertices[2].y - aTriangle.vertices[1].y) -
          (aTriangle.vertices[1].y - aTriangle.vertices[0].y) *
          (aTriangle.vertices[2].x - aTriangle.vertices[1].x);

   if (Area < 0.0f) {
      return -Area / 2.0f;
   } else {
      return Area / 2.0f;
   }
}

solved Structured Data: Nesting Triangles using structs and calculating