PHP code example of anton-panfilov / 1d-integer-geometry

1. Go to this page and download the library: Download anton-panfilov/1d-integer-geometry library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anton-panfilov / 1d-integer-geometry example snippets


$result = Exclude::exclude(
    Shape::s(-9, 5),
    Shape::s(-10, 10)
);

$result = Intersects::getIntersectsShape(
    Shape::s(0, 10),
    Shape::s(5, 15)
);
// Shape::s(5, 10)

$result = Intersects::getIntersectsShape(
    Shape::s(0, 10),
    Shape::s(10, 15)
);
// Shape::p(10)


$result = Intersects::intersectsShapes(
    Shape::p(10),
    Shape::s(5, 34)
);
// true

$result = Intersects::intersectsShapes(
    Shape::vp(10),
    Shape::s(5, 7)
);
// false

$point = Shape::p(10);
$segment = Shape::s(-9, 5);

// Convert Point or Segment to Segment (with point1 <= point2)
$segment = Shape::segment_strict(Shape::p(5)); // expected: Shape::s(5, 5)