Replies: 3 comments 5 replies
-
|
Hi @baba-yaga this may be a precision problem (?) from vedo import *
K = Cube().clean().c('yellow',0.2).lighting('off').lw(3)
plt = Plotter(interactive=False)
plt += K
plt.show()
pos = plt.camera.GetPosition()
hits = []
lines = []
for i in range(8):
pi = K.intersect_with_line(K.vertices[i], pos)
lines.append(Line(K.vertices[i], pos))
hits.extend(pi)
print(f'i={i}, points of intersection:\n {pi}\n')
hits = Points(hits, r=20, c='blue').clean()
plt += lines, hits
print("K.coordinates ", K.coordinates)
print("hits.coordinates", hits.coordinates)
plt.interactive().close()PS: no need to call |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
You are right I think this is an instability/bug in the vtk, so not much I can do to fix it... Eg from vedo import *
K = Cube().clean()
K.rotate_x(45).rotate_y(45).rotate_z(45)
K.c('yellow', 0.25).lighting('off').lw(3)
plt = Plotter()
plt += K
plt.show(interactive=False)
# pos = np.array(plt.camera.GetPosition())
pos = np.array([1,2,-3]) # this works
# pos = np.array([1,2,3]) # this doesnt work
print(f'camera position: {pos}')
for i in range(8):
pip = Points(K.intersect_with_line(K.vertices[i], pos)).clean()
plt.add(pip.ps(10).c("blue5"))
plt.add(Line(K.vertices[i], pos).c("red5"))
print(f'i={i}, points of intersection: {pip.vertices}')
plt.show(axes=1, interactive=True).close() |
Beta Was this translation helpful? Give feedback.
1 reply
-
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment




Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, Marco. I discovered the following unexpected behaviour of the mentioned procedure.
Draw a cube and identify its visible vertices from the cam:
Reproduce the plot with visible vertices marked in blue:
No vertex is detected as visible! The code fails because the intersections pi for the front vertices contain duplicated points - the vertices themselves.
The behaviour seems to be related to the angle between the view line and the gradient at the vertex. If you redefine

K = K.rotate_x(45).rotate_y(45).rotate_z(45)the closest vertex is detected, but the others still not
Beta Was this translation helpful? Give feedback.
All reactions