aguimaraes/spiral

Generates spirals



Documentation

Build Status StyleCI Codacy Badge

Archimedean Spiral Generator

This library will generate a collection (array) of points (SpiralPoint) that will form a perfect Archimedean Spiral.

Usage

$builder = new Builder();
$builder->setTotal(3);
var_dump($builder->generate());

This will print:

array:3 [
  0 => Aguimaraes\Spiral\SpiralPoint {
    #x: 0
    #y: 0
  }
  1 => Aguimaraes\Spiral\SpiralPoint {
    #x: 1
    #y: 0
  }
  2 => Aguimaraes\Spiral\SpiralPoint {
    #x: 1
    #y: 1
  }
]

Advanced Example

The expected spiral:

Expected Archimedean Spiral

The code:

$builder = new Builder();
$builder->setTotal(74);
$builder->setStep(3);
$builder->generate();

Parameters

  • Total: The number of points that should be generated.
$builder = new Builder();
$builder->setTotal(120);
$builder->generate();

that will create 120 points.

  • Step: How much points before the first turn.
$builder = new Builder();
$builder->setTotal(74);
$builder->setStep(3);
$builder->generate();

that will generate 74 points with the first turning point being 3 points away