Write a method, circlePlot, which takes as arguments an integer, n. The method should plot n points, evenly spaced around a circle.
I'm using the StdDraw library and a single while loop.
I don't even know where to begin.
One good thing would be to look up the StdDraw library and see what methods you have to use there.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
The only method I need to use is StdDraw.point
My issue is creating the loop:
Code:public class circleFun { public static void circlePlot(int n) { StdDraw.clear(); StdDraw.setPenColor(StdDraw.BLACK); StdDraw.setXscale(-1.1, 1.1); StdDraw.setYscale(-1.1,1.1); int ct = 0; StdDraw.setPenRadius(.01); while(n>=ct){ StdDraw.point(); //body of method ct=ct+1; } //end loop }}
Last edited by Orjan; 02-26-2010 at 07:22 PM. Reason: Please use code tags when posting code
Then I assume you need to calculate which points to draw. Think sinus and cosinus for the angle to calculate the coordinates. the angle should rely on number of points to have them evenly distributed (if more than n=1)
the unit circle would help you a lot with solving this I assume.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
Right, okay. So then the only values of n that will work will need to be multiples of 4.. that narrows it down a bit.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks