POV-Ray : Newsgroups : povray.text.scene-files : [Minimum Volume] Bounding Ellipsoid via SVD Server Time
31 Oct 2024 18:58:53 EDT (-0400)
  [Minimum Volume] Bounding Ellipsoid via SVD (Message 15 to 24 of 34)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 6 Nov 2019 19:25:00
Message: <web.5dc36373f7b9a3affeeb22ff0@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> ...
> > anyway, the source you posted does not compile, so it's clearly not meant to be.
> my command line directive is:
> c++ SVD_BW.cpp -std=c++11
         ^^^
spot the difference.  ;-)  no matter though, it can wait until you've changed it
to read data from stdin.

> Not sure what your system is spitting out as complaints.
>
> I can give you the current version of the tangent macro, and hopefully that will
> be all you need.

cool, thanks.  any chance of a/the scene file?  to see it in-use.

>  Looks like Leroy couldn't help himself and has his own version
> going as well. :D

it is .. seductive.  _if_ I can understand yr code well enough, I've plans for a
platform on tank-like tracks I'd like to build.

> I hope the lesson pdf clarifies the whole point of all of this and to some
> extent how it's done.

you're pulling my leg..  had a quick scan, the formulae just make my eyes bleed.
 the 1st scan main benefit was seeing the virtual "mass", as an assumption and
how it can then be applied.  that, as a concept, is v interesting, need to think
on it.


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 6 Nov 2019 20:35:00
Message: <web.5dc374c1f7b9a3af4eec112d0@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> > my command line directive is:
> > c++ SVD_BW.cpp -std=c++11
>          ^^^
> spot the difference.  ;-)  no matter though, it can wait until you've changed it
> to read data from stdin.

Spot the identity.  ;P
http://news.povray.org/povray.text.scene-files/message/%3Cweb.5dc33dd7f7b9a3af4eec112d0%40news.povray.org%3E/#%3Cweb.5d
c33dd7f7b9a3af4eec112d0%40news.povray.org%3E

I don't know what construct to use to "catch" the data from stdin...
But I will look.
Hangin' it up for the day - got a day tomorrow, hopefully it's not a disaster
<crosses fingers>


> it is .. seductive.  _if_ I can understand yr code well enough, I've plans for a
> platform on tank-like tracks I'd like to build.

I'll see if I can put together a simplified version minus all the gobbledygook.


> > I hope the lesson pdf clarifies the whole point of all of this and to some
> > extent how it's done.
>
> you're pulling my leg..

Nope.
Just look at the pretty pictures.

> had a quick scan, the formulae just make my eyes bleed.
>  the 1st scan main benefit was seeing the virtual "mass", as an assumption and
> how it can then be applied.  that, as a concept, is v interesting, need to think
> on it.

Well that's basically it - don't look at the formulae.

The real gist looks to be that matrices encode (mostly) scaling and rotations.
 One matrix can be split up (factored) into a rotation matrix, a reverse
rotation matrix (which obviously cancel) and a matrix of scaling factors.

So "How is your data stretched?"  It stretches along "x" by this much, "Y" by
this much, and "z" by this much.
And the rotation matrix tells you what direction "x", "y" and "z" are from the
real, cardinal basis vectors of <x, y, z>.


Post a reply to this message

From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 6 Nov 2019 21:15:01
Message: <web.5dc37d9ff7b9a3affeeb22ff0@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
>
> > > my command line directive is:
> > > c++ SVD_BW.cpp -std=c++11
> >          ^^^
> > spot the difference.  ;-)  no matter though, it can wait until you've changed it
> > to read data from stdin.
>
> Spot the identity.  ;P
>
http://news.povray.org/povray.text.scene-files/message/%3Cweb.5dc33dd7f7b9a3af4eec112d0%40news.povray.org%3E/#%3Cweb.
5d
> c33dd7f7b9a3af4eec112d0%40news.povray.org%3E
>
> I don't know what construct to use to "catch" the data from stdin...

the program does already though.  where in main you have "std::cin >> matrix",
that's reading from stdin, after it put the message on stdout.  cin/cout/cerr ==
stdin/stdout/stderr.

> But I will look.
> Hangin' it up for the day - got a day tomorrow, hopefully it's not a disaster
> <crosses fingers>
>
> > it is .. seductive.  _if_ I can understand yr code well enough, I've plans for a
> > platform on tank-like tracks I'd like to build.
>
> I'll see if I can put together a simplified version minus all the gobbledygook.

great, cheers.

