-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathD3Point.java
More file actions
31 lines (28 loc) · 733 Bytes
/
Copy pathD3Point.java
File metadata and controls
31 lines (28 loc) · 733 Bytes
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
public class D3Point extends D2Point
{
double z;
D3Point()
{
super();
z=0.0;
}
D3Point(double nx,double ny,double nz)
{
super(nx,ny);
z=nz;
}
double distance3d(D3Point b)
{
double d=Math.pow((Math.pow((b.x-x),2)+Math.pow((b.y-y),2))+Math.pow((b.z-z),2),.5);
return d;
}
public static void main(double nx,double ny,double nz,double nx1,double ny1,double nz1)
{
D2Point ob=new D2Point(nx,ny);
D3Point ob1=new D3Point(nx,ny,nz);
D2Point ob2=new D2Point(nx1,ny1);
D3Point ob3=new D3Point(nx1,ny1,nz1);
System.out.println(ob2.distance2d(ob));
System.out.println(ob3.distance3d(ob1));
}
}