Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComputeModel function implementation in Line #5

Open
jiayily opened this issue Apr 12, 2021 · 1 comment
Open

ComputeModel function implementation in Line #5

jiayily opened this issue Apr 12, 2021 · 1 comment

Comments

@jiayily
Copy link

jiayily commented Apr 12, 2021

Hi, the line parameters solving in your code involves eigenvalues. Can you show me a formula derivation about this implementation. I tried to do it by myself but failed. Thank you so much.

@DavidHernandezLopez
Copy link

I think there is a bug.
virtual Line ComputeModel(const std::vector& data, const std::set& samples)
when not if (fabs(b) > DBL_EPSILON)
a and b coefficients for lines in x and y axis solved by:

        double maxDiffX=0.;
        double maxDiffY=0.;
        for(int np=0;np<(data.size()-1);np++)
        {
            double diffX=fabs(data[np+1].x-data[np].x);
            if(diffX>maxDiffX) maxDiffX=diffX;
            double diffY=fabs(data[np+1].y-data[np].y);
            if(diffY>maxDiffY) maxDiffY=diffY;
        }
        if(maxDiffX<maxDiffY)
        {
            line.a = 1;
            line.b = 0;
        }
        else
        {
            line.a = 0;
            line.b = 1;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants