-
Nicola Vigano authored
Signed-off-by:
Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@154 4c865b51-4357-4376-afb4-474e03ccb993
Nicola Vigano authoredSigned-off-by:
Laura Nervo <laura.nervo@esrf.fr> git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@154 4c865b51-4357-4376-afb4-474e03ccb993
gtLinePlaneIntersection.m 815 B
function isec=gtLinePlaneIntersection(l,p)
%
% FUNCTION is=gtLinePlaneIntersection(l,p)
%
% Computes the intersection of a line with several planes.
%
% INPUT: l: line parameters (1x6) [l0x l0y l0z ldirx ldiry ldirz]
% p: planes parameters (nx6) [p0x p0y p0z pnormx pnormy pnormz]
%
% ,where ldir and pnorm do not need to be normalized.
%
% OUTPUT: isec: intersection points respectively (nx3) [X Y Z]
%
% Equations:
% t = (plane_0-line_0)*plane_dir/(plane_dir*line_dir)
% isec = line_0+line_dir*t
% For one plane only:
% t=((p(1)-l(1))*p(4)+(p(2)-l(2))*p(5)+(p(3)-l(3))*p(6))/...
% (l(4)*p(4)+l(5)*p(5)+l(6)*p(6));
% isec=l(1:3)+l(4:6)*t;
%
l0=repmat(l(1:3),size(p,1),1);
ld=repmat(l(4:6),size(p,1),1);
t=sum((p(:,1:3)-l0).*p(:,4:6),2)./(p(:,4:6)*l(4:6)');
isec=l0+ld.*[t t t];
end