Commit 7afa464f authored by Sabrina Templeton's avatar Sabrina Templeton
Browse files

radius of security now functional

parent 801a6a02
......@@ -305,6 +305,7 @@ main() {
// this will obviously change once we are actually fetching from the nearest neighbor instead of the seed
float d = 0;
for (int i = 1; i < u_nb_neighbors; i ++){
//works when i < 2 but not otherwise
//vec3 nn0 = vec3(texelFetch( seeds, i).xy, 0);
......@@ -313,37 +314,46 @@ main() {
//int nn0 = neighbor_hardcoded[i + (gl_PrimitiveIDIn * 7)];//int(texelFetch( nn, i + (gl_PrimitiveIDIn * 7)).x); // i + (gl_PrimitiveIDIn * 7) // remember that this is just the index, we have to use this to lookup in seeds
vec3 nearest_neighbor = vec3(texelFetch( seeds, nn0).xy, 0);
float d1 = d;
d = distance(nearest_neighbor, p0);
// This is a test to make sure that nearest neighbors are sorted in increaasing order. it passes
// if (d1 > d) {
// render_square(vec3(0, 1, 0), .5);
// }
calc_poly(p0, nearest_neighbor, curr_poly, space);
//calculate radius of security
float radius = 0;
vec3 furthest_pt;
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);
radius = distance(curr_pt, p0);
furthest_pt = curr_pt;
}
}
//render_square(furthest_pt, .02);
// if (gl_PrimitiveIDIn == 0){
// if (radius < .26) {
// if (radius > .1) {
// render_square(vec3(1, 1, 0), .1);
// }
// }
// }
// render_square(furthest_pt, i * .001);
// }
// if (radius != distance(furthest_pt, p0)){
// render_square(vec3(0, 0, 0), .5);
// };
if (distance(nearest_neighbor, p0) > (2.1 * radius)){
//render_square(vec3(0, 0, 0), .1);
break;
}
}
//if (gl_PrimitiveIDIn == 0) {
render_poly(curr_poly, p0, space);
//}
//render_square(p0, .03);
......
......@@ -82,17 +82,29 @@ 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 ++){
double val = double(rand()) / double(RAND_MAX);
seeds.push_back(val );
if ((i - 2) % 3 == 0){
seeds.push_back(0.0); // make the z coordinate 0
//std::cout << i << std::endl;
}
else {
//std::cout << i << std::endl;
seeds.push_back(val);
}
//std::cout << seeds[i] << std::endl;
//printf("loop ran, %d point added", i);
};
//std::cout << "Test Print!!!!!!!!!!!!!";
//cout << seeds;
//*/ //uncomment this to restore to random
// std::vector<graphics::gl_float> seeds = { // test case 1
// 0.25, 0.5 , 0.0,
......@@ -132,7 +144,7 @@ UT_TEST_CASE( test1 )
nns->set_points( num_points , seeds_d.data() );
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
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