Venn Diagram Applet Help
Hello everyone!
Im working on an applet to use Venn Diagrams (remeber these? with some circles and how they intersect over a common point?) Well, i just was going to ask if anyone could help me to get started...i have no idea where to start off with... i want to figure out some kind of formula for the diagram...
This page displays EXACTLY what i am trying to achieve, with the overlapping colours, etc!
http://acm.uva.es/p/v105/10540.html
Thanks to all who have any ideas!
-Crawf
[526 byte] By [
crawf] at [2007-11-11 8:47:19]

# 1 Re: Venn Diagram Applet Help
The number of circles is proportional to the number of degrees between each circle.
N = number of circles
angle = 360/N
for = 0 to N-1
x = cos(angle*i)*radius
y = sin(angle*i)*radius
drawCircle(x,y,radius)
# 2 Re: Venn Diagram Applet Help
Hi! thanks thats just what i am looking for!
what does the "for = 0 to N-1" stand for?
and also "i"
Thanks again!
-Crawf
crawf at 2007-11-11 22:35:25 >

# 3 Re: Venn Diagram Applet Help
its a for statement, pseudo code. (or basic) I hope you know the purpose of a for statement before you try to code anything.
for(int i=0; i<N; i++)
it draws all the circles.
# 4 Re: Venn Diagram Applet Help
OH! sorry about that! i didnt realise it was a for loop! well, i have put together an applet with the aid you've given me, but there is a problem with it...ive started off with 3 circles but they aren't at an equal angular distance for each other...well, in short, i want to make the circles be printed in a triangle shape, like the example page from my initial post...
here is my code if you can be bothered to look at! I would appreciate it a lot!!
import java.applet.*;
import java.awt.*;
public class Flower extends Applet {
double x, y;
public void paint (Graphics g){
int n=3;
double angle = 360/n;
int radius = 100;
for(int i=0; i<n; i++) {
x = Math.cos(angle*i)*radius;
y = Math.sin(angle*i)*radius;
g.drawOval((int)x+radius,(int)y+radius,2*radius,2*radius);
}
}
}
I cant thank you enough for helping me so far! you've been extremely helpful, and i thank you a LOT! :)
-Crawf
crawf at 2007-11-11 22:37:23 >

# 5 Re: Venn Diagram Applet Help
Math.sin() takes an angle in radians, whereas i demonstrated degrees.
Math.sin(Math.toRadians(angle*i))*radius
# 6 Re: Venn Diagram Applet Help
thats perfect! thank you very much! i didnt even think about converting to radians! thanks!
Just one more question though...if you enter the number of circles drawn to, say 50 circles, they arent quite evenly spaced...Is there anything i can do to fix this?
Otherwise, i must applause you for your GREAT help! you've helped me heaps! :) :) :)
-Crawf
crawf at 2007-11-11 22:39:32 >

# 7 Re: Venn Diagram Applet Help
ah, got it, just changed the angle to a double, as it will round off and not display correctly...thank you everyone for your awesome help! :)
-Crawf
crawf at 2007-11-11 22:40:30 >

# 8 Re: Venn Diagram Applet Help
I'm just a humble geometry nerd