Coordinate offsets

• A Taichi field can be defined with coordinate offsets. The offsets will move field bounds so that field origins are no longer zero vectors. A typical use case is to support voxels with negative coordinates in physical simulations.
• For example, a matrix of 32x64 elements with coordinate offset (-16, 8) can be defined as the following:
a = ti.Matrix.field(2, 2, dtype=ti.f32, shape=(32, 64), offset=(-16, 8))

In this way, the field's indices are from (-16, 8) to (16, 72) (exclusive).

a[-16, 8]  # lower left cornera[16, 8]   # lower right cornera[-16, 72]  # upper left cornera[16, 72]   # upper right corner
note

The dimensionality of field shapes should be consistent with that of the offset. Otherwise, a AssertionError will be raised.

a = ti.Matrix.field(2, 3, dtype=ti.f32, shape=(32,), offset=(-16, ))          # Works!b = ti.Vector.field(3, dtype=ti.f32, shape=(16, 32, 64), offset=(7, 3, -4))   # Works!c = ti.Matrix.field(2, 1, dtype=ti.f32, shape=None, offset=(32,))             # AssertionErrord = ti.Matrix.field(3, 2, dtype=ti.f32, shape=(32, 32), offset=(-16, ))       # AssertionErrore = ti.field(dtype=ti.i32, shape=16, offset=-16)                              # Works!f = ti.field(dtype=ti.i32, shape=None, offset=-16)                            # AssertionErrorg = ti.field(dtype=ti.i32, shape=(16, 32), offset=-16)                        # AssertionError