Rakam or (رقم) in Arabic, which means "number". This is a math(s) library, one of the reasons to give this package a try is that, the performance is the main goal. As some great projects such as plotto and desmos make intense calculations in tons of iterations to generate the graph. The need of such an open-source project cares about these situations arises, don't forget to contribute by raising an issue at github or optimizing some algorithms 🚀.
- Some helpful special maths functions in core.
- Compile math expression from a string into js function, ready for evaluation, considering the performance as the main goal.
- Parse math expression.
- The same for latex.
- Convert between latex and math expression.
- Geometric shapes and properties and intersections: lines and circles are available now.
- Use it harmony with other packages such as fraction.js and interval-arithmetics.
You can get and import any of Rakam's APIs directly, saving load time and bundle size.
Browser.
<script src="https://cdn.jsdelivr.net/npm/rakam/main/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/rakam/main/index.min.js"></script>
Nodejs
, or import then bundle.
❯ npm i rakam
Rakam uses @scicave/math-parser library to parse math expression, then handle the AST, or say the parser tree, to generate the equivalent js code, in a very customizable way. After all of these steps, we easily use Function constructor, new Function(...)
.
See documentations for more about math2js.
To convert ASCII-math expressions into latex representation. Let me rephrase it, 12sinx*2/3
=> 12\sin{x} \cdot \frac{2}{3}
.
See documentations for more about math2latex.
Rakam uses @scicave/math-latex-parser library to parse latex expression. expression, then handle the AST, to generate the equivalent js code, in a very customizable way. After all of these steps, we easily use Function constructor, new Function(...)
.
See documentations for more about latex2js.
To convert latex expressions into ASCII-math expressions. Let me rephrase it, 12\sin x\cdot\frac 23
=> 12sin(x) * 2 / 3
.
See documentations for more about latex2math.
You can:
- Convert angles from unit to another one (e.g. from deg to red, or rad to grad, etc...).
- Calculate the angle between two vectors,
{ x: number, y: number }
. You can also calculate the angle between two lines. - In both cases, between vectors or lines, you can get the minimal or maximal angle or get the angle by which the first vector (or line) rotates to reach the other vector (or line).
- Calculate the angle in degree (as float number), and get it as
{deg: number, min: number, sec: number}
, degree, minutes and seconds respectively. - Or get it as
12° 26' 53.48"
Documentations: angles.
You can:
- Get a line equation parameters: "a", "b" and "c" in
ax + by + c = 0
. - Get the intersection points between lines and any other geometric shape such as circles.
- Project a point onto a line.
- Get the distance between a point and a line.
Documentations: lines.
You can:
- Get a line equation parameters: "h", "k" and "r" in
(x-h)^2 + (y-k)^2 = r^2
. - Get the intersection points between circles and any other geometric shape such as lines.
- Project a point onto a circle.
- Get the distance between a point and a line.
Documentations: circles.
In order to adhere to the universal law "DON'T reinvent the wheel", fraction.js is a great and fast library to do computations on fractions. You can also use it with harmony with Rakam, see math2js
and latex2js
, and the options chain: true, chainHead: (num)=>{ new Fraction(num) }, chainMap
.
Copyright (©) 2020 sciCave™ [email protected]
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.