[Pkg-octave-commit] rev 677 - in trunk/packages/octave-epstk/debian: . patches

Thomas Weber thomas-guest at costa.debian.org
Sun Aug 6 21:28:14 UTC 2006


Author: thomas-guest
Date: 2006-08-06 21:28:13 +0000 (Sun, 06 Aug 2006)
New Revision: 677

Added:
   trunk/packages/octave-epstk/debian/patches/50_add_plotcollapse.patch
Modified:
   trunk/packages/octave-epstk/debian/changelog
   trunk/packages/octave-epstk/debian/copyright
Log:
Inlude plotcollapse.m file; there was no answer to Francesco's mail on Octave's
sources list
(https://www.cae.wisc.edu/pipermail/octave-sources/2006-May/thread.html)


Modified: trunk/packages/octave-epstk/debian/changelog
===================================================================
--- trunk/packages/octave-epstk/debian/changelog	2006-08-02 19:35:45 UTC (rev 676)
+++ trunk/packages/octave-epstk/debian/changelog	2006-08-06 21:28:13 UTC (rev 677)
@@ -1,3 +1,13 @@
+octave-epstk (2.1-4) unstable; urgency=low
+
+  NOT YET RELEASED!
+
+  [ Thomas Weber ]
+  * Add plotcollapse.m script from Francesco Potorti` (Closes: #365757)
+    Update copyright file accordingly.
+
+ -- 
+
 octave-epstk (2.1-3) unstable; urgency=low
 
   * debian/control:

Modified: trunk/packages/octave-epstk/debian/copyright
===================================================================
--- trunk/packages/octave-epstk/debian/copyright	2006-08-02 19:35:45 UTC (rev 676)
+++ trunk/packages/octave-epstk/debian/copyright	2006-08-06 21:28:13 UTC (rev 677)
@@ -30,5 +30,14 @@
    along with this program;  if not, write to the Free Software Foundation, 
    Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
+
+
+The file plotcollapse.m was downloaded from 
+	http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=365757
+
+It is copyrighted by Francesco Potorti` and released 
+under the GNU General Public License. 
+
+
 On a Debian GNU/Linux system, a full copy of the GNU General Public License
 can be found in the file /usr/share/common-licenses/GPL .

Added: trunk/packages/octave-epstk/debian/patches/50_add_plotcollapse.patch
===================================================================
--- trunk/packages/octave-epstk/debian/patches/50_add_plotcollapse.patch	2006-08-02 19:35:45 UTC (rev 676)
+++ trunk/packages/octave-epstk/debian/patches/50_add_plotcollapse.patch	2006-08-06 21:28:13 UTC (rev 677)
@@ -0,0 +1,139 @@
+diff -Nur octave-epstk-2.1/m/plotcollapse.m octave-epstk-2.1.new/m/plotcollapse.m
+--- octave-epstk-2.1/m/plotcollapse.m	1970-01-01 00:00:00.000000000 +0000
++++ octave-epstk-2.1.new/m/plotcollapse.m	2006-08-06 21:12:40.509798795 +0000
+@@ -0,0 +1,135 @@
++## Copyright © 2006  Francesco Potortì
++##
++## This program is free software; you can redistribute it and/or modify
++## it under the terms of the GNU General Public License as published by
++## the Free Software Foundation; either version 2 of the License, or
++## (at your option) any later version.
++##
++## This program is distributed in the hope that it will be useful,
++## but WITHOUT ANY WARRANTY; without even the implied warranty of
++## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++## GNU General Public License for more details.
++##
++## You should have received a copy of the GNU General Public License
++## along with this program; if not, write to the Free Software Foundation,
++## Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA.
++
++## -*- texinfo -*-
++## @deftypefn {Function File} {} plotcollapse (@var{P})
++## @deftypefnx {Function File} {} plotcollapse (@var{P}, @var{so})
++## @deftypefnx {Function File} {} plotcollapse (@var{P}, @var{so}, @var{res})
++##
++## Optimise plot data by removing redundant points and segments
++##
++## The first parameter @var{P} is a two-column matrix to be plotted as X and
++## Y coordinates.   The second optional argument @var{so} disables segment
++## optimisation when set to @var{false} (default is @var{true}). The third
++## optional argument @var{res} is the size of the largest error on the plot:
++## if it is a scalar, it is meant relative to the range of X and Y values
++## (default 1e-3); if it is a 2x1 array, it contains the absolute errors for
++## X and Y.  Returns a two-column matrix containing a subset of the rows of
++## @var{P}. A line plot of @var{P} has the same appearance as a line plot of
++## the output, with errors smaller than @var{res}.  When creating point
++## plots, set @var{so} to @var{false}.
++## @end deftypefn
++
++## Author: Francesco Potortì <Potorti at isti.cnr.it>
++## $Revision: 2.7 $
++## Usage: plotcollapse(P[, so[, res]])
++## Description: Optimise plot data by removing redundant points and segments
++
++function C = plotcollapse (P, so, res)
++
++  if (!ismatrix(P) || columns(P) != 2)
++    error("P must be a matrix with two columns");
++  endif
++  if (nargin < 2)
++    so = true;			# do segment optimisation
++  endif
++  if (nargin < 3)
++    res = 1e-3;			# default resolution is 1000 dots/axis
++  endif
++
++  ## Slack: admissible error on coordinates on the output plot
++  if (isscalar(res))
++    if (res <= 0)
++      error("res must be positive");
++    endif
++    E = range(P)' * res;	# build error vector using range of data
++  elseif (ismatrix(res))
++    if (!all(size(res) == [2 1]) || any(res <= 0))
++      error("res must be a 2x1 matrix with positive values");
++    endif
++    E = res;			# take error vector as it is
++  else
++    error("res should be a scalar or matrix");
++  endif
++
++  if (rows(P) < 3)
++    C = P;
++    return;			# nothing to do
++  endif
++  P ./= repmat(E',rows(P),1);	# normalize P
++  rot = [0,-1;1,0];		# rotate a vector pi/4 anticlockwise
++
++  ## Iteratively remove points too near to the previous point
++  while (1)
++    V = [true; sumsq(diff(P),2) > 1]; # points far from the previous ones
++    if (all(V)) break; endif
++    V = [true; diff(V) >= 0];	# identify the sequence leaders
++    P = P(V,:);			# remove them
++  endwhile
++
++  ## Remove points laying near to a segment: for each segment R->S, build a
++  ## unitary-lenght projection vector D perpendicular to R->S, and project
++  ## R->T over D to compute the distance ot T from R->S.
++  if (so)			# segment optimisation
++    ## For each segment, r and s are its extremes
++    r = 1; R = P(1,:)';		# start of segment
++    s = 2; S = P(2,:)';		# end of the segment
++    rebuild = true;		# build first projection vector
++
++    for t = 3:rows(P)
++      if (rebuild)		# build projection vector
++	D = rot*(S-R)/sqrt(sumsq(S-R)); # projection vector for distance
++	rebuild = false;	# keep current projection vector
++      endif
++
++      T = P(t,:)';		# next point
++
++      if (abs(sum((T-R).*D)) < 1 # T is aligned
++	  && sum((T-R).*(S-R)) > 0) # going forward
++	V(s) = false;		# do not plot s
++      else			# set a new segment
++	r = s; R = S;		# new start of segment
++	rebuild = true;		# rebuild projection vector
++      endif
++      s = t; S = T;		# new end of segment
++    endfor
++  endif
++
++  C = P(V,:) .* repmat(E',sum(V),1); # denormalize P
++endfunction
++
++%!test
++%! x = [ 0 1 2 3 4 8 8 8 8 8 9 ]'; 
++%! y = [ 0 1 1 1 1 1 1 2 3 4 5 ]';
++%!
++%! x1 = [0 1 8 8 9]';
++%! y1 = [0 1 1 4 5]';
++%!   # optimised for segment plot
++%!
++%! x2 = [ 0 1 2 3 4 8 8 8 8 9 ]';
++%! y2 = [ 0 1 1 1 1 1 2 3 4 5 ]';
++%!   # double points removed
++%!
++%! P = [x,y];
++%!   # Original
++%! P1 = [x1, y1];
++%!   # optimised segments
++%! P2 = [x2, y2];
++%!   # double points removed
++%!
++%! assert(plotcollapse(P), P1);
++%! assert(plotcollapse(P, false), P2);
++




More information about the Pkg-octave-commit mailing list