UNPKG

ootk-core

Version:

Orbital Object Toolkit. A modern typed replacement for satellite.js including SGP4 propagation, TLE parsing, Sun and Moon calculations, and more.

229 lines (228 loc) 9.94 kB
import { AngularDiameterMethod } from '../enums/AngularDiameterMethod.js'; import { AngularDistanceMethod } from '../enums/AngularDistanceMethod.js'; import { EcfVec3, Kilometers, Radians, SpaceObjectType } from '../types/types.js'; /** * Calculates the factorial of a given number. * @param n - The number to calculate the factorial for. * @returns The factorial of the given number. */ export declare function factorial(n: number): number; /** * Calculates the base 10 logarithm of a number. * @param x - The number to calculate the logarithm for. * @returns The base 10 logarithm of the input number. */ export declare function log10(x: number): number; /** * Calculates the hyperbolic secant of a number. * @param x - The number to calculate the hyperbolic secant of. * @returns The hyperbolic secant of the given number. */ export declare function sech(x: number): number; /** * Calculates the hyperbolic cosecant of a number. * @param x - The number for which to calculate the hyperbolic cosecant. * @returns The hyperbolic cosecant of the given number. */ export declare function csch(x: number): number; /** * Returns the inverse hyperbolic cosecant of a number. * @param x - The number to calculate the inverse hyperbolic cosecant of. * @returns The inverse hyperbolic cosecant of the given number. */ export declare function acsch(x: number): number; /** * Calculates the inverse hyperbolic secant (asech) of a number. * @param x - The number to calculate the inverse hyperbolic secant of. * @returns The inverse hyperbolic secant of the given number. */ export declare function asech(x: number): number; /** * Calculates the inverse hyperbolic cotangent (acoth) of a number. * @param x - The number to calculate the acoth of. * @returns The inverse hyperbolic cotangent of the given number. */ export declare function acoth(x: number): number; /** * Copies the sign of the second number to the first number. * @param mag - The magnitude of the number. * @param sgn - The sign of the number. * @returns The number with the magnitude of `mag` and the sign of `sgn`. */ export declare function copySign(mag: number, sgn: number): number; /** * Evaluates a polynomial function at a given value. * @param x - The value at which to evaluate the polynomial. * @param coeffs - The coefficients of the polynomial. * @returns The result of evaluating the polynomial at the given value. */ export declare function evalPoly(x: number, coeffs: Float64Array): number; /** * Concatenates two Float64Arrays into a new Float64Array. * @param a - The first Float64Array. * @param b - The second Float64Array. * @returns A new Float64Array containing the concatenated values of `a` and `b`. */ export declare function concat(a: Float64Array, b: Float64Array): Float64Array; /** * Calculates the angle in the half-plane that best matches the given angle. * @param angle - The angle to be matched. * @param match - The angle to be matched against. * @returns The angle in the half-plane that best matches the given angle. */ export declare function matchHalfPlane(angle: number, match: number): number; /** * Wraps an angle to the range [-π, π]. * @param theta - The angle to wrap. * @returns The wrapped angle. */ export declare function wrapAngle(theta: Radians): Radians; /** * Calculates the angular distance between two points on a sphere. * @param lam1 The longitude of the first point. * @param phi1 The latitude of the first point. * @param lam2 The longitude of the second point. * @param phi2 The latitude of the second point. * @param method The method to use for calculating the angular distance. Defaults to AngularDistanceMethod.Cosine. * @returns The angular distance between the two points. * @throws Error if an invalid angular distance method is provided. */ export declare function angularDistance(lam1: number, phi1: number, lam2: number, phi2: number, method?: AngularDistanceMethod): Radians; /** * Calculates the angular diameter of an object. * @param diameter - The diameter of the object. * @param distance - The distance to the object. * @param method - The method used to calculate the angular diameter. Defaults to AngularDiameterMethod.Sphere. * @returns The angular diameter of the object. * @throws Error if an invalid angular diameter method is provided. */ export declare function angularDiameter(diameter: number, distance: number, method?: AngularDiameterMethod): number; /** * Performs linear interpolation between two points. * @param x - The x-coordinate to interpolate. * @param x0 - The x-coordinate of the first point. * @param y0 - The y-coordinate of the first point. * @param x1 - The x-coordinate of the second point. * @param y1 - The y-coordinate of the second point. * @returns The interpolated y-coordinate corresponding to the given x-coordinate. */ export declare function linearInterpolate(x: number, x0: number, y0: number, x1: number, y1: number): number; /** * Calculates the mean value of an array of numbers. * @param values - The array of numbers. * @returns The mean value of the numbers. */ export declare function mean(values: number[]): number; /** * Calculates the standard deviation of an array of numbers. * @param values - The array of numbers. * @param isSample - Optional. Specifies whether the array represents a sample. Default is false. * @returns The standard deviation of the array. */ export declare function std(values: number[], isSample?: boolean): number; /** * Calculates the covariance between two arrays. * @param a - The first array. * @param b - The second array. * @param isSample - Optional. Specifies whether the arrays represent a sample. Default is false. * @returns The covariance between the two arrays. */ export declare function covariance(a: number[], b: number[], isSample?: boolean): number; /** * Calculates the gamma function of a number. * @param n - The input number. * @returns The gamma function value. */ export declare function gamma(n: number): number; /** * Calculates the eccentric anomaly (e0) and true anomaly (nu) using Newton's method * for a given eccentricity (ecc) and mean anomaly (m). * @param ecc - The eccentricity of the orbit. * @param m - The mean anomaly. * @returns An object containing the eccentric anomaly (e0) and true anomaly (nu). */ export declare function newtonM(ecc: number, m: number): { e0: number; nu: number; }; /** * Calculates the eccentric anomaly (e0) and mean anomaly (m) using Newton's method * for a given eccentricity (ecc) and true anomaly (nu). * @param ecc - The eccentricity of the orbit. * @param nu - The true anomaly. * @returns An object containing the calculated eccentric anomaly (e0) and mean anomaly (m). */ export declare function newtonNu(ecc: number, nu: number): { e0: number; m: Radians; }; /** * Creates a 2D array with the specified number of rows and columns, filled with the same given value. * @template T The type of elements in the array. * @param rows The number of rows in the 2D array. * @param columns The number of columns in the 2D array. * @param value The value to fill the array with. * @returns The 2D array with the specified number of rows and columns, filled with the given value. */ export declare function array2d<T>(rows: number, columns: number, value: T): T[][]; /** * Clamps a number between a minimum and maximum value. * @param x The number to clamp. * @param min The minimum value. * @param max The maximum value. * @returns The clamped number. */ export declare function clamp(x: number, min: number, max: number): number; /** * Determines whether a given year is a leap year. * @param dateIn The date to check. * @returns `true` if the year is a leap year, `false` otherwise. */ export declare function isLeapYear(dateIn: Date): boolean; /** * Calculates the day of the year for a given date. * If no date is provided, the current date is used. * * This is sometimes referred to as the Jday, but is * very different from the Julian day used in astronomy. * @param date - The date for which to calculate the day of the year. * @returns The day of the year as a number. */ export declare function getDayOfYear(date?: Date): number; /** * Rounds a number to a specified number of decimal places. * @param value - The number to round. * @param places - The number of decimal places to round to. * @returns The rounded number. */ export declare function toPrecision(value: number, places: number): number; /** * Returns the sign of a number. * @param value - The number to determine the sign of. * @returns 1 if the number is positive, -1 if the number is negative. */ export declare function sign(value: number): 1 | -1; /** * Converts a SpaceObjectType to a string representation. * @param spaceObjType - The SpaceObjectType to convert. * @returns The string representation of the SpaceObjectType. */ export declare const spaceObjType2Str: (spaceObjType: SpaceObjectType) => string; /** * Calculates the Doppler factor for a given location, position, and velocity. * The Doppler factor is a measure of the change in frequency or wavelength of a wave * as observed by an observer moving relative to the source of the wave. * @param location - The location vector of the observer. * @param position - The position vector of the source. * @param velocity - The velocity vector of the source. * @returns The calculated Doppler factor. */ export declare const dopplerFactor: (location: EcfVec3<Kilometers>, position: EcfVec3<Kilometers>, velocity: EcfVec3<Kilometers>) => number; /** * Creates an array of numbers from start to stop (inclusive) with the specified step. * @param start The starting number. * @param stop The ending number. * @param step The step value. * @returns An array of numbers. */ export declare function createVec(start: number, stop: number, step: number): number[];