package jtznyj.engineer.service.dataDiagnosticService.data;

import java.util.Date;

/**
 * 监控夹角类
 * 相邻三个点（依次为A、B、C三点）构成的夹角
 */
public class MonitorAngle {
    /**
     * 夹角（弧度）
     */
    public double _angle;

    /**
     * 监控角点（B）与第一个点的时差（A）
     */
    public double _sec;

    /**
     * C点的Y值
     */
    public double _value;

    /**
     * C点的时刻值
     */
    public Date _dtCurrent;

    public MonitorAngle() {
    }

    public MonitorAngle(double angle, double sec, double value, Date dtCurrent) {
        this._angle = angle;
        this._sec = sec;
        this._dtCurrent = dtCurrent;
        this._value = value;
    }

    public static double CalcAngle(MonitorPoint mp0, MonitorPoint mpAngle, MonitorPoint mp1) {
        double xV = mpAngle._x - mp0._x;
        double yV = mpAngle._y - mp0._y;
        double xV2 = mp1._x - mpAngle._x;
        double yV2 = mp1._y - mpAngle._y;
        double result;
        if ((0.0 == xV && 0.0 == yV) || (0.0 == xV2 && 0.0 == yV2)) {
            result = 0.0;
        } else {
            result = Math.acos((xV * xV2 + yV * yV2) / Math.sqrt((xV * xV + yV * yV) * (xV2 * xV2 + yV2 * yV2))) * 180.0 / 3.1415926535897931;
        }
        return result;
    }
}
