# Introduction

## Table of Contents

[[toc]]

## Prerequsites

- [Node.js 10+](//nodejs.org/en)
- Package manager (any of the below)

  - Yarn
  - npm
  - pnpm

  ::: danger Package Manager
  We recommend you use `yarn` over `npm` and `pnpm`. This is because you may notice some compatibility/stability issues while using `npm`. Also, we have noticed in some cases, `@enginemirage/math` may behave unexpectedly or slowly while using `npm`.
  :::

---

Mirage Math was created to act as a private tool only to be used by the Mirage team, but I have decided against that and have made it public along with documentation. It is very easy to get started with. Our math library was created with the JavaScript Math object as a reference. **The library is still actively being updated, with tons of new features being added each day.** Soon, you can expect all of the default Math functions imported into Mirage Math. Mirage Math will also contain tons of more custom features such as vectors, and 3D plane calculations.

## Installation

Mirage Math can easily be installed using your default Node package manager. To install, run the following command:

```bash
# with npm
npm install @enginemirage/math

# with yarn
yarn add @enginemirage/math

# with pnpm
pnpm install @enginemirage/math
```

::: tip Stability Issues
If you experience that `@enginemirage/math` is behaving slowly or unexpectedly while using `npm` or `pnpm`, please read the danger slot above.
:::

Once you install Mirage Math, you can immediately use it in your code!

## Basic Usage

Mirage Math is very easy to use. All you have to do is import the package and the class, then get going!

```js
import { MirageMath } from "@enginemirage/math";
// const { MirageMath } = require("@enginemirage/math");
// CommonJS imports also work
const math = new MirageMath();

// The following is a list of a couple
// constants automatically provided
// by Mirage

math.PI; // Returns the value of PI
math.E; // Returns Euler's Constant
math.SQRT2; // Returns the square root of 2 (sqrt(2))

// A couple functions provided by MirageMath

math.clamp(-50, 0, 100); // Clamps a number between two values --> 0
math.sqrt(4489); // Returns the square root of 4449 --> 67
math.cbrt(729000); // Returns the cube root of 729000 --> 90
```

::: warning Package Updating
This package is frequently being updated. So, the functions that are listed above may be outdated or not listed. **Make sure to check the README in the [GitHub Repository](https://github.com/enginemirage/math) for the most updated version.** This is because there are new features being added to this package by the minute.
:::
