//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.base.core.source;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

public class SideAngleSurfaceGrid {
    private Position pos;
    private Position nextPos;
    private double width;
    private double length;
    private List<LatLon> locations;
    private double theta;
    private Color color;
    private String name;
    private String satName;
    private int cellIndex;
    private LatLon pointSec = null;
    private LatLon pointThr = null;
    private int flag;

    public Position getPos() {
        return this.pos;
    }

    public void setPos(Position pos) {
        this.pos = pos;
    }

    public Position getNextPos() {
        return this.nextPos;
    }

    public void setNextPos(Position nextPos) {
        this.nextPos = nextPos;
    }

    public double getWidth() {
        return this.width;
    }

    public void setWidth(double width) {
        this.width = width;
    }

    public double getLength() {
        return this.length;
    }

    public void setLength(double length) {
        this.length = length;
    }

    public List<LatLon> getLocations() {
        return this.locations;
    }

    public void setLocations(List<LatLon> locations) {
        this.locations = locations;
    }

    public double getTheta() {
        return this.theta;
    }

    public void setTheta(double theta) {
        this.theta = theta;
    }

    public Color getColor() {
        return this.color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSatName() {
        return this.satName;
    }

    public void setSatName(String satName) {
        this.satName = satName;
    }

    public int getCellIndex() {
        return this.cellIndex;
    }

    public void setCellIndex(int cellIndex) {
        this.cellIndex = cellIndex;
    }

    public LatLon getPointSec() {
        return this.pointSec;
    }

    public void setPointSec(LatLon pointSec) {
        this.pointSec = pointSec;
    }

    public LatLon getPointThr() {
        return this.pointThr;
    }

    public void setPointThr(LatLon pointThr) {
        this.pointThr = pointThr;
    }

    public SideAngleSurfaceGrid(Position pos, Position nextPos, double width, double length, double theta, int flag) {
        this.pos = pos;
        this.nextPos = nextPos;
        this.width = width;
        this.length = length;
        this.theta = theta;
        this.flag = flag;
        this.locations = new ArrayList();
        this.constructLocations();
    }

    private void constructLocations() {
        double distanceX;
        Angle heading;
        double globeRadius;
        double distanceY;
        double azimuth;
        double satAltitude;
        double rigidRadians;
        double thetaRadians;
        LatLon tempPos;
        Position sensorPos;
        double coverageDistance;
        if (this.flag == 0) {
            satAltitude = this.nextPos.getAltitude();
            rigidRadians = 0.0D;
            thetaRadians = 0.0D;
            tempPos = null;
            sensorPos = null;
            heading = LatLon.greatCircleAzimuth(this.pos.getLatLon(), this.nextPos.getLatLon());
            sensorPos = GlobeMath.computePositionFromPosition(this.nextPos, heading, (this.width - this.length) / 2.0D, 0);
            globeRadius = RadiansDic.queryradians(sensorPos.getLatitude().getDegrees());
            rigidRadians = Math.atan2(this.width, 2.0D * satAltitude);
            thetaRadians = this.theta * 3.141592653589793D / 180.0D;
            coverageDistance = LatLon.greatCircleDistance(this.pos, this.nextPos).radians;
            distanceX = satAltitude * Math.tan(rigidRadians - thetaRadians) / globeRadius;
            azimuth = heading.radians + 1.5707963267948966D;
            this.locations.add(tempPos = LatLon.greatCircleEndPosition(sensorPos, azimuth, distanceX));
            if (this.getPointSec() == null) {
                this.locations.add(LatLon.greatCircleEndPosition(tempPos, heading.radians + 3.141592653589793D, coverageDistance));
            } else {
                this.locations.add(this.getPointSec());
            }

            sensorPos = GlobeMath.computePositionFromPosition(this.nextPos, heading, (this.width - this.length) / 2.0D, 1);
            globeRadius = RadiansDic.queryradians(sensorPos.getLatitude().getDegrees());
            rigidRadians = Math.atan2(this.width, 2.0D * satAltitude);
            thetaRadians = this.theta * 3.141592653589793D / 180.0D;
            distanceY = satAltitude * Math.tan(rigidRadians + thetaRadians) / globeRadius;
            azimuth = heading.radians - 1.5707963267948966D;
            tempPos = LatLon.greatCircleEndPosition(sensorPos, azimuth, distanceY);
            if (this.getPointThr() == null) {
                this.locations.add(LatLon.greatCircleEndPosition(tempPos, heading.radians + 3.141592653589793D, coverageDistance));
            } else {
                this.locations.add(this.getPointThr());
            }

            this.locations.add(tempPos);
            this.setPointSec((LatLon)this.locations.get(0));
            this.setPointThr((LatLon)this.locations.get(3));
        } else {
            satAltitude = this.nextPos.getAltitude();
            rigidRadians = 0.0D;
            thetaRadians = 0.0D;
            tempPos = null;
            sensorPos = null;
            heading = LatLon.greatCircleAzimuth(this.pos.getLatLon(), this.nextPos.getLatLon());
            sensorPos = GlobeMath.computePositionFromPosition(this.nextPos, heading, (this.width - this.length) / 2.0D, 0);
            globeRadius = RadiansDic.queryradians(sensorPos.getLatitude().getDegrees());
            rigidRadians = Math.atan2(this.width, 2.0D * satAltitude);
            thetaRadians = this.theta * 3.141592653589793D / 180.0D;
            coverageDistance = LatLon.greatCircleDistance(this.pos, this.nextPos).radians;
            distanceX = satAltitude * Math.tan(rigidRadians + thetaRadians) / globeRadius;
            azimuth = heading.radians + 1.5707963267948966D;
            this.locations.add(tempPos = LatLon.greatCircleEndPosition(sensorPos, azimuth, distanceX));
            if (this.getPointSec() == null) {
                this.locations.add(LatLon.greatCircleEndPosition(tempPos, heading.radians + 3.141592653589793D, coverageDistance));
            } else {
                this.locations.add(this.getPointSec());
            }

            sensorPos = GlobeMath.computePositionFromPosition(this.nextPos, heading, (this.width - this.length) / 2.0D, 1);
            globeRadius = RadiansDic.queryradians(sensorPos.getLatitude().getDegrees());
            rigidRadians = Math.atan2(this.width, 2.0D * satAltitude);
            thetaRadians = this.theta * 3.141592653589793D / 180.0D;
            distanceY = satAltitude * Math.tan(rigidRadians - thetaRadians) / globeRadius;
            azimuth = heading.radians - 1.5707963267948966D;
            tempPos = LatLon.greatCircleEndPosition(sensorPos, azimuth, distanceY);
            if (this.getPointThr() == null) {
                this.locations.add(LatLon.greatCircleEndPosition(tempPos, heading.radians + 3.141592653589793D, coverageDistance));
            } else {
                this.locations.add(this.getPointThr());
            }

            this.locations.add(tempPos);
            this.setPointSec((LatLon)this.locations.get(0));
            this.setPointThr((LatLon)this.locations.get(3));
        }

    }
}
