summaryrefslogtreecommitdiff
path: root/inst/geom2d/parallelLine.m
diff options
context:
space:
mode:
authorRafael Laboissiere <rafael@debian.org>2017-04-08 18:30:33 -0300
committerRafael Laboissiere <rafael@debian.org>2017-04-08 18:30:33 -0300
commit87f1c69f10eb490ae5bdfbd551ba386b58e199e3 (patch)
tree5bee8ef68534e6e37fb38a4b2a2795a61ffc62d9 /inst/geom2d/parallelLine.m
parent4c6951e2fb58d0176029a222b07633bf2854b090 (diff)
New upstream version 3.0.0
Diffstat (limited to 'inst/geom2d/parallelLine.m')
-rw-r--r--inst/geom2d/parallelLine.m31
1 files changed, 19 insertions, 12 deletions
diff --git a/inst/geom2d/parallelLine.m b/inst/geom2d/parallelLine.m
index 93e8575..d59816b 100644
--- a/inst/geom2d/parallelLine.m
+++ b/inst/geom2d/parallelLine.m
@@ -2,16 +2,16 @@
## Copyright (C) 2004-2011 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas)
## Copyright (C) 2012 Adapted to Octave by Juan Pablo Carbajal <carbajal@ifi.uzh.ch>
## All rights reserved.
-##
+##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
-##
+##
## 1 Redistributions of source code must retain the above copyright notice,
## this list of conditions and the following disclaimer.
## 2 Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
-##
+##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ''AS IS''
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -29,7 +29,7 @@
## Create a line parallel to another one.
##
## Returns the line with same direction vector than @var{line} and going through
-## the point given by @var{point}.
+## the point given by @var{point}.
## @var{line} is given as [x0 y0 dx dy] and @var{point} is [xp yp].
##
## Uses relative distance to specify position. The new line will be
@@ -39,17 +39,24 @@
## @seealso{lines2d, orthogonalLine, distancePointLine}
## @end deftypefn
-function res = parallelLine(line, point)
+function res = parallelLine (l, point)
- if size(point, 1)==1
- # use a distance. Compute position of point located at distance DIST on
- # the line orthogonal to the first one.
- point = pointOnLine([line(:,1) line(:,2) line(:,4) -line(:,3)], point);
+ if size (point, 2) == 1
+ # use a distance. Compute position of point located
+ # at distance DIST on the line orthogonal to the first one.
+ point = pointOnLine ([l(:,[1 2 4]) -l(:,3)], point);
end
# normal case: compute line through a point with given direction
- res = zeros(1, 4);
- res(1:2) = point;
- res(3:4) = line(3:4);
+ res = zeros (size (l, 1), 4);
+ res(:,1:2) = point;
+ res(:,3:4) = l (:, 3:4);
endfunction
+
+%!demo
+%! l = createLine ([0,0],[1,1]);
+%! lp = parallelLine (l, [0,1]);
+%! plot (0,1,'.r',1,1,'.g');
+%! axis ([-1 1 -1 1])
+%! drawLine([l; lp]);