Geometry Kit 

0
486

A set of utils that help with geometry (line, circle, triangle, polygon,…)

Features 

  • distance from a point to a line
  • check if to line segments intersect
  • find intersect point of 2 line segments
  • get area or perimeter of shapes,
  • calculate circumcircle or incircle of a polygon
  • check if a point is in side a polygon

Installing the library: 

Like any other package, add the library to your pubspec.yaml dependencies:

dependencies:
    geometry_kit: <latest_version>

Then import it wherever you want to use it:

import 'package:fetching_state/fetching_state.dart';

Usage 


  // Line
  final line1 = Line(Point(0, 2), Point(2, 0));
  final line2 = Line(Point(0, -1), Point(3, 2));

  final intersect = LineUtils.getSegmentIntersect(line1, line2);

  print(intersect); //Point(1.5, 0.5)
//Polygon
  final polygon = [
    Point(1, 0),
    Point(0, 2),
    Point(0, 3),
    Point(2, 5),
    Point(3, 5),
    Point(5, 3),
    Point(5, 1),
    Point(3, 0),
  ];

  final point1 = Point<num>(5, 2);
  var isInside = PolygonUtils.isInsidePolygon(point1, polygon);
  print(isInside); // true

repo: https://github.com/samderlust/geometry_kit

pub: https://pub.dev/packages/geometry_kit

LEAVE A REPLY

Please enter your comment!
Please enter your name here