getLinesParallelToAxis method

List<List<Line>> getLinesParallelToAxis(
  1. NumberLine axis1,
  2. NumberLine axis2,
  3. double freq,
  4. double ratio,
)

Implementation

List<List<Line>> getLinesParallelToAxis(
    NumberLine axis1, NumberLine axis2, double freq, double ratio) {
  var line = Line(start: axis1.getStart(), end: axis1.getEnd());
  var denseFreq = 1 + ratio;
  var step = (1 / denseFreq) * freq;

  var lines1 = <Line>[];
  var lines2 = <Line>[];

  var ranges = [
    arange(start: 0, end: axis2.xMax, step: step).getColumn(0),
    arange(start: 0, end: axis2.xMin, step: -step).getColumn(0),
  ];

  for (var inputs in ranges) {
    for (var kx in enumerate(inputs)) {
      var k = kx.item1;
      var x = kx.item2;

      var newLine = line.copy()..shift(axis2.n2p(x));

      if (k % (1 + ratio) == 0) {
        lines1.add(newLine);
      } else {
        lines2.add(newLine);
      }
    }
  }

  return [lines1, lines2];
}