Exemple #1
0
int main(int argc, char* argv[])
{
    double* vec;
    vec = new double [(argc-1)];

    for (int i = 1; i<argc; i++)
    {
        vec[i-1] = atof(argv[i]);
    } 
    
    std::cout << "2-norm of vector is " << p_norm(vec, (argc-1)) << std::endl;
    
    delete[] vec;

    return 0;
}
Exemple #2
0
void draw_ellipse_p(double x0, double y0, double xr, double yr, double p, char c) {
	if ((xr <= 0) || (yr <= 0) || (p <= 0)) {
		return;
	}
	
	int rect_x0 = (int) round(x0 - xr);
	int rect_y0 = (int) round(y0 - yr);
	int rect_x1 = (int) round(x0 + xr + 1);
	int rect_y1 = (int) round(y0 + yr + 1);
	
	for (int y = rect_y0; y < rect_y1; y++) {
		for (int x = rect_x0; x < rect_x1; x++) {
			if (p_norm((x - x0) / xr, (y - y0) / yr, p) <= 1) {
				draw_char(x, y, c);
			}
		}
	}
}
Exemple #3
0
void draw_ellipse_p( double x0, double y0, double xr, double yr, double p, char ch )
{
	if ( xr > 0 && yr > 0 && p > 0 )
	{
		for ( int i = 0; i < screen_width(); i++ )
		{
			for ( int j = 0; j < screen_height(); j++ )
			{
				double x = ( i - x0 ) / xr;
				double y = ( j - y0 ) / yr;
				double inEllipse = p_norm( x, y, p );
			
				if ( inEllipse <= 1 )
				{
					draw_char( i, j, ch );
				}
			}
		}
	}
}
Exemple #4
0
bool inside_ellipse(int x, int y, int x0, int y0, int xr, int yr, double p) {
	return (p_norm((((double) x) - x0) / xr, (((double) y) - y0) / yr, p) <= 1);
}