MCPcopy Create free account
hub / github.com/Notgnoshi/generative / _drop_coord

Function _drop_coord

generative/projection.py:126–141  ·  view source on GitHub ↗

Project the given 3D geometry objects onto one of the standard 2D bases.

(tagged_points: TaggedPointSequence, basis: str, scale)

Source from the content-addressed store, hash-verified

124
125
126def _drop_coord(tagged_points: TaggedPointSequence, basis: str, scale) -> TaggedPointSequence:
127 """Project the given 3D geometry objects onto one of the standard 2D bases."""
128 # Do not allow flips. That is, you cannot reorder coordinates, only drop.
129 if basis == "xy":
130 coord = 2
131 elif basis == "xz":
132 coord = 1
133 elif basis == "yz":
134 coord = 0
135 else:
136 raise ValueError(f"Unsupported basis for dropping coordinates '{basis=}'")
137 points, tags = unzip(tagged_points)
138 for point, tag in zip(_zeropad_3d(points), tags):
139 point = (*point[:coord], *point[coord + 1 :])
140 point = tuple(scale * c for c in point)
141 yield point, tag

Callers 1

projectFunction · 0.85

Calls 2

unzipFunction · 0.85
_zeropad_3dFunction · 0.85

Tested by

no test coverage detected