Closed DavideBassano closed 6 years ago
Hi Davide,
Besides the main branch, there is a branch called "intersection" that contains another notebook that has what you want. The file is https://github.com/mhogg/pyoctree/blob/Intersection/pyoctree/Examples/pyoctree-intersection.ipynb. This code gets all the triangle faces involved in an intersection and then calculates the angle between the triangle face normal and the ray vector to determine if the intersection point is an entry point (face normal is opposite direction to the ray) or an exit point (face normal is in the same direction to the ray).
To find the angle (in radians), you can calculate the inverse cosine of the dot product between the face normal and ray vector.
Cheers, Michael
Hi Michael, thank you very much for your answer.
I looked at this code ( https://github.com/mhogg/pyoctree/blob/Intersection/pyoctree/Examples/pyoctree-intersection.ipynb ) and I have a problem with In[17]:
# Get intersection points for a single ray ray = rayPointList[0] for i in tree.rayIntersection(ray): print('Intersected tri = %d,' % i.triLabel, 'Intersection coords = [%.2f, %.2f, %.2f]' % tuple(i.p), ', Parametric. dist. along ray = %.2f' % i.s)
AttributeError: 'pyoctree.pyoctree.Intersect' object has no attribute 'triLabel'
The fact is that when I type "i." Pycharm suggests me p, s and also triLabel!
Do you know why?
Thanks, Cheers,
Davide
Hi Davide,
I made several changes to the code in the "Intersection" branch. triLabel was something that was added in that branch, but will not exist in the main branch. Therefore you will have to download the entire "Intersection" branch code, not just the notebook.
Cheers, Michael
Dear Michael,
Thanks for your replies. Once I downloaded the entire "Intersection" branch code (now I have my "pyoctree-Intersection" folder with all the files inside (build folder, LICENSE.txt, setup.py, ...), what I have to do to install/use it?
Thanks, Cheers, Davide
Hi Davide, I am assuming that you installed pyoctree via pip? I would uninstall this one, download v0.2.5_rc1 from the releases page and install that instead. There is a python wheel for windows and python 3.6, which can be installed via pip. If you are on Linux or Mac you will have to run the setup.py file. See the readme for install instructions. Cheers Michael
Actually I installed pyoctree from PyCharms' UI, but it only has 0.2.4 version. I downloaded version 0.2.5 and installed it from the terminal. Now that version 0.2.5 is installed (somewhere and somehow), how can I use it in Pycharm?
Thanks, Cheers,
Davide Bassano
Dear Michael,
now everything works: I downloaded wheel file and ran
pip install pyoctree-0.2.4-cp27-cp27m-win_amd64.whl
in PyCharm Terminal.
Thank you for your help, Have a nice day, Cheers, Davide Bassano
Hello,
I used this code ( https://github.com/mhogg/pyoctree/blob/master/pyoctree/Examples/pyoctree-intro.ipynb ) to calculate intersection points between a triangular mesh and a ray. I need the angle between my ray and the normal of intersected face. Is there a way to get the normal vectors of intersected faces?
Thanks,
Davide Bassano