コード例 #1
0
ファイル: Selector.cpp プロジェクト: makouski/NtuplePlotter
void Selector::process_objects(const EventTree* inp_tree){
	tree = inp_tree;
	clear_vectors();
	filter_photons();
	filter_electrons();
	filter_muons();
	filter_jets();
}
コード例 #2
0
// Generate the vertex coordinates of shapes into vectors,
// these will be read by the program to produce the shapes.
void ShapeGenerator::generateDisc(int radius, int triangle_number)
{
	int loop = 0;
	float theta = 0;
	float x, y, u, v;

	//Check if the shape has been generated before, if it has then skip calculating and don't clean the containers.
	if (radius == old_disc_radius)
	{
		if (triangle_number == old_disc_triangle_number) //Same parameters means same shape, so skip calculating.
		{
			//Do nothing, exit the calculation function.
			return;
		}
	}

	//If the program hasn't exited the function that means we need to generate a new shape.
	clear_vectors(Disc);

	if (triangle_number < 3)
		triangle_number = 3;

	theta = (2*PI)/triangle_number;
	old_disc_radius = radius;
	old_disc_triangle_number = triangle_number;

	//Generate Triangles.
	//Origin Coordinates.
	Disc_vertices_X.push_back(0);
	Disc_vertices_Y.push_back(0);

	Disc_texture_U.push_back(0);
	Disc_texture_V.push_back(0);

	//TriangleFan vertices.
	int vertices_number = triangle_number * 2;
	for (int i = 0; i < vertices_number ; i++)
	{
		x = radius * cos(theta*loop);
		Disc_vertices_X.push_back(x);
		y = radius * sin(theta*loop);
		Disc_vertices_Y.push_back(y);

		u = x / (radius*2);
		Disc_texture_U.push_back(u);
		v = y / 2;
		Disc_texture_V.push_back(v);

		loop++;
	}
}
コード例 #3
0
void ShapeGenerator::generateSphere(int radius, int latitude, int longitude)
{
	/*
	Angle of Latitude = Theta
	Angle of longitude = Delta
	*/

	float theta = 0;
	float delta = 0;

	float delta_offset = 0;
	float theta_offset = 0;

	float x, y, z;

	//Check if the shape has been generated before, if it has then skip calculating and don't clean the containers.
	if (radius == old_sphere_radius)
	{
		if (latitude == old_sphere_latitude)
		{
			if (longitude == old_sphere_longitude)
			{
				/*
				If one of the above failed then the shape requested is not the same as the
				previously generated shape. If all the above are correct then the shapes are the same so
				do nothing.
				*/
				return;
			}
		}
	}

	//Generate a new shape as the parameters don't match the old one.
	clear_vectors(Sphere);

	if (latitude < 3)
		latitude = 3;
	if (longitude < 3)
		longitude = 3;

	theta = (2*PI)/longitude;
	delta = (2*PI)/latitude;

	for (int i = 0; i < longitude; i++)
	{
		for (int j = 0; j < latitude/2; j++)
		{
			//Right Top
			x= radius * cos(theta*i) * sin(delta*(j+1));
			y= radius * sin(theta*i) * sin(delta*(j+1));
			z= radius * cos(delta*(j+1));

			Sphere_vertices_X.push_back(x);
			Sphere_vertices_Y.push_back(y);
			Sphere_vertices_Z.push_back(z);

			//Right Bottom
			x= radius * cos(theta*(i+1)) * sin(delta*(j+1));
			y= radius * sin(theta*(i+1)) * sin(delta*(j+1));
			z= radius * cos(delta*(j+1));

			Sphere_vertices_X.push_back(x);
			Sphere_vertices_Y.push_back(y);
			Sphere_vertices_Z.push_back(z);

			//Left Bottom
			x= radius * cos(theta*(i+1)) * sin(delta*j);
			y= radius * sin(theta*(i+1)) * sin(delta*j);
			z= radius * cos(delta*j);

			Sphere_vertices_X.push_back(x);
			Sphere_vertices_Y.push_back(y);
			Sphere_vertices_Z.push_back(z);

			//Left Top
			x= radius * cos(theta*i) * sin(delta*j);
			y= radius * sin(theta*i) * sin(delta*j);
			z= radius * cos(delta*j);

			Sphere_vertices_X.push_back(x);
			Sphere_vertices_Y.push_back(y);
			Sphere_vertices_Z.push_back(z);
		}
	}
}