Example #1
0
/* Draws a freeform scene */
void draw_free_scene(void) {
	int num_indices;
	int i;
	int index1, index2, index3, index4;

	num_indices = sizeof(hypercube_indices) / sizeof(GLuint);
	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glDepthMask(GL_FALSE);

	GLUquadricObj *quad = gluNewQuadric();

	for (i = 0; i < num_indices; i += 4) {

		index1 = hypercube_indices[i] * 3;
		index2 = hypercube_indices[i+1] * 3;
		index3 = hypercube_indices[i+2] * 3;
		index4 = hypercube_indices[i+3] * 3;

		glColor3f( 0.73333333333f, 0.82352941176f, 0.85490196078f);

		draw_rod(quad, &(cube_vertices[index1]), inside, &(cube_vertices[index2]), inside);
		draw_rod(quad, &(cube_vertices[index3]), inside, &(cube_vertices[index4]), inside);

		draw_rod(quad, &(cube_vertices[index1]), inside, &(cube_vertices[index1]), outside);
		draw_rod(quad, &(cube_vertices[index2]), inside, &(cube_vertices[index2]), outside);

		draw_rod(quad, &(cube_vertices[index1]), outside, &(cube_vertices[index2]), outside);
		draw_rod(quad, &(cube_vertices[index3]), outside, &(cube_vertices[index4]), outside);

		draw_rod(quad, &(cube_vertices[index3]), inside, &(cube_vertices[index3]), outside);
		draw_rod(quad, &(cube_vertices[index4]), inside, &(cube_vertices[index4]), outside);

		glBegin(GL_QUADS);
		glColor4f( 0.82352941176f, 0.82352941176f, 0.82352941176f, 0.4f );
		glVertex3f( inside*cube_vertices[index1], inside*cube_vertices[index1+1], inside*cube_vertices[index1+2] );
		glVertex3f( inside*cube_vertices[index2], inside*cube_vertices[index2+1], inside*cube_vertices[index2+2] );
		glVertex3f( inside*cube_vertices[index3], inside*cube_vertices[index3+1], inside*cube_vertices[index3+2] );
		glVertex3f( inside*cube_vertices[index4], inside*cube_vertices[index4+1], inside*cube_vertices[index4+2] );

		glVertex3f( inside*cube_vertices[index1], inside*cube_vertices[index1+1], inside*cube_vertices[index1+2] );
		glVertex3f( inside*cube_vertices[index2], inside*cube_vertices[index2+1], inside*cube_vertices[index2+2] );
		glVertex3f( outside*cube_vertices[index2], outside*cube_vertices[index2+1], outside*cube_vertices[index2+2] );
		glVertex3f( outside*cube_vertices[index1], outside*cube_vertices[index1+1], outside*cube_vertices[index1+2] );

		glVertex3f( inside*cube_vertices[index3], inside*cube_vertices[index3+1], inside*cube_vertices[index3+2] );
		glVertex3f( inside*cube_vertices[index4], inside*cube_vertices[index4+1], inside*cube_vertices[index4+2] );
		glVertex3f( outside*cube_vertices[index4], outside*cube_vertices[index4+1], outside*cube_vertices[index4+2] );
		glVertex3f( outside*cube_vertices[index3], outside*cube_vertices[index3+1], outside*cube_vertices[index3+2] );
		glEnd();

	}
}
  void rose_of_directions::compute_from_acf_in(std::vector<float>& rose_vec, const image_t& image) {
    rose_vec.clear();
    rose_vec.resize(180);
    int width  = image.size().width;
    int height = image.size().height; 
    int D0 = (width<height) ? width / 2 - 1 : height / 2 - 1;
    int d0 = D0 / 10;
    float PI = 3.14159f;
    for (int theta = 0; theta < 180; ++theta) {
      rose_vec[theta] = 0.0f;
      for (int r = d0; r < D0; ++r) {
	float x = 0.5f * float(width)  + float(r) * std::sin(PI*float(theta)/180.0f);
	float y = 0.5f * float(height) - float(r) * std::cos(PI*float(theta)/180.0f);
	rose_vec[theta] += image.at<float>(int(y),int(x));
      }
    }
    if (debug_flag_) { draw_rod(rose_vec); }
  }