Xiajijian
2025-10-13 e90fcceee583f9428b40a551c31ae29a3492f2bf
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
package com.ard.work.util;
 
public class Vertex {
    public double x;
    public double y;
 
    public Vertex() {
 
    }
 
    public Vertex(double x, double y) {
        this.x = x;
        this.y = y;
    }
 
    // 判断这个点是不是和另外一个点重合(允许极小的误差,算作同一个点
    public boolean IsSame(Vertex anotherV) {
        double almostZero = 0.00000001;
        if ((Math.abs(x - anotherV.x) < almostZero) && (Math.abs(y - anotherV.y) < almostZero))
            return true;
        else
            return false;
    }
 
    // 直线距离
    public double Distance(Vertex anotherV) {
        return Math.sqrt(Math.pow(x - anotherV.x, 2) + Math.pow(y - anotherV.y, 2));
    }
}