-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDCircle.java
57 lines (41 loc) · 1.02 KB
/
DCircle.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.fleen.geom_2D;
public class DCircle{
/*
* ################################
* CONSTRUCTORS
* ################################
*/
public DCircle(double x,double y,double r){
this.x=x;
this.y=y;
this.r=r;}
public DCircle(double[] c,double r){
this.x=c[0];
this.y=c[1];
this.r=r;}
public DCircle(DPoint c,double r){
this.x=c.x;
this.y=c.y;
this.r=r;}
public DCircle(){}
/*
* ################################
* GEOMETRY
* ################################
*/
public double x=0,y=0,r=0;
public double getRadius(){
return r;}
public double getDiameter(){
return r*2;}
public double[] getCenter(){
return new double[]{x,y};}
public double getArea(){
return GD.PI*r*r;}
public double getCircumference(){
return GD.PI*2.0*r;}
public double getDistance(double[] p){
return GD.getDistance_PointCircle(p[0],p[1],x,y,r);}
public boolean contains(double[] p){
return getDistance(p)<r;}
}