INTERSECTLINECYLINDER Compute intersection points between a line and a cylinder. POINTS = intersectLineCylinder(LINE, CYLINDER) Returns intersection points between a line and a cylinder. Input parameters: LINE = [x0 y0 z0 dx dy dz] CYLINDER = [x1 y1 z1 x2 y2 z2 R] Output: POINTS = [x1 y1 z1 ; x2 y2 z2] POINTS = intersectLineCylinder(LINE, CYLINDER, 'checkBounds', B) Where B is a boolean (TRUE by default), check if the points are within the bounds defined by the two extreme points. If B is false, the cylinder is considered to be infinite. Example % Compute intersection between simple vertical cylinder and line line = [60 60 60 1 2 3]; cylinder = [20 50 50 80 50 50 30]; points = intersectLineCylinder(line, cylinder); % Display the different shapes figure; drawCylinder(cylinder); hold on; light; axis([0 100 0 100 0 100]); drawLine3d(line); drawPoint3d(points, 'ko'); % Compute intersections when one of the points is outside the % cylinder line = [80 60 60 1 2 3]; cylinder = [20 50 50 80 50 50 30]; intersectLineCylinder(line, cylinder) ans = 67.8690 35.7380 23.6069 See also lines3d, intersectLinePlane, drawCylinder, cylinderSurfaceArea References See the link: http://www.gamedev.net/community/forums/topic.asp?topic_id=467789
Package: matgeom