Пример #1
0
void AssimpScene::get_data(
	float * arr_vertex, int arr_vertex_length, 
	float * arr_normal, int arr_normal_length, 
	int * arr_indices, int arr_indices_length, 
	int & store_num_arr, int & store_num_arr_indices)
{
	store_num_arr = 0;
	store_num_arr_indices = 0;
	uncompress_recursive(this->scene->mRootNode,
		arr_vertex, arr_vertex_length, store_num_arr,
		arr_normal, arr_normal_length,
		arr_indices, arr_indices_length, store_num_arr_indices);
	update_center(arr_vertex, store_num_arr, sceneMin, sceneMax,sceneCenter);
	rescale_verts(arr_vertex, store_num_arr);


	/*
	{
		for (int i = 0; i < store_num_vertex / 3; i++) {
			std::cout << "POS : " << arr_vertex[i * 3 + 0] << " " << arr_vertex[i * 3 + 1] <<" " << arr_vertex[i * 3 + 2] << std::endl;
			std::cout << "NOR : " << arr_normal[i * 3 + 0] << " " << arr_normal[i * 3 + 1] << " " <<arr_normal[i * 3 + 2] << std::endl;
		}
		for (int i = 0; i < store_num_faces/3; i++) {
			std::cout << "indices : " << arr_indices[i * 3 + 0] << " " << arr_indices[i * 3 + 1] << " "<< arr_indices[i * 3 + 2] << std::endl;
		}
	}
	*/
}
Пример #2
0
void compute_cluster_centers(Dataset* dataset, Centroid** centroids){
//    Datapoint* random_point = dataset->points[rand() % dataset->size];
    for (size_t i = 0; i < dataset->size; i++) {
        Centroid* closest_centroid = find_closest(centroids, dataset->points[i]);
        update_center(dataset, closest_centroid);
    }
    scramble_dataset(dataset);
}
Пример #3
0
void transport(GLfloat x, GLfloat y, GLfloat z){
	GLfloat M[4][4] = {0};
	for(int i = 0; i < 4; ++i)
		M[i][i] = 1;
	M[0][3] = x;
	M[1][3] = y;
	M[2][3] = z;

	GLfloat I[4][4] = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
	multiMatrix(geoMatrix[now], M, geoMatrix[now]);
	multiple_all_matrix(M);
	update_center(M);
}
Пример #4
0
double kmeans::update_centers(const cluster_sequence & clusters, dataset & centers) {
    const dataset & data = *m_ptr_data;
    const size_t dimension = data[0].size();

    dataset calculated_clusters(clusters.size(), point(dimension, 0.0));
    std::vector<double> changes(clusters.size(), 0.0);

    parallel_for(std::size_t(0), clusters.size(), [this, &clusters, &centers, &calculated_clusters, &changes](const std::size_t p_index) {
        calculated_clusters[p_index] = centers[p_index];
        changes[p_index] = update_center(clusters[p_index], calculated_clusters[p_index]);
    });

    centers = std::move(calculated_clusters);

    return *(std::max_element(changes.begin(), changes.end()));
}
void cluster()
{
	int x;				/* Goes through all the center points */
	int i;				/* Goes through all data points */
	double distance;		/* Gives the distance between the data points based on the metric */
	double min_distance=INT_MAX;	/* This will tell us which cluster to add it to */
	for(i=0;i<n;i++)	
	{
		min_distance=INT_MAX;
		for(x=0;x<no_of_clusters;x++)
		{
			distance=Euclidian_metric(center_array[x],data[i]);
			
			if(distance < min_distance)
			{
				min_distance=distance;
				output[i]=x;			/* Updates the cluster data point i belongs to  */
			}		
		}
		update_center(output[i],i);
	}
}