nest2D
nest2D copied to clipboard
add area, translation and rotation attrs to Item
This adds translation, rotation and area attributes to the Item class. As I mentioned in #3, this may help with applying textures or image overlays to transformed features.
The returned rotation is in radians. The returned translation is a Point that can be interpreted as a vector.
An example:
import nest2D as n2d
item = n2d.Item([n2d.Point(10, 10), n2d.Point(10, 12), n2d.Point(12, 12), n2d.Point(10, 10)])
packing = n2d.nest([item] * 10, n2d.Box(100, 100))
[p.rotation for p in packing[0]]
# [0.0, 3.141592653589793, 0.0, 1.5707963267948966, 3.141592653589793, 0.0, ...]
[p.translation for p in packing[0]]
# [Point(39, 39), Point(61, 60), Point(38, 40), Point(60, 38), Point(62, 59), ...]
Disabling Rotation would be a plus as well
If that's a feature of libnest2d, it should theoretically be possible to reflect in the Python bindings. I think it's a little outside of the scope of this update, though.