Convex Hull | Newbie | | Join Date: May 2009
Posts: 3
| | |
hello,
I'm new in using java. i'm trying to use eclipse to be able to run a convex hull problem which means you are given a number of points in a plane then you connect points so that the points are enclosed in a convex.
can someone help how i can do it using eclipse?
|  | Site Moderator | | Join Date: Oct 2006 Location: The Great White North
Posts: 5,137
| | | re: Convex Hull
What have you tried so far?
What problems are you having running the application with eclipse?
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | re: Convex Hull
Your problem isn't really a convex hull problem but a problem of "how to do this bloody thing in Eclipse"? Right? A 2D convex hull problem is like wrapping a rubber band around a bunch of points/nails and see how it wraps around them.
please elaborate on your problem.
kind regards,
Jos
| | Newbie | | Join Date: May 2009
Posts: 3
| | | re: Convex Hull
ohhh thank you for your replies.
let me try to change my problem and be more specific.
i'm a beginner in java, i want to write codes that will allow me to enter points in a plane then by clicking on a button i want to find the minimum circle that encloses all the points entered in the plane.
can someone help me please?
thank you
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | re: Convex Hull Quote:
Originally Posted by michou ohhh thank you for your replies.
let me try to change my problem and be more specific.
i'm a beginner in java, i want to write codes that will allow me to enter points in a plane then by clicking on a button i want to find the minimum circle that encloses all the points entered in the plane.
can someone help me please?
thank you That circle won't be the convex hull of the set of points; you want to find the largest distance d == |P_i, P_j| for any point P_i and P_j. That distance d is the diameter of the circle you're looking for and points P_i and P_j are on opposite sides of that circle.
kind regards,
Jos
| | Newbie | | Join Date: May 2009
Posts: 3
| | | re: Convex Hull
hello,
thank you for your reply, up to now i have wrote some codes that can allow me to enter points in a plane but im still comfused about how i can write codes to find the maximum distance between two points (the two points have to be in different sides) then that maximum distance has to be the diameter of the circle that must enclose all the points entered.
the above is the program that i wrote so far but i need to include a function that calculate the maximum distance then use that maximum distance to draw a circle:
can u help? - import java.awt.Graphics;
-
import java.awt.Point;
-
import java.awt.event.*;
-
-
public class PointTool implements Tool {
-
private Point p;
-
protected JDrawFrame drawframe;
-
protected PointCanvas canvas;
-
protected int xStart;
-
protected int yStart;
-
protected Graphics onscreen;
-
protected Graphics offscreen;
-
-
public PointTool(JDrawFrame drawframe, PointCanvas canvas) {
-
super();
-
this.drawframe = drawframe;
-
this.canvas = canvas;
-
}
-
-
@Override
-
public void mousePressed(MouseEvent e) {
-
int dot = 1;
-
p = e.getPoint();
-
canvas.mouseButtonDown = true;
-
canvas.x = p.x;
-
canvas.y = p.y;
-
-
// saving the point that have been drawn
-
canvas.getJDrawFrame1().addTwoDPoint(new Vertix(canvas.x, canvas.y));
-
-
// drawing the point on the screen
-
//canvas.getOffScreenGraphics().drawOval(canvas.x, canvas.y, 10, 10);
-
canvas.getOffScreenGraphics().fillOval(canvas.x, canvas.y, 10, 10);
-
//canvas.getOffScreenGraphics().drawString(String.valueOf(dot), canvas.x,canvas.y);
-
canvas.repaint(canvas.x, canvas.y, canvas.x, canvas.y);
-
dot++;
-
-
}
-
-
@Override
-
public void mouseDragged(MouseEvent e) {
-
-
}
-
-
@Override
-
public void mouseReleased(MouseEvent e) {
-
// handle mouse released for scribble tool
-
canvas.mouseButtonDown = false;
-
-
}
-
-
}
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | re: Convex Hull Quote:
Originally Posted by michou hello,
thank you for your reply, up to now i have wrote some codes that can allow me to enter points in a plane but im still comfused about how i can write codes to find the maximum distance between two points (the two points have to be in different sides) then that maximum distance has to be the diameter of the circle that must enclose all the points entered.
the above is the program that i wrote so far but i need to include a function that calculate the maximum distance then use that maximum distance to draw a circle:
can u help? What do you mean by "different sides"? Different sides of what? In order to find a maximum distance between two points you have to use two loops: one for every point P_i and one loop for every point P_j; find the distance between point P_i and P_j and remember the index values of i and j.
kind regards,
Jos
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|