> > > I hope the lesson pdf clarifies the whole point of all of this and to some
> > > extent how it's done.
> >
> > you're pulling my leg..
>
> Nope.
> Just look at the pretty pictures.
>
> > had a quick scan, the formulae just make my eyes bleed.
> >  the 1st scan main benefit was seeing the virtual "mass", as an assumption and
> > how it can then be applied.  that, as a concept, is v interesting, need to think
> > on it.
>
> Well that's basically it - don't look at the formulae.

well, re-orienting a given object to obtain a best fit BB seems to be necessary,
so, no choices.  :-)

> ...


regards, jr.


Post a reply to this message

From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 10 Nov 2019 09:50:01
Message: <web.5dc82312f7b9a3affeeb22ff0@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
>
> > the latter, I'm confident, although somewhat unsure of exact syntax.
>
> OK - I just usually search-engine my way to a solution   :)
>
> > suggestion: attach your working version of svd.cpp, so we talk same code.  I'll
> > play with it here to test; are the matrices filled just with floats?
>
> Right on.
> At the moment, my thoughts are:
>
> 1. the data must get read into a faux-matrix std::vector container, which I
> suppose has to be created before assigning the data to it
>
> 2. it should have m rows - the number of vectors to process, and m columns - the
> first 3 are x, y, and z, and all the remaining columns are zeros
>
> Then hopefully I can use that lesson to apply the SVD output to the data in the
> SDL scene.
>
>
> There's hardly any data in the header file - I'm assuming that can just be added
> to the top of the .cpp file to keep it all self-contained.

it's been .. quiet.  in case you haven't addressed 1/2 yet, here's a quick,
though inefficient (and inelegant), hack.  in the 'generate_matrix' function,
there's an assignment in the innermost 'for()'.  if you change that line to
read:
  std::cin >> matrix[row[col];
then you can pipe your data in.  inefficient because you're reading one value at
a time.  say you want a 2x2 matrix:
1.0 2.0
3.0 4.0

then your data file should read:
2
1.0
2.0
3.0
4.0

and you'd execute:
$ ./a.out < myfile

while I haven't actually tried it here, I'm quite confident it'll work.  in the
long run you'd want to read and process a row of data at a time though.  hth.


regards, jr.


Post a reply to this message

From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 10 Nov 2019 10:10:01
Message: <web.5dc82730f7b9a3affeeb22ff0@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...
> it's been .. quiet.  in case you haven't addressed 1/2 yet, here's a quick,
> though inefficient (and inelegant), hack.  in the 'generate_matrix' function,
> there's an assignment in the innermost 'for()'.  if you change that line to
> read:
>   std::cin >> matrix[row[col];

uh, typo.  effing always.  :-(

std::cin >> matrix[row][col];

> ...


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 10 Nov 2019 18:40:00
Message: <web.5dc89f2df7b9a3af4eec112d0@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> > it's been .. quiet.

Well, been busy with RL, reading, re-reading, watching vids, filtering, taking
notes, processing, etc.

I think I have enough of an understanding of what goes on and what to do with
it, that it ought to be a viable method.

Will start a new thread in pbi so I can show results.

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.


Post a reply to this message

From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 10 Nov 2019 19:45:00
Message: <web.5dc8ae2df7b9a3affeeb22ff0@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > > it's been .. quiet.
>
> Well, been busy with RL, reading, re-reading, watching vids, filtering, taking
> notes, processing, etc.
>
> I think I have enough of an understanding of what goes on and what to do with
> it, that it ought to be a viable method.
>
> Will start a new thread in pbi so I can show results.

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.  :-)  assuming a justified (with
space chars) layout like:
2
123.0    4.56
  7.89  -2.0

you can use standard *NIX text processing tools to "massage" the data:
$ tr -s ' ' '\n' < myfile | grep -v -e ^$ | ./a.out

in English, 'tr' ("translate") converts spaces to newlines, the '-s' option
"squeezes" any number of consecutive chars into one, the grep looks for lines
which do not match an empty line.

looking forward to more on svd.  is it useful only for (vaguely)
spherical/elliptical shapes?


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 10 Nov 2019 20:40:00
Message: <web.5dc8bb38f7b9a3af4eec112d0@news.povray.org>
"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.

> 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,

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,

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 ...


Post a reply to this message

From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
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

From: jr
Subject: Re: [Minimum Volume] Bounding Ellipsoid via SVD
Date: 11 Nov 2019 16:50:01
Message: <web.5dc9d701f7b9a3affeeb22ff0@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...
> (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
>   }

</sigh>  blindly copying + pasting does that.  :-(  corrected:

  grep -v -e ^# $1 | tr -s ' ' '\n' | grep -v -e ^$ | /path/to/svd/a.out


regards, jr.


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

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