"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.GVec3 = void 0;
var src_1 = require("src");
var gis_1 = require("src-gis/gis");
var Vec3_1 = require("src/math/Vec3");
/*
 * @Description  :
 * @Author       : 赵耀圣
 * @QQ           : 549184003
 * @Date         : 2021-08-04 11:39:03
 * @LastEditTime : 2021-08-04 16:02:16
 * @FilePath     : \cga.js\src-gis\math\GVec3.ts
 */
var scratchN = new Vec3_1.Vec3();
var scratchK = new Vec3_1.Vec3();
var GVec3 = /** @class */ (function (_super) {
    __extends(GVec3, _super);
    function GVec3() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    GVec3.fromDegrees = function (longitude, latitude, height, ellipsoid) {
        if (height === void 0) { height = 0; }
        if (ellipsoid === void 0) { ellipsoid = gis_1.wgs84RadiiSquared; }
        longitude = (0, src_1.toRadians)(longitude);
        latitude = (0, src_1.toRadians)(latitude);
        return GVec3.fromRadians(longitude, latitude, height, ellipsoid);
    };
    /**
     * @description :
     * @param ellipsoid  {椭球体}
     * @return       {*}
     * @example     :
     */
    GVec3.fromRadians = function (longitude, latitude, height, ellipsoid) {
        if (height === void 0) { height = 0; }
        if (ellipsoid === void 0) { ellipsoid = gis_1.wgs84RadiiSquared; }
        var cosLatitude = Math.cos(latitude);
        scratchN.x = cosLatitude * Math.cos(longitude);
        scratchN.y = Math.sin(latitude);
        scratchN.z = cosLatitude * Math.sin(longitude);
        scratchN.normalize(); //标准球形坐标
        scratchK.copy(scratchN).multiply(ellipsoid); //各个单位
        var gamma = Math.sqrt(scratchN.dot(scratchK));
        scratchK.divideScalar(gamma);
        scratchN.multiplyScalar(height); //scratchN始终是一个标准球
        var result = new Vec3_1.Vec3();
        return result.addVecs(scratchK, scratchN);
    };
    GVec3.toCartographic = function () {
    };
    return GVec3;
}(Vec3_1.Vec3));
exports.GVec3 = GVec3;
