@fimbul-works/vec
Version:
A comprehensive TypeScript vector math library providing 2D, 3D, and 4D vector operations with a focus on performance and type safety.
13 lines (12 loc) • 402 B
JavaScript
/**
* Creates a 3D vector from spherical coordinates.
* @param {number} theta - First angle
* @param {number} phi - Second angle
* @param {number} [m] - Optional magnitude (default: `1`)
* @returns {ArrayVector3D} Vector
*/
export const fromSphericalCoords3D = (theta, phi, m = 1) => [
m * Math.sin(theta) * Math.cos(phi),
m * Math.sin(theta) * Math.sin(phi),
m * Math.cos(theta),
];