java - Comparing Distance within an Array -
i have question in comparing values within array , drawing line points have largest distance.
point2d[] pts = new point2d[n]; (int = 0; < pts.length; i++){ pts[i] = new point2d(math.random(), math.random()); stddraw.setpencolor(stddraw.red); stddraw.setpenradius(0.008); pts[i].draw(); if(something){ stddraw.setpencolor(stddraw.black); stddraw.setpenradius(0.002); pts[i].drawto(something);
so far that's part of code generates random points, have no clue how approach measuring distance , drawing it. have create nested loop? advice great!
it that, if want draw longest edge (a graph theory term), your draw call not inside of loop. rather, loop (and possibly second nested loop) run through of possibilities , find longest edge first, saving , overwriting data on whichever most-longest has found far every time breaks previous record, , commence drawing once after loop.
Comments
Post a Comment