POV-Ray : Newsgroups : povray.text.scene-files : [Minimum Volume] Bounding Ellipsoid via SVD : Re: [Minimum Volume] Bounding Ellipsoid via SVD Server Time
2 May 2024 19:00:24 EDT (-0400)
  Re: [Minimum Volume] Bounding Ellipsoid via SVD  
From: jr
Date: 11 Nov 2019 16:00:16
Message: <web.5dc95458f7b9a3affeeb22ff0@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > looks great.
> >
> > > Thanks for the line of code - that will be the next step after some more
> > > tinkering:  packaging it up into an easy to use utility.
> >
> > after posting it occurred to me that you might want your data files resemble the
> > matrix, rather than having a value per line.
>
> Yes, that's what I was planning on.

after posting _that_ I remembered you mentioning your being new to Linux etc in
another thread.  so some more on command lines etc below.  (I really feel old --
not so many years ago I'd have covered the salient points in a single reply.
thinking is getting harder.  :-()

> > looking forward to more on svd.  is it useful only for (vaguely)
> > spherical/elliptical shapes?
>
> Nah.  Anything that doesn't have a symmetric distribution.
> so I'd say that off-axis linear data can be oriented,

and can be just a set of data points, ie no "shape" required?  powerful.

> 2D data can be aligned so that the most elongated part is along one axis, and
> the rest of the data perpendicular to that gets rotated to be in the cardinal
> plane,

interesting too but cannot visualise use cases.  when (what kind of data) would
you use that?

> and the ellipsoid is just the easy 3D version of that, but any set of vectors
> could be used.
>
> Hopefully some of the finer points become clearer in the near future.
>
> Looking at what I just posted, and how I've noticed changes in the SVD output
> with different data, maybe all I need for a better alignment is more points ...

testing, testing..  :-)

so, "..you might want your data files resemble the matrix, rather than having a
value per line."

and also, conceivably :-), you might want to document the data.  that
command-line for cleaning ("re-formatting") the data -- no one likes to type
stuff like it all the time.  but there's no need since the tools are all
provided.

typically, a '#' in the first column of a line starts a comment, so the matrix
data file could be:

  # mydata - from some/url.
  2
  123.0    4.56
  7.89    -2.0

the shell (BASH) lets you create functions[*], though they do not have to return
a value, which in use are indistinguishable from "real" utilities.  they can be
typed in on the command-line or sourced from file.  my usual method (ymmv) is to
create a function in a scratch file, test it "to death" ;-), then transfer it to
my '~/.bash_functions' file (think personal library); sourced from the
'~/.bashrc', so gets loaded automatically.

[*] an 'alias' would be no good since you can only append to them, the
alternative would be a "proper" shell script.

for the svd invocation, presuming that you'll go with the above file format (can
have more than one comment line, of course), one way of writing that function is
(fingers crossed wrt typos):

  function fnsvd () {
    if [ 1 -ne $# ]; then
      echo usage: $FUNCNAME matrix_data
    else
      grep -v -e ^# | tr -s ' ' '\n' < $1 | grep -v -e ^$ | /path/to/svd/a.out
    fi
  }

same as before but removing the comments first.  if you're in the (bad, imo)
habit of having spaces in file names, you'd need to put the '$1' parameter in
double quotes.  _is_ extra work, but you only type it once.  wrt the name, I
generally use a 'fn' prefix to remind self.

once that is available in the shell, ie has been 'source'd, you can simply:

  $ fnsvd mydata

the last line in my '~/.bashrc' reads:

  if [ -f ~/.bash_functions ]; then source ~/.bash_functions; fi

note that I tend to write out 'source', usually you'll see people use the
shorthand, a period/dot.  hope that helps in some way, and, yeah, sorry about
the .. noise.


regards, jr.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.