필터 지우기
필터 지우기

How to detect when 2 surface plots collide ?

조회 수: 5 (최근 30일)
Aiden
Aiden 2023년 11월 6일
댓글: Aiden 2023년 12월 11일
Hi,
I am creating a pipe work system using matlab script where the pipe is represented using surface plot. I want to be able to flag up a warning when 2 surface plots (pipes) clash with each other.
The script determins the direction of the pipe by searching the workspace data for pipe start nodes (SN) and end nodes (EN) (added to workspace before hand). It will then do the checks SNx - ENx~=0 , SNy-ENy~=0, SNz-ENz~=0. depending on the check results the pipe will be plotted in the order of X-section (if check ~=0), Y- section (if check ~=0) then Z- section (if check ~=0).
The 2 pipes I have clashing, 1 is only X-direction section of pipe and the clashing pipe is only Y-direction section of pipe.
looking for some code to add to my script that will flag up the collision ?
thank you.

채택된 답변

Harsha Vardhan
Harsha Vardhan 2023년 11월 17일
Hi,
I understand that you want to detect a collision between two surface plots (representing pipes) in MATLAB.
There are a few strategies you can employ.
Bounding Box Intersection Method: This method involves creating a bounding box around each pipe segment and then checking if these boxes intersect. This is a more straightforward approach but can be less accurate if your pipes are very thin or have complex shapes.
Steps:
  • Calculate the axis-aligned bounding box (AABB) for each pipe segment. The AABB can be defined by the minimum and maximum coordinates along each axis.
  • Check if the AABBs of two pipe segments intersect. AABBs intersect if they overlap along all three axes (X, Y, Z).
Discretization and Spatial Hashing: This method involves discretizing the space into a grid and marking which cells are occupied by each pipe. Then, you can easily check if a cell is occupied by more than one pipe.
Steps:
  • Discretize your workspace into a 3D grid.
  • For each pipe segment, determine which grid cells it occupies.
  • Check for collisions by identifying grid cells that are occupied by more than one pipe.
Using ‘checkCollision' function from Robotic System Toolbox: This function checks if 2 geometries are in collision. You may have to map your surface plot to those geometries. Please find the documentation here - https://www.mathworks.com/help/robotics/ref/checkcollision.html
Hope this helps in resolving your query!
  댓글 수: 1
Aiden
Aiden 2023년 12월 11일
thank you Harsha, this helped a lot !

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gate-Based Quantum Computing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by