/* draw a horizontal line */
void
draw_line(unsigned char *frame, int x1, int y1, int x2, int y2, unsigned char color)
{
    int delta_x =(x2 - x1);
    // if x1 == x2, then it does not matter what we set here
    signed char const ix =((delta_x > 0) - (delta_x < 0));
    delta_x = abs(delta_x) << 1;
    int delta_y =(y2 - y1);
    // if y1 == y2, then it does not matter what we set here
    signed char const iy =((delta_y > 0) - (delta_y < 0));
    delta_y = abs(delta_y) << 1;

    point_xy(frame, x1, y1, 1, color );

    if (delta_x >= delta_y)
    {
        // error may go below zero
        int error= (delta_y - (delta_x >> 1));
        while (x1 != x2)
        {
            if ((error >= 0) && (error || (ix > 0)))
            {
                error -= delta_x;
                y1 += iy;
            }
            // else do nothing
            error += delta_y;
            x1 += ix;
            point_xy(frame, x1, y1, 1, color);
        }
    }
ribi::PlaneZ::Coordinats2D ribi::PlaneZ::CalcProjection(
  const Coordinats3D& points
) const
{
  assert(points.size() >= 3);
  const double x_origin = 0.0;
  const double y_origin = 0.0;
  const double z_origin = CalcZ(x_origin,y_origin);

  Coordinats2D v;
  for (const auto& point: points)
  {
    const Double x(boost::geometry::get<0>(point));
    const Double y(boost::geometry::get<1>(point));
    const Double z(boost::geometry::get<2>(point));
    const Double dx =
      sqrt( //Apfloat does not add the std::
          ((x - x_origin) * (x - x_origin))
        + ((z - z_origin) * (z - z_origin))
      ) * (x - x_origin)
    ;
    const Double dy =
      sqrt( //Apfloat does not add the std::
          ((y - y_origin) * (y - y_origin))
        + ((z - z_origin) * (z - z_origin))
      ) * (y - y_origin)
    ;

    Coordinat2D point_xy(dx,dy);
    v.push_back(point_xy);
  }
  return v;
}