Ejemplo n.º 1
0
void dtObstacleAvoidanceDebugData::normalizeSamples()
{
	normalizeArray(m_pen, m_nsamples);
	normalizeArray(m_vpen, m_nsamples);
	normalizeArray(m_vcpen, m_nsamples);
	normalizeArray(m_spen, m_nsamples);
	normalizeArray(m_tpen, m_nsamples);
}
Ejemplo n.º 2
0
void MyDeformObject::getInterpolateData()
{
    for (int i = 0; i < number_element; ++i)
    {
        MyTriangle triangle;
        int first_point = p_data_element[i][0];
        int secnd_point = p_data_element[i][1];
        int third_point = p_data_element[i][2];

        double first_coor_x = p_data_point[first_point][0];
        double first_coor_y = p_data_point[first_point][1];
        double secnd_coor_x = p_data_point[secnd_point][0];
        double secnd_coor_y = p_data_point[secnd_point][1];
        double third_coor_x = p_data_point[third_point][0];
        double third_coor_y = p_data_point[third_point][1];

        double x_tmp = getSourceCoordinX(first_coor_x, first_coor_y);
        double y_tmp = getSourceCoordinY(first_coor_x, first_coor_y);
        double one_intensy = bright.getIntensety(((x_tmp) / 2.0), ((y_tmp) / 2.0));

        x_tmp = getSourceCoordinX(secnd_coor_x, secnd_coor_y);
        y_tmp = getSourceCoordinY(secnd_coor_x, secnd_coor_y);
        double two_intensy = bright.getIntensety(((x_tmp) / 2.0), ((y_tmp) / 2.0));

        x_tmp = getSourceCoordinX(third_coor_x, third_coor_y);
        y_tmp = getSourceCoordinY(third_coor_x, third_coor_y);
        double tre_intensy = bright.getIntensety(((x_tmp) / 2.0), ((y_tmp) / 2.0));

        triangle.setCoordinate(first_coor_x, first_coor_y, secnd_coor_x, secnd_coor_y, third_coor_x, third_coor_y);
        triangle.setIntensy(one_intensy, two_intensy, tre_intensy);
        triangle.initialization();
        int tmp_y_min = floor (((triangle.y_min * (double)y_pic_deform)) / 2.0);
        int tmp_y_max = floor (((triangle.y_max * (double)y_pic_deform)) / 2.0);
        int tmp_x_min = floor (((triangle.x_min * (double)x_pic_deform)) / 2.6);
        int tmp_x_max = floor (((triangle.x_max * (double)x_pic_deform)) / 2.6);
        for (int y = tmp_y_min; y <= tmp_y_max; ++y)
        {
            for (int x =  tmp_x_min; x <= tmp_x_max; ++x)
            {
                double x_norm = ((x_dfrm_size * x) / (x_pic_deform - 1.0));
                double y_norm = ((y_src_size * y) / (y_pic_deform - 1.0));

                bool check = triangle.isContainPoint(x_norm, y_norm);
                if (check)
                {
                    p_interpolate_intensy[y * x_pic_deform + x] = triangle.getBright(x_norm, y_norm);//((x_tmp) / 2.0), ((y_tmp) / 2.0));
                }
                else
                {
                    //p_real_instansy[y * x_pic + x] = 0.0;
                }
            }
        }
    }
    normalizeArray(p_interpolate_intensy, (x_pic_deform * y_pic_deform));
}
Ejemplo n.º 3
0
void MyDeformObject::getSourceData()
{
    for (int y = 0; y < x_pic_source; ++y)
    {
        for (int x = 0; x < y_pic_source; ++x)
        {
            p_source_intensy[y * x_pic_source + x] = bright.getIntensety(((double)x / (x_pic_source - 1)), ((double)y / (y_pic_source - 1)));
        }
    }
    normalizeArray(p_source_intensy, (x_pic_source * y_pic_source));
}
Ejemplo n.º 4
0
int main() {
	std::cout << "Hello world! This is a test program for outputting a gradient to a PPM image file." << std::endl;

	srand(time(NULL));
	initGradient();

	char *memblock;

	std::ofstream output;
	output.open("image.ppm", std::ios::binary);
	if (output.is_open())
	{
		output << "P5\n" << img_width << " " << img_height << "\n" << 255 << "\n";

		int size = img_width * img_height;
		memblock = new char[size];

		for (int y = 0; y < img_height; ++y)
		{
			for (int x = 0; x < img_width; ++x)
			{
				getValue(Vector2(x, y));
			}
		}

		normalizeArray();

		for (int y = 0; y < img_height; ++y)
		{
			for (int x = 0; x < img_width; ++x)
			{
				std::cout << ImagePoints[x][y] << "\n";
			}
		}

		for (int y = 0; y < img_height; ++y)
		{
			for (int x = 0; x < img_width; ++x)
			{
				memblock[(y * img_width) + x] = ImagePoints[x][y];
			}
		}

		output.write(memblock, size);
	}
	else
	{
		std::cout << "Error opening file" << std::endl;
	}
	output.close();
	return 0;
}
Ejemplo n.º 5
0
void MyDeformObject::getAnalyticalData()
{
    for (int y = 0; y < y_pic_deform ; ++y)
    {
        for (int x = 0; x < x_pic_deform; ++x)
        {
            double x_norm = ((x_dfrm_size * x) / (x_pic_deform - 1.0));
            double y_norm = ((y_src_size * y) / (y_pic_deform - 1.0));
            double x_tmp = getSourceCoordinX(x_norm, y_norm);
            double y_tmp = getSourceCoordinY(x_norm, y_norm);
            if (y_tmp > 0.0 && y_tmp < y_src_size)
            {
                p_analytic_intensy[y * x_pic_deform + x] = bright.getIntensety(((x_tmp) / 2.0), ((y_tmp) / 2.0));
            }
            else
            {
                p_analytic_intensy[y * x_pic_deform + x] = 0.0;
            }
        }
    }
    normalizeArray(p_analytic_intensy, (x_pic_deform * y_pic_deform));
}