# @0x2e757/math-ext

> Math extended

Latest version **1.1.2** (published 2018-06-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @0x2e757/math-ext
pnpm add @0x2e757/math-ext
yarn add @0x2e757/math-ext
bun add @0x2e757/math-ext
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2018-06-26 |
| First published | 2018-06-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 148.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Eric Kevrel |
| Maintainers | 0x2e757 |
| Keywords | math, geometry, extended, typescript |

## Links

- npm: https://www.npmjs.com/package/@0x2e757/math-ext
- Repository: https://github.com/0x2E757/MathExt
- Homepage: https://github.com/0x2E757/MathExt#readme
- Issues: https://github.com/0x2E757/MathExt/issues
- npm.io page: https://npm.io/package/@0x2e757/math-ext

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.1.2 (latest) — 2018-06-26
- 1.1.1 — 2018-06-25
- 1.1.0 — 2018-06-25
- 1.0.0 — 2018-06-24

## README

# MathExt

Library with useful math functions like `clamp` and `random` with parameters and simple geometry classes. Library mostly oriented to be used with any kind of simple graphics. Also class objects support chaining.

TypeScript code transpiled to ES3 JavaScript.

## Install

```bash
npm i @0x2e757/math-ext
```

## Usage

### How to import

```typescript
import { ... } from "@0x2e757/math-ext";
```

### Interfaces

```typescript
interface IRange {
    start: number;
    end: number;
}
```

```typescript
interface IPoint {
    x: number;
    y: number;
    z: number;
}
```

```typescript
interface IRect {
    left: number;
    top: number;
    right: number;
    bottom: number;
}
```

### Math functions

```typescript 
clamp = (value: number, min: number, max: number) => number
clamp = (value: number, range: IRange) => number
```

```typescript 
round = (value: number, fractionDigits: number) => number
```

```typescript 
random = (min: number, max: number) => number
random = (min: number, max: number, integer: boolean) => number
random = (range: IRange) => number
random = (range: IRange, integer: boolean) => number
```

### Range methods

```typescript
new Range(start: number, end: number) => Range
new Range(range: IRange) => Range
```

```typescript
shift = (offset: number) => Range
shift = (offsetStart: number, offsetEnd: number) => Range
```

```typescript
multiply = (multiplier: number) => Range
multiply = (multiplierStart: number, multiplierEnd: number) => Range
```

```typescript
clamp = (min: number, max: number) => Range
clamp = (minStart: number, maxStart: number, minEnd: number, maxEnd: number) => Range
clamp = (range: IRange) => Range
clamp = (rangeStart: IRange, rangeEnd: IRange) => Range
clampStart = (min: number, max: number) => Range
clampStart = (range: IRange) => Range
clampEnd = (min: number, max: number) => Range
clampEnd = (range: IRange) => Range
```

```typescript
round = (fractionDigits: number) => Range
round = (fractionDigitsStart: number, fractionDigitsEnd: number) => Range
roundStart = (fractionDigits: number) => Range
roundEnd = (fractionDigits: number) => Range
```

```typescript
normalize = () => Range
```

```typescript
contains = (value: number) => boolean
contains = (range: IRange) => boolean
```

### Point methods

```typescript
new Point() => Point
new Point(x: number) => Point
new Point(x: number, y: number) => Point
new Point(x: number, y: number, z: number) => Point
new Point(point: IPoint) => Point
```

```typescript
shift = (offsetX: number) => Point
shift = (offsetX: number, offsetY: number) => Point
shift = (offsetX: number, offsetY: number, offsetZ: number) => Point
shift = (point: IPoint) => Point
shiftX = (offset: number) => Point
shiftY = (offset: number) => Point
shiftZ = (offset: number) => Point
```

```typescript
multiply = (multiplierX: number) => Point
multiply = (multiplierX: number, multiplierY: number) => Point
multiply = (multiplierX: number, multiplierY: number, multiplierZ: number) => Point
multiplyX = (multiplier: number) => Point
multiplyY = (multiplier: number) => Point
multiplyZ = (multiplier: number) => Point
```

```typescript
clamp = (min: number, max: number) => Point
clamp = (minX: number, maxX: number, minY: number, maxY: number, minZ: number, maxZ: number) => Point
clamp = (range: IRange) => Point
clamp = (rangeX: IRange, rangeY: IRange, rangeZ: IRange) => Point
clampX = (min: number, max: number) => Point
clampX = (range: IRange) => Point
clampY = (min: number, max: number) => Point
clampY = (range: IRange) => Point
clampZ = (min: number, max: number) => Point
clampZ = (range: IRange) => Point
```

```typescript
round = (fractionDigits: number) => Point
round = (fractionDigitsX: number, fractionDigitsY: number, fractionDigitsZ: number) => Point
roundX = (fractionDigits: number) => Point
roundY = (fractionDigits: number) => Point
roundZ = (fractionDigits: number) => Point
```

```typescript
distance = (point: IPoint) => number
```

### Rect methods

```typescript
new Rect() => Rect
new Rect(left: number, top: number, right: number, bottom: number) => Rect
new Rect(topLeft: IPoint, bottomRight: IPoint) => Rect
new Rect(rect: IRect) => Rect
```

```typescript
shift = (offsetHorizontal: number, offsetVertical: number) => Rect
shift = (offsetLeft: number, offsetTop: number, offsetRight: number, offsetBottom: number) => Rect
shift = (offset: IPoint) => Rect
shiftLeft = (offset: number) => Rect
shiftTop = (offset: number) => Rect
shiftRight = (offset: number) => Rect
shiftBottom = (offset: number) => Rect
shiftHorizontal = (offset: number) => Rect
shiftHorizontal = (offsetLeft: number, offsetRight: number) => Rect
shiftVertical = (offset: number) => Rect
shiftVertical = (offsetTop: number, offsetBottom: number) => Rect
shiftTopLeft = (offset: IPoint) => Rect
shiftTopLeft = (offsetLeft: number, offsetTop: number) => Rect
shiftTopRight = (offset: IPoint) => Rect
shiftTopRight = (offsetRight: number, offsetTop: number) => Rect
shiftBottomLeft = (offset: IPoint) => Rect
shiftBottomLeft = (offsetLeft: number, offsetBottom: number) => Rect
shiftBottomRight = (offset: IPoint) => Rect
shiftBottomRight = (offsetRight: number, offsetBottom: number) => Rect
```

```typescript
multiply = (multiplier: number) => Rect
multiply = (multiplierHorizontal: number, multiplierVertical: number) => Rect
multiplyHorizontal = (multiplier: number) => Rect
multiplyVertical = (multiplier: number) => Rect
```

```typescript
clamp = (min: number, max: number) => Rect
clamp = (minHorizontal: number, maxHorizontal: number, minVertical: number, maxVertical: number) => Rect
clamp = (minLeft: number, maxLeft: number, minTop: number, maxTop: number, minRight: number, maxRight: number, minBottom: number, maxBottom: number) => Rect
clamp = (rect: IRect) => Rect
clamp = (rangeHorizontal: IRange, rangeVertical: IRange) => Rect
clamp = (rangeLeft: IRange, rangeTop: IRange, rangeRight: IRange, rangeBottom: IRange) => Rect
clampLeft = (min: number, max: number) => Rect
clampLeft = (range: IRange) => Rect
clampTop = (min: number, max: number) => Rect
clampTop = (range: IRange) => Rect
clampRight = (min: number, max: number) => Rect
clampRight = (range: IRange) => Rect
clampBottom = (min: number, max: number) => Rect
clampBottom = (range: IRange) => Rect
clampHorizontal = (min: number, max: number) => Rect
clampHorizontal = (range: IRange) => Rect
clampVertical = (min: number, max: number) => Rect
clampVertical = (range: IRange) => Rect
clampTopLeft = (min: number, max: number) => Rect
clampTopLeft = (range: IRange) => Rect
clampTopRight = (min: number, max: number) => Rect
clampTopRight = (range: IRange) => Rect
clampBottomLeft = (min: number, max: number) => Rect
clampBottomLeft = (range: IRange) => Rect
clampBottomRight = (min: number, max: number) => Rect
clampBottomRight = (range: IRange) => Rect
```

```typescript
round = (fractionDigits: number) => Rect
round = (fractionDigitsHorizontal: number, fractionDigitsVertical: number) => Rect
roundHorizontal = (fractionDigits: number) => Rect
roundVertical = (fractionDigits: number) => Rect
```

```typescript
normalize = () => Rect
```

```typescript
topLeft = () => IPoint
topLeft = (left: number, top: number) => Rect
topLeft = (topLeft: IPoint) => Rect
```

```typescript
topRight = () => IPoint
topRight = (right: number, top: number) => Rect
topRight = (topRight: IPoint) => Rect
```

```typescript
bottomLeft = () => IPoint
bottomLeft = (left: number, bottom: number) => Rect
bottomLeft = (bottomLeft: IPoint) => Rect
```

```typescript
bottomRight = () => IPoint
bottomRight = (right: number, bottom: number) => Rect
bottomRight = (bottomRight: IPoint) => Rect
```

```typescript
width = () => number
width = (width: number) => Rect
```

```typescript
height = () => number
height = (height: number) => Rect
```

```typescript
contains = (point: IPoint) => boolean
contains = (rect: IRect) => boolean
```

---
_Source: https://npm.io/package/@0x2e757/math-ext · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
