/**
This file is created by Yu Dong (2023).
License : Apache 2.0
FileName : Math.cj
Author : Yu Dong
Version : 0.0.1
Date : 20230424
Note : First Commit
*/
/**
* @file
* Math
*/
package gistools.base
import std.math.*
// base parameter
let x_PI = Float64.PI * 3000.0 / 180.0
// 地球椭球体 - 长半轴
let a = 6378245.0
// 地球椭球体 - 扁率
let ee = 0.00669342162296594323
// 地球赤道周长的一半 墨卡托坐标x轴区间[-20037508.3427892,20037508.3427892]
let halfRadius = 20037508.34
// 地球半径(米)
let earthRadiusMeters : Float64 = 6371006.0
// 米每度
let metersPerDegree : Float64 = 2.0 * Float64.PI * earthRadiusMeters / 360.0
// 弧度每度
let radiansPerDegree : Float64 = Float64.PI / 180.0
// 度每弧度
let degreesPerRadian : Float64 = 180.0 / Float64.PI
/**
* The Function is to compute atan2 with 2 values
*
* @param x of Float64
* @param y of Float64
*
* @return Type of Float64
* @since 0.38.2
*/
public func atan2(x : Float64, y : Float64): Float64 {
if (y < 0.0 && x < 0.0) {
atan(y/x) - Float64.PI
} else if (y > 0.0 && x < 0.0) {
atan(y/x) + Float64.PI
} else {
atan(y/x)
}
}
/**
* Ordered Pair
*
* @author Yu Dong
* @since 0.38.2
*/
public interface OrderedPair {
mut prop x : Float64
mut prop y : Float64
}