Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Line's find_index_at_position() method returns wrong indices in some instances #1230

Closed
natabma opened this issue Mar 3, 2025 · 2 comments
Labels

Comments

@natabma
Copy link

natabma commented Mar 3, 2025

I just came across this: the find_index_at_position method of the Line Class seems to return faulty indices. My intent was to enter a new point at a certain position on the Line and to make that point the very first one of the vertices.

Only for some of my lines, the returned index was more than 200 off the correct value. I am so sorry, i cannot share the line data but i can try to share the code reproduce it? if it helps i can try to send the exact line i am showcasing here.

I tried my best to make some kind of minimal example:

lines_long_after_seam_order=[]
eval_fraction=tens_liner_instance.seam_position

line=lines_long[27]


eval_fraction=0.28
new_idx_0_point=line.eval(eval_fraction)
idx_fraction=line.find_index_at_position(new_idx_0_point)
idx_before=math.floor(idx_fraction)
idx_after=math.ceil(idx_fraction)
vertices_new=[[new_idx_0_point],line.vertices[idx_after:-1],line.vertices[0:idx_before]]
vertices_new=list(chain.from_iterable(vertices_new))
line_new=vedo.Line(vertices_new,closed=True)

lines_long_after_seam_order.append(line_new)

idx=0
labs=lines_long_after_seam_order[idx].labels2d()
vedo.show([lines_long_after_seam_order[idx],labs])

As the image shows, the sampled point was not between the identified indices, but somewhere entirely else:
Image

@marcomusy
Copy link
Owner

Hi
Thanks for reporting the issue, after some investigation I think I found the problem.
I wrote a small test script to verify that the behavior is now correct:

tests/issues/issue_1230.py

Image

@marcomusy
Copy link
Owner

I forgot to mention that you will need to install the latest dev version:

pip install -U git+https://github.com/marcomusy/vedo.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants