Home > matGeom > geom3d > projLineOnPlane.m

projLineOnPlane

PURPOSE ^

PROJLINEONPLANE Return the orthogonal projection of a line on a plane.

SYNOPSIS ^

function [newLine, isOrthogonal] = projLineOnPlane(line, plane)

DESCRIPTION ^

PROJLINEONPLANE Return the orthogonal projection of a line on a plane.
 
   NEWLINE = PROJLINEONPLANE(LINE, PLANE) Returns the orthogonal
   projection of LINE or multiple lines on the PLANE.

   [..., ISORTHOGONAL] = PROJLINEONPLANE(LINE, PLANE) Also returns if the
   LINE is orthogonal to the PLANE.

   Example
     plane = [.1 .2 .3 .4 .5 .6 .7 .8 .9];
     lines = [0 .3 0 1 0 0;0  .5 .5 0 0 1;...
         .4 .1 .5 1 0 2;.2 .7 .1 0 1 0;...
         plane(1:3) planeNormal(plane)];
     [newLines, isOrthogonal] = projLineOnPlane(lines, plane);
     figure('color','w'); axis equal; view(3)
     drawLine3d(lines,'b')
     drawPlane3d(plane)
     drawLine3d(newLines(~isOrthogonal,:), 'r')

   See also
   planes3d, lines3d, intersectLinePlane, projPointOnPlane

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [newLine, isOrthogonal] = projLineOnPlane(line, plane)
0002 %PROJLINEONPLANE Return the orthogonal projection of a line on a plane.
0003 %
0004 %   NEWLINE = PROJLINEONPLANE(LINE, PLANE) Returns the orthogonal
0005 %   projection of LINE or multiple lines on the PLANE.
0006 %
0007 %   [..., ISORTHOGONAL] = PROJLINEONPLANE(LINE, PLANE) Also returns if the
0008 %   LINE is orthogonal to the PLANE.
0009 %
0010 %   Example
0011 %     plane = [.1 .2 .3 .4 .5 .6 .7 .8 .9];
0012 %     lines = [0 .3 0 1 0 0;0  .5 .5 0 0 1;...
0013 %         .4 .1 .5 1 0 2;.2 .7 .1 0 1 0;...
0014 %         plane(1:3) planeNormal(plane)];
0015 %     [newLines, isOrthogonal] = projLineOnPlane(lines, plane);
0016 %     figure('color','w'); axis equal; view(3)
0017 %     drawLine3d(lines,'b')
0018 %     drawPlane3d(plane)
0019 %     drawLine3d(newLines(~isOrthogonal,:), 'r')
0020 %
0021 %   See also
0022 %   planes3d, lines3d, intersectLinePlane, projPointOnPlane
0023 
0024 % ------
0025 % Author: oqilipo
0026 % E-mail: N/A
0027 % Created: 2017-08-06
0028 % Copyright 2017-2024
0029 
0030 p1 = projPointOnPlane(line(:,1:3), plane);
0031 p2 = projPointOnPlane(line(:,1:3)+line(:,4:6), plane);
0032 
0033 newLine=createLine3d(p1, p2);
0034 isOrthogonal = ismembertol(p1,p2,'ByRows',true);
0035 
0036

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022