Esempio n. 1
0
void test_arclength(void) {
  function_t *f = function_create("2**x - log(x)");
  ASSERT_EQ(arc_length(f, 0.5, 2.3), 3.0663188081);
  function_destroy(f);

  f = function_create("1/x + sin(x)**0.3");
  ASSERT_EQ(arc_length(f, 0.5, 2.3), 2.4417982309);
  function_destroy(f);

  f = function_create("3.5*x**4 - 30.3*x**3 + 7.2*x**2 - 3.4*x + 32.0");
  ASSERT_EQ(arc_length(f, -5, 7), 8109.52041086);
  function_destroy(f);

  f = function_create("3.5*x**4 - 7.2*x**2 - 3.4*x - 32.0");
  ASSERT_EQ(arc_length(f, -1.5, 0.73), 14.196939434);
  function_destroy(f);
}
Esempio n. 2
0
real circle_arc_length(Nested<const CircleArc> arcs) {
  real total = 0;
  for(const auto contour : arcs) {
    for(int prev_i = contour.size()-1, curr_i = 0; curr_i < contour.size(); prev_i = curr_i++) {
      total += arc_length(contour[prev_i].x, contour[curr_i].x, contour[prev_i].q);
    }
  }
  return total;
}