Hardware accelerated ray-triangle intersection

버전 1.2.0.0 (35.6 KB) 작성자: Thomas Seers
GPU portable implementation of the ray-triangle intersection method of Moller and Trumbore (1997)
다운로드 수: 841
업데이트 날짜: 2015/2/13

라이선스 보기

% Ray-triangle intersection algorithm of Muller and Trumbore (1997)
% formatted for arrayfun to allow hardware acceleration
% Call with gpuarray and arrayfun to execute on the GPU: thjs
% may give two orders of magnitude speed up over vectorized
% cpu based implementation
% INPUT:
% P0x, P0y, P0z / P1x, P1y, P1z / P2x, P2y, P2z: xyz components of the
% triangle objects
% orx, ory, orz: xyz componants of the ray origin
% Dx, Dy, Dz: xyz components of the ray directional (unit) vectors
% OUTPUT:
% distOut: distance from from the ray-tri intersection to the origin or nan
% if no intersection is located
% flag: logical where true indicates intersection and false indicates
% no intersection
% Usage example:
% Step 1: convert mx3 direction vectors, D = [Dx Dy Dz] to gpuarray object
% >> gD = gpuArray(D);
% Step 2: call rayTriGPU using arrayfun with scalar input formatting
% where P0, P1, P2 are the nx3 vertex lists of the triangle corner points
% and where or is the xyz coordinates of the origin
% >> [dist, flag] = arrayfun(@rayTriGPU, P0(:,1)', P0(:,2)', P0(:,3)', ...
% P1(:,1)', P1(:,2)', P1(:,3)', ...
% P2(:,1)', P2(:,2)', P2(:,3)', ...
% or(:,1), or(:,2), or(:,3), ...
% gD(:,1),gD(:,2),gD(:,3));
% Step 3: recover data
% distances = gather(dist);
% Output is an mxn array containing a the distance from the ray-tri
% intersection to the origin or nan if no intersection is located
% Implentation based upon that of Paul Peeling (originally from Jesus P.
% Mena-Chalco of FEX), MathWorks (which returns a flag but not the
% intersection distance).

% Per ray flags can be obtained from the output dist using the following
% method:
% >> flagT = true(size(D,1),1);
% >> flagT(sum(isnan(dist),2) == size(P0,1)) = false;
% This may save transfer time off the GPU

% Dependencies: requires Parallel Computing Toolbox
% Test data (testDataTri.mat) is provided with the package

% references
% Fast, Minimum Storage Ray/Triangle Intersection, Möller & Trumbore.
% Journal of Graphics Tools, 1997.

인용 양식

Thomas Seers (2024). Hardware accelerated ray-triangle intersection (https://www.mathworks.com/matlabcentral/fileexchange/49670-hardware-accelerated-ray-triangle-intersection), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2013a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 GPU Computing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.2.0.0

Changed description to match new function output (distOut)

1.1.0.0

Changed output to avoid potential conflict with the built-in function: dist

1.0.0.0