Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions genesis/utils/geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1162,18 +1162,20 @@ def _np_z_up_to_R(z, up=None, out=None):
z[:] = 0.0, 1.0, 0.0

if up is not None:
x[:] = np.cross(up[i], z)
a = up[i]
else:
x[0] = z[1]
x[1] = -z[0]
x[2] = 0.0
a = np.array([0.0, 1.0, 0.0], dtype=z.dtype)

x[:] = np.cross(a, z)
x_norm = np.linalg.norm(x)
if x_norm > gs.EPS:
x /= x_norm
y[:] = np.cross(z, x)
else:
R[:] = np.eye(3, dtype=R.dtype)

if x_norm <= gs.EPS:
a_fallback = np.array([1.0, 0.0, 0.0], dtype=z.dtype)
x[:] = np.cross(a_fallback, z)
x_norm = np.linalg.norm(x)

x /= x_norm
y[:] = np.cross(z, x)

return out_

Expand Down
2 changes: 1 addition & 1 deletion genesis/utils/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def create_arrow(
def create_line(start, end, radius=0.002, color=(1.0, 1.0, 1.0, 1.0), sections=12):
vec = end - start
length = np.linalg.norm(vec)
mesh = create_cylinder(radius, length, sections) # along z-axis
mesh = create_cylinder(radius, length, sections, color) # along z-axis
mesh._data["vertices"][:, -1] += length / 2.0
mesh.vertices = gu.transform_by_trans_R(mesh._data["vertices"], start, gu.z_up_to_R(vec))
return mesh
Expand Down