UNPKG

dimensional

Version:

Dimensional analysis and unit conversions

62 lines (61 loc) 1.74 kB
import { Unit } from './unit'; /** * Represents a physical, measurable quantity. */ export declare class Quantity { readonly quantity: number; readonly units: Unit; /** * Define a new quantity. * @param quantity The numeric value of the quanity * @param units The units of this quantity */ constructor(quantity: number, units: Unit); /** * Scale this quantity by a constant factor. * @param factor A scalar * @returns A scaled quantity */ scaleBy(factor: number): Quantity; /** * Add another quantity to this one. * @param other Another quantity * @returns The sum */ plus(other: Quantity): Quantity; /** * Subtract another quantity from this one. * @param other Another quantity * @returns The difference */ minus(other: Quantity): Quantity; /** * Multiply this quantity by another. * @param other Another quantity * @returns The product */ times(other: Quantity): Quantity; /** * Divide this quantity by another. * @param other Another quantity * @returns The quotient */ over(other: Quantity): Quantity; /** * Raise this quantity to an exponent. * @param exponent The exponent * @returns The power */ pow(exponent: number): Quantity; /** * Convert this quantity to another unit system. Dimensions **must** be identical between the two unit systems. * @param units Units to convert to * @returns This quantity in a different unit system */ as(units: Unit): Quantity; /** * Convert this quantity into LaTeX code. * @returns LaTeX code for this quantity */ toString(): string; }