WdMath is a JavaScript library providing a variety of mathematical functions, including operations on complex numbers, geometry calculations, and conversion utilities. This library is designed to be lightweight and easy to integrate into any JavaScript project.
To install WdMath, you can use npm or include the script directly in your project.
npm install wdmath
yarn add wdmathWdMath provides functions to work with complex numbers, including addition, subtraction, multiplication, and division.
Example:
const complex1 = { real: 1, imag: 2 };
const complex2 = { real: 3, imag: 4 };
const sum = WdMath.addComplex(complex1, complex2);
console.log(sum); // { real: 4, imag: 6 }Functions to calculate properties of various geometric shapes like cones, cylinders, prisms, pyramids, and spheres.
Example:
const radius = 5;
const height = 10;
const volume = WdMath.cylinderVolume(radius, height);
console.log(volume); // 785.3981633974483Convert between degrees and radians.
Example:
const degrees = 180;
const radians = WdMath.toRadians(degrees);
console.log(radians); // 3.141592653589793=> @param {number[]}array.mean(array): Calculates the mean of a array.array.median(array): Calculates the median of a array.array.mode(array): Calculates the mode of a array.array.standardDeviation(array): Calculates the standard deviation of a array.
=> @param {{real: number, imag: number}}complex.addComplex(complex1, complex2): Adds two complex numbers.complex.subtractComplex(complex1, complex2): Subtracts two complex numbers.complex.multiplyComplex(complex1, complex2): Multiplies two complex numbers.complex.divideComplex(complex1, complex2): Divides two complex numbers.complex.magnitudeComplex(complex): Calculates the magnitude of a complex numbercomplex.phaseComplex(complex): Calculates the phase of a complex number
cone.Volume(radius, height): Calculates the volume of a cone.cylinder.Volume(radius, height): Calculates the volume of a cylinder.prism.Volume(baseArea, height): Calculates the volume of a prism.pyramid.Volume(baseArea, height): Calculates the volume of a pyramid.sphere.Volume(radius): Calculates the volume of a sphere.rectangularPrism.Volume(length, width, height): Calculates the volume of a rectangular prism.
toRadians(degrees): Converts degrees to radians.toDegrees(radians): Converts degrees to radians.
getBearing(startLat, startLng, endLat, endLng): Calculates the bearing between two points.distInKm(lat1, lng1, lat2, lng2): Calculates the distance in kilometers between two points.
Contributions are welcome! Please open an issue or submit a pull request for any changes or additions.
This project is licensed under the MIT License.