create a mesh grid from major and minor values.

given two arrays major_values and minor_values, this function generates a pair of 2D arrays representing the major-grid and minor-grid. the major-grid contains rows of major_values, and the minor-grid contains columns of minor_values.

import { assertEquals } from "jsr:@std/assert"

const
y_values = [1, 2, 3],
x_values = [4, 5],
[yy_grid, xx_grid] = meshGrid(y_values, x_values)
assertEquals(yy_grid, [
[1, 1],
[2, 2],
[3, 3],
])
assertEquals(xx_grid, [
[4, 5],
[4, 5],
[4, 5],
])
  • Type Parameters

    • T

    Parameters

    • major_values: T[]

      the values to be used as rows in the major-grid

    • minor_values: T[]

      the values to be used as columns in the minor-grid

    Returns [major_grid: Array2D<T>, minor_grid: Array2D<T>]

    a 2-tuple containing the major-grid and minor-grid as 2D arrays