Helpers.h

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
1.1 kB
1
Indexable
Never
#ifndef HELPERS_H
#define HELPERS_H

#include "Star.h"
#include <vector>
#include <math.h>
#include <queue>
// If you want to add any helper classes,
// here's some space to do it in.

// KD Tree attempt

class kdTree {
public:
    struct Node {
        float points[3];
        Node* left;
        Node* right;
        int id;
        Node(int i, float x, float y, float z) {
            points[0] = x;
            points[1] = y;
            points[2] = z;
            id = i;
            left = nullptr;
            right = nullptr;
        };
        float dist;
    };

    kdTree();
    ~kdTree();
    void insert(float x, float y, float z, int i);
    std::vector<Star> nNearest(float x, float y, float z, int n);
    

private:
    // Varibs
    Node* root;
    size_t hSize;
    // Functios
    template<typename compare> void searchHelp(Node* root, float coords[], int depth, std::priority_queue<Star, std::vector<Star>, compare> *heap);
    Node* insertHelp(Node* curr, float coords[], int depth, int id);
};



#endif