dart_math 0.0.9+4

  • Readme
  • Changelog
  • Example
  • Installing
  • 69

DartMath #

A simple dart Math Library #

##Example Usage

import 'package:dart_math/algebra.dart';
import 'package:dart_math/dart_math.dart';

main(List<String> arguments) {
  //Intantiate a Fraction Object
  Fraction fractions = new Fraction(3.0, 2.0);
  Fraction fractions1 = new Fraction(5.0, 4.0);
  Fraction fractions2 = new Fraction(5.0, 2.0);
  Fraction sumfrac = fractions.fracAdd(fractions1).fracAdd(fractions2);

//get nominator,denominator, quotient,remainder;
  print(
      'Nominator: ${sumfrac.nominator()} Denominator ${sumfrac.denominator()}');
  print('This is quotient ${sumfrac.quotient()}');
  print('This is remainder ${sumfrac.remainder()}');

  // //Intantiate Line Object
  Line l1 = new Line(y: 1.0, gradient: 2.0, intercept: 3.0);
  Line l2 = new Line(y: 1.0, gradient: -0.5, intercept: 7.0);
  Line l3 = new Line(y: 1.0, gradient: 2.0, x: 1.0);

//Intanciate Cordinates Object
  Cordinates p1 = new Cordinates(x: 1.0, y: 1.0);
  Cordinates p2 = new Cordinates(x: 2.0, y: 3.0);

  print('This is distance ${p1.getdistance(p2)}');
  print('This is Slope ${p1.getslope(p2).getGradient()}');
  print('This is y intercept ${l3.findYintercept()}');

  Cordinates inter;
  Map<String, double> cord;
  //get intersection of two lines
  inter = l1.intersection(l2);
  print(l1.intersection(l2).toLine(p1));
  cord = inter.getcordinates();
  print('These Lines intersect at $cord');

  //Startof Algebra
  Quadratic quadratic = new Quadratic(2.0, -1.0, -1.0);
  print(quadratic.discriminant());
  print(quadratic.roots());

  Line l = new Line(gradient: 2.0, intercept: 2.0, x: 3.0);
  Cordinates c = Cordinates(x: 3.0);
  print('Get y value given X ${c.findY(l).getcordinates()}');

//point of intersection between circle and Line
  Circle c1 = new Circle(
      new Cordinates(x: 2.0, y: -3.0), new Cordinates(x: 2.0, y: 3.0), 2.0);
  c1.lineIntersection(Line(
    gradient: -1.0,
    intercept: -0.5,
  ));

  c1.radius();
}

0.0.1 #

  • Initial version, created by Stagehand

##0.0.9+4

  • Added few more functions

example/main.dart

import 'package:dart_math/algebra.dart';
import 'package:dart_math/dart_math.dart';
main(List<String> arguments) {
  //Intantiate a Fraction Object
  Fraction fractions = new Fraction(3.0, 2.0);
  Fraction fractions1 = new Fraction(5.0, 4.0);
  Fraction fractions2 = new Fraction(5.0, 2.0);
  Fraction sumfrac = fractions.fracAdd(fractions1).fracAdd(fractions2);

//get nominator,denominator, quotient,remainder;
  print(
      'Nominator: ${sumfrac.nominator()} Denominator ${sumfrac.denominator()}');
  print('This is quotient ${sumfrac.quotient()}');
  print('This is remainder ${sumfrac.remainder()}');

  // //Intantiate Line Object
  Line l1 = new Line(y: 1.0, gradient: 2.0, intercept: 3.0);
  Line l2 = new Line(y: 1.0, gradient: -0.5, intercept: 7.0);
  Line l3 = new Line(y: 1.0, gradient: 2.0, x: 1.0);

//Intanciate Cordinates Object
  Cordinates p1 = new Cordinates(x:1.0, y:1.0);
  Cordinates p2 = new Cordinates(x:2.0, y:3.0);

  print('This is distance ${p1.getdistance(p2)}');
  print('This is Slope ${p1.getslope(p2).getGradient()}');
  print('This is y intercept ${l3.findYintercept()}');

  Cordinates inter;
  Map<String, double> cord;
  //get intersection of two lines
  inter = l1.intersection(l2);
  print(l1.intersection(l2).toLine(p1).findYintercept());
  cord = inter.getcordinates();
  print('These Lines intersect at $cord');



  //Startof Algebra
  Quadratic quadratic = new Quadratic(2.0, -1.0, -1.0);
  print(quadratic.discriminant());
  print(quadratic.roots());
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_math: ^0.0.9+4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_math/dart_math.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
53
Health:
Code health derived from static analysis. [more]
94
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
69
Learn more about scoring.

We analyzed this package on Dec 10, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.1+4

Health issues and suggestions

Document public APIs. (-0.33 points)

43 out of 44 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/geometry/cordinates.dart. (-1.99 points)

Analysis of lib/src/geometry/cordinates.dart reported 4 hints:

line 20 col 20: Unnecessary new keyword.

line 27 col 16: Unnecessary new keyword.

line 41 col 25: Unnecessary new keyword.

line 43 col 9: Unnecessary new keyword.

Fix lib/src/geometry/fractions.dart. (-1.99 points)

Analysis of lib/src/geometry/fractions.dart reported 4 hints:

line 39 col 25: Unnecessary new keyword.

line 50 col 25: Unnecessary new keyword.

line 55 col 25: Unnecessary new keyword.

line 61 col 25: Unnecessary new keyword.

Fix lib/src/geometry/circle.dart. (-1 points)

Analysis of lib/src/geometry/circle.dart reported 2 hints:

line 24 col 19: Unnecessary new keyword.

line 27 col 22: Unnecessary new keyword.

Fix additional 3 files with analysis or formatting issues. (-0.50 points)

Additional issues in the following files:

  • lib/src/geometry/lines.dart (1 hint)
  • lib/matrix.dart (Run dartfmt to format lib/matrix.dart.)
  • lib/src/matrix/matrix.dart (Run dartfmt to format lib/src/matrix/matrix.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
Dev dependencies
test ^1.3.0