8000 GitHub - kirara-shiroyoru/const_math
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kirara-shiroyoru/const_math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This package includes several "constable math functions" that can be called at compile-time which dart:math mostly cannot, returning const double, and can be used as compile-time constants.

They are const constructors of extension type on double implements double, therefore can be used just like normal double, with almost 0 cost.

Note

This package is not and will not be optimized for runtime, if runtime optimization is needed for calculations, then consider using 'dart:math' or other libraries.

Features

Constants

  • ConstMath.pi()
  • ConstMath.e()

Basic functions

  • ConstMath.abs(num d)
  • ConstMath.sgn(num d)
  • ConstMath.min(num a, num b, [num c, num d, num e, num f, num g, num h, num i, num j])
  • ConstMath.max(num a, num b, [num c, num d, num e, num f, num g, num h, num i, num j])
  • ConstMath.degToRad(num d)
  • ConstMath.radToDeg(num d)

Trigonometric functions

  • ConstMath.sin(num d)
  • ConstMath.cos(num d)
  • ConstMath.tan(num d)
  • ConstMath.cot(num d)
  • ConstMath.sec(num d)
  • ConstMath.csc(num d)

Log functions

  • ConstMath.log(num d)
  • ConstMath.log2(num d)
  • ConstMath.log10(num d)

Exponent functions

  • ConstMath.exp(num d)
  • ConstMath.pow(num a, num b)

Inverse trigonometric functions

  • ConstMath.asin(num d)
  • ConstMath.acos(num d)
  • ConstMath.atan(num d)
  • ConstMath.atan2(num y, num x)

Root functions

  • ConstMath.sqrt(num d)
  • ConstMath.cbrt(num d)
  • ConstMath.rt5(num d)
  • ConstMath.rt7(num d)

Hyperbolic trigonometric functions

  • ConstMath.sinh(num d)
  • ConstMath.cosh(num d)
  • ConstMath.tanh(num d)
  • ConstMath.coth(num d)
  • ConstMath.sech(num d)
  • ConstMath.coth(num d)

Error functions

  • ConstMath.erf(num d)
  • ConstMath.erfc(num d)

Getting started

In pubspec.yaml, add

dependencies:
  const_math: ^1.0.2

and run pub get. Import the package with

import 'package:const_math/const_math.dart';

Usage

ConstMath has compile-time math functions that dart:math does not provide, implemented by extension type on double.

const mySinValue = ConstMath.sin(3);

If ConstMath feels too verbose, then you can do something like this:

typedef CM = ConstMath;
const seventhRoot2 = CM.rt7(2);

These values can also be passed as argument to other const constructors, or inside another ConstMath function.

const sinOfSin1 = CM.sin(CM.sin(1));

Additional information

If you need support or to report bugs, email: const_math_support@worldoverwrite.com

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0