//
// Created by martin on 18. 2. 2021.
//

#ifndef ARC_MATRIX_ARCEXTRACTION_H
#define ARC_MATRIX_ARCEXTRACTION_H

#include<iostream>
#include <vector>
#include <cmath>
#include <opencv2/core.hpp>

class ArcVector {
public:
    int x,y;
    ArcVector(const cv::Point2i& x, const cv::Point2i& y);
    ArcVector() = default;

    double scalProd(const ArcVector &other) const;
    double dotProd(const ArcVector &other) const;
    double size() const;
};

struct posArc {
    int index;
    std::vector<cv::Point2i> arc;
};
posArc mkArc(int index,std::vector<cv::Point2i>& arc);


/**
 * calcs signum of a value
 */
int sgn(double val);

std::vector<double> eta(ArcVector k, ArcVector k1, int s);

/**
 * calcs 1/tan(i)
 */
double cot(double i);

/**
 * calcs 1/sin(i)
 */
double csc(double i);

/**
 * equation 3 from the original paper
 * @param e vector containing
 * @param O_arc
 * @return
 */
std::vector<double> eq3(std::vector<double> e, double O_arc);

/**
 * stores points of the extracted arc
 * @param E stores the extracted points
 * @param DP is a DP contour
 * @param k index of first point to be stored
 */
void res(std::vector<cv::Point2i> &E, std::vector<cv::Point2i> &DP, int k);

/**
 * 1. algorithm from the original paper
 * @param DP is a DP contour
 * @param O_arc a Threshold for arc extraction
 * @param L_arc a Threshold for arc extraction
 * @return extracted arcs
 */
std::vector<std::vector<cv::Point2i>> ArcExtract(std::vector<std::vector<cv::Point2i>> &DP, double O_arc, double L_arc);



#endif //ARC_MATRIX_ARCEXTRACTION_H
