void IntpQdrNonuniform2<Real>::ProcessTriangles ()
{
    // Add degenerate triangles to boundary triangles so that interpolation
    // at the boundary can be treated in the same way as interpolation in
    // the interior.

    // Compute centers of inscribed circles for triangles.
    const Vector2<Real>* vertices = mDT->GetVertices();
    int numTriangles = mDT->GetNumSimplices();
    const int* indices = mDT->GetIndices();
    mTData = new1<TriangleData>(numTriangles);
    int i;
    for (i = 0; i < numTriangles; ++i)
    {
        int v0 = *indices++;
        int v1 = *indices++;
        int v2 = *indices++;
        Circle2<Real> circle;
        Inscribe(vertices[v0], vertices[v1], vertices[v2], circle);
        mTData[i].Center = circle.Center;
    }

    // Compute cross-edge intersections.
    for (i = 0; i < numTriangles; ++i)
    {
        ComputeCrossEdgeIntersections(i);
    }

    // Compute Bezier coefficients.
    for (i = 0; i < numTriangles; ++i)
    {
        ComputeCoefficients(i);
    }
}
Пример #2
0
/* Main method */
int main(int argc, char *argv[]){

	/* Check to make sure there are no additional cmdline args */
	if(argc < 2){

		/* Initialize double values X and Y that will store the point values
		returned from the call to Data Points */
		double X, Y;

		/* Initialize double values A and B that represent the coefficients for
		the line of best fit. Passed into ComputeCoefficients by refence */
		double A, B;

		/* Variable that represents the index of the last element added to Payload  */

		/* Initialize variable for Dynamic Array */
		DArray array;

		/* Call CreateDArray to initialize array */
		CreateDArray(&array, INITIAL_CAPACITY);

		/* Gather X and Y values while DataPoints() supplies values */
		while (DataPoints(&X, &Y)==1){

			/* Initialize Data Object With values from DataPoints function */
			Data point;
			point.X=X;
			point.Y=Y;

			/* Send the data point to the dynamic array */
			PushToDArray(&array, &point);

		}

		/* Compute the coefficients (Stores both A AND B) */
		ComputeCoefficients(&A, &B, &array);

		/* Produce Output */
		printf("\nThe line is: Y = %f * X + %f\n", A, B);
		printf("There were %d points in the data set\n\n", array.EntriesUsed);

		/* Destroy the DArray object, and free associated memory */
		DestroyDArray(&array);

	}else{

		/* Improper amount of cmdline args entered, alert user */
		printf("\nUsage: %s\n\n", argv[0]);

	}
	/* End Cmdline args check */

	/* Return 1 to the operating system */
	return 1;
}
Пример #3
0
YARPGaussianFeatures::YARPGaussianFeatures(int necc, int nang, double rfmin, int size) 
	: YARPFilter(),
	  YARPLogPolar(necc, nang, rfmin, size),
	  m_sigmas(8)
{
	// memalloc.
	m_ro2 = new double[necc];
	assert (m_ro2 != NULL);
	
	m_coeffs = new _YARPG[m_sigmas];
	assert (m_coeffs != NULL);

	for (int j = 0; j < m_sigmas; j++)
	{
		m_coeffs[j].Resize (necc, nang);
	}

	// build arrays for gaussian derivative.
	double tmp;
	for (int i = 0; i < necc; i++)
	{
		tmp = ro0 * pow(a, i/kxi);
		m_ro2[i] = tmp*tmp;
	}

	// loop over sigmas.
	int count;  int i;
	for (i = 1, count = 0; i <= 15; i+=2, count++)
	{
		ComputeCoefficients (double(i), m_coeffs[count]);
	}

	m_features.Resize (m_sigmas * 2);
	m_features = 0;

	FILE *fp = fopen ("pippo.txt", "w");
	assert (fp != NULL);

	for (i = 0; i < m_sigmas; i++)
	{
		for (int j = 0; j < nang; j++)
		{
			for (int k = 0; k < necc; k++)
				fprintf (fp, "%lf ", m_coeffs[i].m_co[j][k]);
			fprintf (fp, "\n");
		}
		fprintf (fp, "\n");
	}

	fclose (fp);
}