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

How to calculate octagon points in fine resolutions grids? #254

Open
mycool666 opened this issue Mar 5, 2022 · 0 comments
Open

How to calculate octagon points in fine resolutions grids? #254

mycool666 opened this issue Mar 5, 2022 · 0 comments

Comments

@mycool666
Copy link

mycool666 commented Mar 5, 2022

Hi,
I don't understand the principle of calculating octagon points in fine resolutions grids.Can you tell me where this computing idea comes from or some documents that I can refer to?Here is a code snippet:

    ux = points->array[index*3+0];
    uy = points->array[index*3+1];
    uz = points->array[index*3+2];

    x1 = points->array[iPointMin*3+0];
    y1 = points->array[iPointMin*3+1];
    z1 = points->array[iPointMin*3+2];

    dot = (ux*x1) + (uy*y1) + (uz*z1);

    x0 = ux + x1 - dot * ux;
    y0 = uy + y1 - dot * uy;
    z0 = uz + z1 - dot * uz;

    /*
    tx = ux - x0;
    ty = uy - y0;
    tz = uz - z0;

    tx *= 0.75f;
    ty *= 0.75f;
    tz *= 0.75f;

    x0 = ux - tx;
    y0 = uy - ty;
    z0 = uz - tz;
    */

    nAngles = 8;

    points_octo = points_construct_zero(nAngles);

    for (iAngle = 0; iAngle < nAngles; iAngle++) {

        theta = 2*M_PI * ((float) iAngle) / ((float) nAngles);

        R11 = cosf(theta) + (ux*ux) * (1.0f - cosf(theta));
        R12 = (ux*uy) * (1.0f - cosf(theta)) - uz * sinf(theta);
        R13 = (ux*uz) * (1.0f - cosf(theta)) + uy * sinf(theta);
        R21 = (uy*ux) * (1.0f - cosf(theta)) + uz * sinf(theta);
        R22 = cosf(theta) + (uy*uy) * (1.0f - cosf(theta));
        R23 = (uy*uz) * (1.0f - cosf(theta)) - ux * sinf(theta);
        R31 = (uz*ux) * (1.0f - cosf(theta)) - uy * sinf(theta);
        R32 = (uz*uy) * (1.0f - cosf(theta)) + ux * sinf(theta);
        R33 = cosf(theta) + (uz*uz) * (1.0f - cosf(theta));

        xR = R11 * x0 + R12 * y0 + R13 * z0;
        yR = R21 * x0 + R22 * y0 + R23 * z0;
        zR = R31 * x0 + R32 * y0 + R33 * z0;

        norm = sqrtf(xR*xR + yR*yR + zR*zR);

        xR /= norm;
        yR /= norm;
        zR /= norm;

        points_octo->array[iAngle*3+0] = xR;
        points_octo->array[iAngle*3+1] = yR;
        points_octo->array[iAngle*3+2] = zR;

    }

Many thanks!
Best regards,
mycool666

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

1 participant