平分正方形的直线

来源:互联网 发布:黑火金融网络贷款 编辑:程序博客网 时间:2024/04/28 12:08
package 平分的直线;class Point {    int x;    int y;    public Point(int x, int y) {        this.x = x;        this.y = y;    }    public Point() {        this.x = 0;        this.y = 0;    }}public class Bipartition {    public double[] getBipartition(Point[] A, Point[] B) {        double firstX = (A[0].x + A[1].x) / 2.0;        double firstY = (A[0].y + A[3].y) / 2.0;        double secondX = (B[0].x + B[1].x) / 2.0;        double secondY = (B[0].y + B[3].y) / 2.0;        double slope = (secondY - firstY) / (secondX - firstX);        double y = secondY - slope * secondX;        double[] res = new double[2];        res[0] = slope;        res[1] = y;        return res;    }    public static void main(String[] args) {    }}
0 0
原创粉丝点击