1.0.0-2 β€’ Published 3 years ago

rakam v1.0.0-2

Weekly downloads
17
License
Apache-2.0
Repository
github
Last release
3 years ago

RAKAM βž• βž— πŸ“

NPM Package Build Status License

Rakam or (Ψ±Ω‚Ω…) in Arabic, which means "number". This is a math library. One of the reasons to give this package a try is that, the performance is in our considerations. 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, so that we can cooperate and contribute to reach the optimal performance πŸš€.

Features:

  • 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: now lines are avaliable.
  • Get a float number as a numerator over a denomerator { s: sign<1|-1>, n: integer, d: integer }.
  • As well as getting the quotient, the reminder and the denomerator of a fraction, { s: sign<1|-1>, q: integer, r: integer, d: integer }. AKA: quotient is the whole number, and the decimal part will be converted to a numerator and a denomerator.

You can get any import any of the APIs elements directly, saving load time and bundle size.

Documentations tree (API):

  • core lcm, gcd, lcm2, gcd2, dist, constrain, trunc, toFixed, random, randomInt
  • engine
    • math2js
    • math2latex
    • mathParser
    • latexParser
    • latex2js
    • latex2math
  • geometry
  • fraction

πŸ›  engine

math2js

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.

πŸ“ geometry

angles

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.

lines

You can:

  • Get a line equation parameters: "a", "b" and "c" in ax + by + c = 0.
  • Get the 2 lines intersection point.
  • Project a point onto a line.
  • Get the distance between a point ad a line.

Documentations: lines

βž— fraction

Documentation: fraction

πŸ“œ License

Copyright (Β©) 2020 sciCaveβ„’ scicaveteam@gmail.com

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.