docs/lang/articles/basic/offset.md
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 corner
a[15, 8] # lower right corner
a[-16, 71] # upper left corner
a[15, 71] # 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,)) # AssertionError
# d = ti.Matrix.field(3, 2, dtype=ti.f32, shape=(32, 32), offset=(-16, )) # AssertionError
e = ti.field(dtype=ti.i32, shape=16, offset=-16) # Works!
# f = ti.field(dtype=ti.i32, shape=None, offset=-16) # AssertionError
# g = ti.field(dtype=ti.i32, shape=(16, 32), offset=-16) # AssertionError