neso_fame.offset.Offset(obj: T, x3_offset: float) T

Offset the object in the x3-direction.

This function wraps an object so that it has an associated offset in the x3-direction. The wrapper will then forward all attribute lookup to the wrapped object, but wrap the result with the offset again. The same applies to function calls. If the result has an offset method (e.g., if it is a Coord object or similar), then that is called instead.

There is a bit of a hack here. Because the Python type-system doesn’t have a good way to express all attribute lookup being forwarded to the wrapee, this function falsely claims to return the original type. This means mypy will think that it can perform all the usual operations on the wrapped type, but at the cost of losing some information about the real type of the object involved. This is considered a reasonable tradeoff, as the whole point of the offsetting is that the objects should behave indistinguishably.


Last update: Sep 23, 2024