How to convert CAD file to points on 3D grid? [URGENT]

조회 수: 8 (최근 30일)
Jens Sonck
Jens Sonck 2021년 3월 21일
댓글: Ali Grysah 2021년 4월 2일
Hi,
For a project I'm working on, I need to calculate the buoyancy force on a boats hull. The buoyancy of a hull is the volume of the part under the fluid surface multiplied by the density of the fluid. I wrote a little script to calculate that volume and center of that volume (from list of coordinates of subvolumes) to have the magnitude of the force and the point of engagement.
The only thing I need to do now is to convert my CAD model into a set of points (subvolumes) with x,y and z coordinates. My Idea was to do this manually but I need about 2000 points. Is there a way to convert my CAD model to a set of point on a fixed 3D grid? Basically like when you want to make someting in minecraft, an array with al the coordinates of where the blocks would be placed.
Afterthought: I basically want to check if a point on my 3d grid (which will define the 'mesh' size) is within the boundaries of the CAD model and then add it to the list of points.
UPDATE:
I got the alphashape thing working but the shape it produces is off. The concave part of my model is skipped (see pictures) I tried playing with the alpha, region and hole parameters and that kinda fixes the front but messes up the back.
Thanks in advance
Jens
  댓글 수: 8
Precise Simulation
Precise Simulation 2021년 3월 31일
I think you could import your CAD model into the PDE or FEATool Multiphysics toolboxes, generate a volume mesh, and use the (Delaunay) mesh to check which points are in or outside of the mesh using for example tsearchn "tsearchn(X,TRI,XI) returns the indices t of the triangulation TRI for each point in XI, and NaN for all points outside the convex hull of X".
Ali Grysah
Ali Grysah 2021년 4월 2일
  • hlo can help me i need matlab 2008 ,,,windows7,32bt

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

채택된 답변

darova
darova 2021년 3월 21일
Try alphaShape with inShape option
  댓글 수: 14
Jens Sonck
Jens Sonck 2021년 3월 23일
@darova I've attached a .zip with the model and the lines that give me the error, hope this clears things up.
Jens Sonck
Jens Sonck 2021년 3월 24일
@darova I've got it working but the shape is off. I've updated the original question with pictures.

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

추가 답변 (1개)

darova
darova 2021년 3월 24일
What about this? You can find volume under each triangle using this formula
  댓글 수: 5
darova
darova 2021년 3월 25일
Maybe you don't such precise mesh. alphaShape has function volume for calculation volume
Jens Sonck
Jens Sonck 2021년 3월 25일
My algorithm takes 73ms to calculate 77k points so that's adequate for the simulation. I'm now having trouble in simscape with the dynamics.

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by