Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@daeinc/math

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daeinc/math - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

2

dist/index.d.ts

@@ -0,1 +1,3 @@

export declare const PI: number;
export declare const TWO_PI: number;
/**

@@ -2,0 +4,0 @@ * clamp values between min and max (=constrain)

5

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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;
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 = exports.TWO_PI = exports.PI = void 0;
// frequently used constants
exports.PI = Math.PI;
exports.TWO_PI = Math.PI * 2;
/**

@@ -5,0 +8,0 @@ * clamp values between min and max (=constrain)

{
"name": "@daeinc/math",
"version": "0.3.0",
"version": "0.4.0",
"description": "Math utilities",

@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts",

# math utilities
For personal consumption. Breaking changes expected.
## Installation
```sh
npm i @daeinc/math
```
then,
```js
import { modF, ... } from "@daeinc/math"
```
## Functions
### clamp
```ts
const clamp: (val: number, min: number, max: number) => number;
```
### constrain
```ts
const constrain: (val: number, min: number, max: number) => number;
```
### dist
```ts
const dist: (x1: number, y1: number, x2: number, y2: number) => number;
```
### distSq
```ts
const distSq: (x1: number, y1: number, x2: number, y2: number) => number;
```
There's another version in `@daeinc/geom` that takes `Pt: number[]` type as arguments.
### floorF
```ts
const floorF: (n: number, digit: number) => number;
```
### map
```ts
const map: (
val: number,
s: number,
e: number,
ns: number,
ne: number
) => number;
```
### mix
```ts
const mix: (a: number, b: number, t: number) => number;
```
### lerp
```ts
const lerp: (a: number, b: number, t: number) => number;
```
### mod
```ts
const mod: (n: number, max: number) => number;
```
### modF
```ts
const modF: (n: number, max: number, precision?: number) => number;
```
### modIncl
```ts
const modIncl: (n: number, max: number) => number;
```
### polarToCartesian
```ts
const polarToCartesian: (radius: number, angle: number) => number[];
```
Converts polar coodrinate to cartesian coordinate. To use a different center point than the default `[0, 0]`, do something like this:
```ts
result.map((v, i) => v + center[i]);
```
### reflect
```ts
const reflect: (num: number, axis: number) => number;
```
### roundF
```ts
const roundF: (n: number, digit: number) => number;
```
### snapBy
```ts
const snapBy: (n: number, inc: number) => number;
```
### snapToArray
```ts
const snapToArray: (n: number, snapArr: number[]) => number;
```
## To do
- add more tests
## License
MIT

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc