@daeinc/math
Advanced tools
Comparing version
@@ -90,2 +90,9 @@ /** | ||
/** | ||
* converts polar coordinate to cartesian. to update center, result.map((v,i)=> v + center[i]) | ||
* @param radius | ||
* @param angle in radians | ||
* @returns | ||
*/ | ||
export declare const polarToCartesian: (radius: number, angle: number) => number[]; | ||
/** | ||
* reflect a scalar value along axis. good for creating reflected version. | ||
@@ -92,0 +99,0 @@ * @param num number to flip |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.snapToArray = exports.snapBy = exports.roundF = exports.reflect = exports.modIncl = exports.modF = exports.mod = exports.lerp = exports.mix = exports.map = exports.floorF = exports.distSq = exports.dist = exports.constrain = exports.clamp = void 0; | ||
exports.snapToArray = exports.snapBy = exports.roundF = exports.reflect = exports.polarToCartesian = exports.modIncl = exports.modF = exports.mod = exports.lerp = exports.mix = exports.map = exports.floorF = exports.distSq = exports.dist = exports.constrain = exports.clamp = void 0; | ||
/** | ||
@@ -109,2 +109,7 @@ * clamp values between min and max (=constrain) | ||
exports.modF = modF; | ||
// export const floorF = (n: number, digit: number): number => { | ||
// n = parseFloat(n.toFixed(digit)); | ||
// const factor = Math.pow(10, digit); | ||
// return Math.floor(n * factor) / factor; | ||
// }; | ||
/** | ||
@@ -124,2 +129,12 @@ * inclusive modulo. modIncl(1, 3) will include 3. | ||
/** | ||
* converts polar coordinate to cartesian. to update center, result.map((v,i)=> v + center[i]) | ||
* @param radius | ||
* @param angle in radians | ||
* @returns | ||
*/ | ||
const polarToCartesian = (radius, angle) => { | ||
return [Math.cos(angle) * radius, Math.sin(angle) * radius]; | ||
}; | ||
exports.polarToCartesian = polarToCartesian; | ||
/** | ||
* reflect a scalar value along axis. good for creating reflected version. | ||
@@ -126,0 +141,0 @@ * @param num number to flip |
{ | ||
"name": "@daeinc/math", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Math utilities", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15982
7.61%316
7.48%0
-100%