Like Tree2Likes
  • 2 Post By nonoob

Can somebody pls help me with project?

This is a discussion on Can somebody pls help me with project? within the C Programming forums, part of the General Programming Boards category; Hi, i'm a complete newbie in c , but unfortunately i've beed told to do a project for my classes ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    15

    Can somebody pls help me with project?

    Hi, i'm a complete newbie in c , but unfortunately i've beed told to do a project for my classes and i completely don't know how to start it or programme it ... It goes like this: generate random set of n points in 2D carthesian coords system. then find ellipse enveloping all points which area is greatest. and the last is to prepare a graph in excel :P I hope someone could help me, greetings

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    1,103
    To start you need to break it down, it sounds like three parts. 1. Generate n points. 2. Find the ellipse. 3. Plot in excel.

    1. A point in 2D space is just two numbers (x,y). So if you want n points, generate 2n numbers. Use rand and srand.
    2. To find the ellipse, it's best to review equations for representing ellipses and then find one that meets the stated criteria (to maximize the area?).
    3. To plot in programs like Excel, you can normally output your information in tabular form and then just import it into the program.

  3. #3
    Registered User loserone+_+'s Avatar
    Join Date
    Dec 2012
    Location
    Indonesia
    Posts
    112
    what do u mean by ellipse?

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by loserone+_+ View Post
    what do u mean by ellipse?
    An ellipse is an egg shape.

    I don't know how you can have random numbers form the ellipse, however.

    We need a more thorough description - an example would help, certainly.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    An ellipse can certainly enclose a set of random points. The trick is to find one that minimally uses up area... But the question states "which area is greatest" - which makes less sense.
    stahta01 and AndiPersti like this.

  6. #6
    Registered User
    Join Date
    Jan 2013
    Posts
    15
    Okay, i finished first step, i wonder if it's good :P anyways it's working ... about the area i personally think that it would be the best to find 2 points with the biggest distance and make them be the part of the ellipse and other points would be inside.. but i don't know if i'm not wrong. That's what i have for now.

    Code:
    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    
    
    
    
    void main()
    {
    	srand( (unsigned) time(NULL));
    
    
    	int x,y;
    	double x_min = -100;
    	double x_max = 100;
    	double y_min = -100;
    	double y_max = 100;
    	int i,n;
    	int lp=0;
    
    
    	printf("Input the number of points:\n");
    	scanf(" %ld",&n);
    
    
    	for(i = 0; i<n; i++)
    	{
    		x = rand() * (x_max - x_min) / (double) RAND_MAX + x_min;
    		y = rand() * (y_max - y_min) / (double) RAND_MAX + y_min;
    		printf("\n(%ld;%ld)",x,y);
    	}
    	return x,y;
    
    
    }

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    You’re on the right track.
    The coordinates should be saved in some array too... so that the ellipse calculation has something to work with.

    The ellipse may not be aligned horizontally or vertically but rather at some angle. Unless the problem domain restricts it. That's what makes it complicated to solve.
    I just looked it up myself - and I highly doubt your teacher expects you to invent a new algorithm for this. Copying an existing solution would not teach you much either... so I wonder if your teacher knows exactly what they expect from the students.

    Making a circle enclose all coordinates is difficult enough.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C project
    By Ellondu in forum C Programming
    Replies: 2
    Last Post: 04-19-2012, 09:40 PM
  2. Classes Project (Not class project)
    By adam.morin in forum C++ Programming
    Replies: 3
    Last Post: 02-28-2011, 12:48 AM
  3. Paid project - The Free Marketing Project
    By sharefree in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 10-27-2010, 02:15 PM
  4. Project - Help Plz
    By Shadow2552 in forum Windows Programming
    Replies: 11
    Last Post: 02-22-2004, 05:22 PM
  5. your 11th & 12th grade c++ project or similar project
    By sleepyheadtony in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 01-13-2002, 04:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21