Skip to content

Allows for calculation of many types of distance between points

License

Notifications You must be signed in to change notification settings

DivineOmega/php-distance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Distance

Build Status Coverage Status Packagist

The PHP Distance library allows for calculation of many types of distance between points.

Installation

PHP Distance can be easily installed using Composer. Just run the following command from the root of your project.

composer require divineomega/php-distance

If you have never used the Composer dependency manager before, head to the Composer website for more information on how to get started.

Usage

See the following code snippet that demonstates how to use this library.

$a = new Point($x1, $y1);
$b = new Point($x2, $y2);
$c = new Point($x3, $y3, $z3); # Infinite dimensions supported by some distance types

$distanceType = new Euclidean();
$distanceType = new EuclideanSquare();
$distanceType = new Haversine();	# For GPS coordinates (latitude and longitude)

$distance = (new Distance())
		->type(new Euclidean())	# Type is optional, and defaults to Euclidean distance
		->from($a)
		->to($b)
		->get();

About

Allows for calculation of many types of distance between points

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages