Skip to content
Snippets Groups Projects
Commit 077a33a4 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Pushed performance a little bit in gtMathsIsPointInPolyhedron


Signed-off-by: default avatarNicola Vigano <nicola.vigano@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@315 4c865b51-4357-4376-afb4-474e03ccb993
parent d8472c63
No related branches found
No related tags found
No related merge requests found
function ok = gtMathsIsPointInPolyhedron(p, faces)
% GTMATHSISPOINTINPOLYHEDRON Tells if the given point is inside the defined 3D
% polyhedron.
% %
% FUNCTION ok = gtMathsIsPointInPolyhedron(p,faces) % ok = gtMathsIsPointInPolyhedron(p, faces)
% %
% Tells if the given point is inside the defined 3D polyhedron. % INPUT: p(mx3) - [X,Y,Z] coordinates of the point
% % faces(nx6) - coordinates of the facet planes of the polyhedron
% INPUT: p(1x3) - [X,Y,Z] coordinates of the point % [p0x p0y p0z pnormx pnormy pnormz]
% faces(nx6) - coordinates of the facet planes of the polyhedron % pnorm vectors point out of the volume
% [p0x p0y p0z pnormx pnormy pnormz]
% pnorm vectors point out of the volume
%
% OUTPUT: ok - true if the point is inside the polyhedron
% %
% OUTPUT: ok - true if the point is inside the polyhedron
aa = (p(ones(size(faces, 1), 1), :) - faces(:, 1:3)) .* faces(:, 4:6);
function ok = gtMathsIsPointInPolyhedron(p,faces) ok = all(sum(aa, 2) <= 1e-12);
ok = all(sum((repmat(p,size(faces,1),1)-faces(:,1:3)).*faces(:,4:6),2) <= 1e-12); end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment