Commit 801a6a02 authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

still bug hunting in radius of security theorem

parent 9562e6e7
......@@ -120,6 +120,7 @@ void render_square(vec3 pt, float size) {
}
float dist(vec3 a, vec3 b){
//return length(b -a);
float comp1 = pow(b.x - a.x, 2);
float comp2 = pow(b.y - a.y, 2);
return comp1 + comp2;
......@@ -304,7 +305,7 @@ main() {
// this will obviously change once we are actually fetching from the nearest neighbor instead of the seed
for (int i = 1; i < u_nb_neighbors; i ++){//super hardcoded for now
for (int i = 1; i < u_nb_neighbors; i ++){
//works when i < 2 but not otherwise
//vec3 nn0 = vec3(texelFetch( seeds, i).xy, 0);
int nn0 = int(texelFetch( nn, i + (gl_PrimitiveIDIn * u_nb_neighbors)).x); // i + (gl_PrimitiveIDIn * 7)
......@@ -316,13 +317,33 @@ main() {
calc_poly(p0, nearest_neighbor, curr_poly, space);
//calculate radius of security
float radius = 0;
for (int j = 0; j < space; j++ ) {
vec3 curr_pt = curr_poly[j];
//render_square(curr_pt, .01);
if(distance(curr_pt, p0) > radius) {
radius = distance(curr_pt,p0);
}
}
// if (gl_PrimitiveIDIn == 0){
// if (radius < .26) {
// if (radius > .1) {
// render_square(vec3(1, 1, 0), .1);
// }
// }
// }
if (distance(nearest_neighbor, p0) > (2.1 * radius)){
//render_square(vec3(0, 0, 0), .1);
break;
}
}
//if (space == 5){
render_poly(curr_poly, p0, space);
//}
//render_square(p0, .03);
......
......@@ -25,9 +25,9 @@ UT_TEST_SUITE( voronoi_toy )
// set up the view
int width = 500, height = width;
graphics::vec3 eye = {0,0,3};
graphics::vec3 eye = {0.5,0.5,2.0};
graphics::vec3 up = {0,1,0};
graphics::vec3 center = {0.0,0.0,0.0};
graphics::vec3 center = {0.5,0.5,0.0};
float fov = M_PI/4.0;
float aspect = width/height;
......@@ -82,13 +82,15 @@ UT_TEST_CASE( test1 )
// /* uncomment this to restore to random
// uncomment this to restore to random
std::vector<graphics::gl_float> seeds;
srand (time(NULL));
for (int i = 0; i < size; i ++){
seeds.push_back(rand() % 100 * .01 );
double val = double(rand()) / double(RAND_MAX);
seeds.push_back(val );
//printf("loop ran, %d point added", i);
};
//*/ //uncomment this to restore to random
......@@ -130,7 +132,7 @@ UT_TEST_CASE( test1 )
nns->set_points( num_points , seeds_d.data() );
index_t nb_neighbors =100; // since there are only seven points right now, this number will probably be more like 50 later
index_t nb_neighbors =index_t(num_points); // since there are only seven points right now, this number will probably be more like 50 later
std::vector<index_t> neighbors(nb_neighbors);
std::vector<index_t> total_neighbors(nb_neighbors * num_points); // i don't know if this is the correct number if, for example, nb points and nb neighbors are not the same (which they usually will not be)
std::vector<double> neighbors_sq_dist(nb_neighbors);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment