コード例 #1
0
void Precompute_Patch_Values(BICUBIC_PATCH *Shape)
{
  int i, j;
  VECTOR Control_Points[16];
  VECTOR(*Patch_Ptr)[4][4] = (VECTOR(*)[4][4]) Shape->Control_Points;
  int max_depth_reached = 0;

  /* Calculate the bounding sphere for the entire patch. */

  for (i = 0; i < 4; i++)
  {
    for (j = 0; j < 4; j++)
    {
      Assign_Vector(Control_Points[4*i + j], Shape->Control_Points[i][j]);
    }
  }

  find_average(16, Control_Points, Shape->Bounding_Sphere_Center, &Shape->Bounding_Sphere_Radius);

  if (Shape->Patch_Type == 1)
  {
    if (Shape->Node_Tree != NULL)
    {
      bezier_tree_deleter(Shape->Node_Tree);
    }

    Shape->Node_Tree = bezier_tree_builder(Shape, Patch_Ptr, 0.0, 1.0, 0.0, 1.0, 0, max_depth_reached);
  }
}
コード例 #2
0
int main()
{

	first = last = NULL;

	int i;
	for (i = 0; i < 100000; i++)
		insert(rand()%10000);

	struct node* n = first;
	for (i = 0; i < 10; i++)
	{
		printf("%2d. %7d %7d times\n", i+1, n->num, n->f);
		n = n->next;
	}

	find_average();

}
コード例 #3
0
ファイル: pack40.c プロジェクト: byung01/arith
 * initialize bitWord - takes in a 2 x 2 block of CV structs and converts it
 *                      into a bitWord struct
 */
static bitWord initialize_bitWord(UArray_T block)
{
        bitWord word = malloc(sizeof(*word));
        word = set_chroma_index(block, word);
        word = cosine_transform(block, word);
        return word;
}

static bitWord set_chroma_index(UArray_T block, bitWord word)
{
        Average average = {.Pba = 0.0, .Pra = 0.0};

        average = find_average(block, average);

        unsigned Pba_chroma = Arith40_index_of_chroma(average.Pba);
        unsigned Pra_chroma = Arith40_index_of_chroma(average.Pra);
        
        word->Pba = Pba_chroma;
        word->Pra = Pra_chroma;

        return word;
}

static Average find_average(UArray_T block, Average average)
{
        for (int i = 0; i < UArray_length(block); i++) {
                CV temp = (CV)UArray_at(block, i);
                (average.Pba) += temp->Pb;