<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/913" />

	<title>Real-Time Physics Simulation Forum</title>
	
	<link href="https://pybullet.org/Bullet/phpBB3/index.php" />
	<updated>2007-01-22T17:35:53+00:00</updated>

	<author><name><![CDATA[Real-Time Physics Simulation Forum]]></name></author>
	<id>https://pybullet.org/Bullet/phpBB3/app.php/feed/topic/913</id>

		<entry>
		<author><name><![CDATA[raigan2]]></name></author>
		<updated>2007-01-22T17:35:53+00:00</updated>

		<published>2007-01-22T17:35:53+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3318#p3318</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3318#p3318"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3318#p3318"><![CDATA[
I just tried implementing volume preservation, it doesn't seem to help. Things are less rigid, but still inside-out-able. Since I desired rigid behaviour, I'm forced to use beta = 0 anyway..<br><br>This is quite frustrating! Have you tried simulating an almost-planar tetrahedron? It might be difficult to tell (visually) if it has flipped inside out or not.<br><br>I feel that the solution doesn't lie in the matrix-fitting steps, since those steps are working on an inverted solution. Adjusting Apq so that the determinant is positive seems to be the correct thing to do, however I don't know how to approach this. <br><br>My only thought so far has been, since I have a method which works when the principle axis/axis-of-greatest-spread is axis aligned, I could fit the particles with a line to determine the current principle axis, rotate everything to align the principle axis to one of the world axes, correct Apq (i.e negate one of the columns, depending on which world axis I've aligned everything to), then rotate things back. However, this seems a bit ridiculous.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=748">raigan2</a> — Mon Jan 22, 2007 5:35 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dog]]></name></author>
		<updated>2007-01-22T16:58:06+00:00</updated>

		<published>2007-01-22T16:58:06+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3316#p3316</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3316#p3316"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3316#p3316"><![CDATA[
It sounds like you are not doing volume preservation. This may be why I can't reproduce your problem.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=60">dog</a> — Mon Jan 22, 2007 4:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raigan2]]></name></author>
		<updated>2007-01-22T16:33:27+00:00</updated>

		<published>2007-01-22T16:33:27+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3315#p3315</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3315#p3315"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3315#p3315"><![CDATA[
Thanks -- I'm using the exact same steps (except that I skip (5), as my beta is always 0). <br><br>I'm not checking that R is orthonormal, but if I understand correctly this wouldn't help the flipping-inside-out anyway, since in both cases R _is_ orthonormal -- in the flipped case, one of the axes has been reverse/negated.<br><br>Have you tried modeling a nearly-flat simplex with your simulator? This is the sort of shape that is very easy to turn inside-out: low particle count, and nearly degenerate/rank-deficient.<br><br>Is it possible that your simulator has the same problems as mine, but you never encounter them in practice? <br><br>Unless you take explicit steps to prevent flipping, I don't see how you can avoid it, since the problem (as far as I understand it) with flipped cases is that the best-fit transformation _is_ to flip the shape inside-out. Or rather, that you're fitting the flipped configuration, so you're screwed from the start.<br><br>Manipulating Apq to make sure the determinant is positive seems to be a solution to this problem, however it's not clear to me how you'd go about altering it to solve the general case. When the flip happens along one of the axes, you can negate one of the basis vectors described by Apq, however this isn't a general solution..<br><br>Thanks again for your help and encouragement -- it's unfortunate that for my application I can't rule-out these problematic configurations.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=748">raigan2</a> — Mon Jan 22, 2007 4:33 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dog]]></name></author>
		<updated>2007-01-22T04:07:04+00:00</updated>

		<published>2007-01-22T04:07:04+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3314#p3314</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3314#p3314"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3314#p3314"><![CDATA[
Of the top of my head you should do:<br><br>1. Integrate particles<br>2. Find centre of mass of particles<br>3. Calculate the initial transformation for the new points:<br>     Initialize matrix to all zeroes<br>     Loop over every particle:<br>        Let L = local particle position relative to new centre of mass<br>        Let Q = local particle position for the original shape<br>        Add L * Q.x to the x-axis of your matrix<br>        Add L * Q.y to the y-axis of your matrix etc.<br>     Then scale the final matrix by 1.0/particle count to normalize it<br>4. Extract the rotation part (and this is from memory, so it might be iffy):<br>     Let our linear transform from above be M<br>     Let M2 = Transpose(M) * M<br>     Let S = MatrixSquareRoot(M2)<br>     Therefore our rotation matrix R = M * MatrixAffineInverse(S)<br>     I then make sure that R is orthonormal (maybe you miss this step?)<br>5. Calculate the linear transformation and try to do volume preservation:<br>     Transform = Transform of Original Shape * M<br>     Calculate the determinate of this matrix.<br>     If the determinant is sufficiently greater of less than 1 (have a margin)      <br>     then scale it according to the paper (some power thing I can't remember)<br>6.  Then compose your final matrix (Transform from 5 scaled by beta + R scaled by  1 - beta).<br><br>etc.<br><br>My square root is something like:<br><br>Given input matrix m<br>Let m1 = m<br>Let m2 = identity<br>Let HalfMat = matrix with 0.5 in the diagonals<br>for (numIterations) do<br>Let invm1 = MatrixAffineInverse(m1)<br>Let invm2 = MatrixAffineInverse(m2)<br>m1 = (m1 + invm2) * HalfMat<br>m2 = (m2 + invm1) * HalfMat<br><br>return m1<br><br>and that's it.<br><br>Hope this helps.<br><br><span style="font-size:59%;line-height:116%">(And thanks to my colleague who actually got all this working nicely)</span><p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=60">dog</a> — Mon Jan 22, 2007 4:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raigan2]]></name></author>
		<updated>2007-01-22T03:19:02+00:00</updated>

		<published>2007-01-22T03:19:02+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3311#p3311</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3311#p3311"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3311#p3311"><![CDATA[
Do you have any suggestions on how the original shape data could be used to avoid flips? I'm simply storing them as a list of 2D positions, in a coordinate system formed by the center-of-mass and the worldspace basis vectors (1,0),(0,1).<br><br><br>I'm skeptical that the problem is bug-related, as things works perfectly in all cases, _except_ that all solvers fail to prevent flips. Long chains of bodies, etc. are totally stable and well-behaved.<br><br>My test case for flipping is extremely simple: I'm using a shape that is a very wide slightly asymmetrical "V", such as (50,50),(70,60),(150,50). (this is in 2D)<br><br>If the middle point crosses the line formed by the other two points, the shape flips around. I can _detect_ that this has occurred by looking at the sign of the determinant of Apq, however I haven't found a way to actually fix the problem in general. Negating a column of Apq only works for certain cases.<br><br>Also, about Denman-Beavers: are you using regular matrix inversion at each iteration? Or some sort of pseudo-inverse? If the original shape is colinear (i.e (50,50),(70,50),(150,50)) the iterates become non-invertible/singular/0-determinant for me. Also, I found that even 12 iterations was far from sufficient. Here's my code:<div class="codebox"><p>Code: </p><pre><code>var numits = 20;var Y = {a:AtA.a,b:AtA.b,c:AtA.c,d:AtA.d};var Z = {a:1,b:0,c:0,d:1};for(var n = 0; n &lt; numits; n++){var invY = Mat22_Inv(Y);var invZ = Mat22_Inv(Z);Mat22_Add_InPlace(invZ,Y);//Y = (Y + Z^-1)Mat22_Scale_InPlace(0.5,Y);//Y = (Y + Z^-1)/2Mat22_Add_InPlace(invY,Z);//Z = (Z + invY)Mat22_Scale_InPlace(0.5,Z);//Z = (Z + invY)/2}</code></pre></div>It definitely produces an accurate square-root, however it doesn't fix the flipping, nor does it handle the colinear cases. In short, it's no better than the polar decomposition I was previously using. Am I missing something? My implementation may be slightly "naive" <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>My implementation of the algorithm is completely straightforward:<br>-calculate center-of-mass and Apq, given current and original particle positions<br>-calculate AtA = Apq^T*Apq<br>-calculate S = (sqrt(AtA))^-1<br>-R = Apq*S<br>-original positions q are transformed to produce target/rigid positions R*q; current positions are moved to target/rigid positions.<br><br>The calculation of S is really the only step that seems like it could be problematic. Are you explicitly calculating AtA? Reading through some docs on SVD, it seems that this step can produce some numerical problems.. but I've yet to figure out exactly how to avoid it.<br><br>Finally, since my Apq matrix is 2x2, I feel like there should be some direct solution/formula for the SVD. However, so far several searches have turned up only questionable (and ancient) usenet posts on the subject.<br><br>Thanks for your help!<br>raigan<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=748">raigan2</a> — Mon Jan 22, 2007 3:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dog]]></name></author>
		<updated>2007-01-22T00:28:55+00:00</updated>

		<published>2007-01-22T00:28:55+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3310#p3310</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3310#p3310"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3310#p3310"><![CDATA[
The original algorithm works fine for me with Denman Beavers (well, the spirit of it does anyway) - and this is in a very aggressive simulation with extreme squashing. I suspect you may have bugs elsewhere. <br><br>I know how frustrating this sort of thing can be, but stick at it. Are you maintaining your original (un-squashed) shape in a consistent way? You can use this to avoid flips. Are you sure you are not getting degenerate calculations somewhere? Just one bad float value can cause havoc.<br><br>Hmmm, I'm not being very helpful really; but I think this is one where you'll just have to instrument your code to catch when things go bad, and look at what is causing the problem. At the very least this should let you see how you would want to change the original algorithm as you have interpreted it to avoid the error you are getting.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=60">dog</a> — Mon Jan 22, 2007 12:28 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raigan2]]></name></author>
		<updated>2007-01-21T22:52:04+00:00</updated>

		<published>2007-01-21T22:52:04+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3309#p3309</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3309#p3309"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3309#p3309"><![CDATA[
I've finally got around to trying the Denman-Beavers matrix square root as suggested, and I'm afraid I have to report that it is having absolutely no effect on preventing the shape from flipping "inside-out".<br><br>Using 20 or even 40 iterations doesn't make a difference; the square root is properly calculated, the problem is elsewhere. My only guess is that we're losing some info in the process since square-roots annihilate sign data.<br><br><br>Similar to my other two methods (polar decomposition and direct/closed-form eigendecomposition), you can prevent flipping in select cases by negating one of the columns of Apq (i.e negate the second column if particles have high varience in x, etc. as I mentioned earlier, and as seen in Muller's source), however this doesn't work in general -- you get the exact same problems as my other methods, where inside-outness will be prevented by rotating the shape 180deg, instead of by a small translation of the particles.<br><br>In fact, the DB algorithm seems to perform worse than polar decomposition, as it fails for cases where the original particle positions are colinear (some matrices become singular), while polar decomposition handles these cases.<br><br><br>This is quite frustrating! I'm surprised that no one else has encountered this problem. I can post code and/or demos, but I don't think that my implementation is at fault -- I've arrived at identical behaviour using three completely different implementations! <br><br>To me this suggests that it's a problem with the original algorithm, which sucks because it's an incredibly useful tool aside from this small (but critical) problem.<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=748">raigan2</a> — Sun Jan 21, 2007 10:52 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raigan2]]></name></author>
		<updated>2007-01-16T19:20:09+00:00</updated>

		<published>2007-01-16T19:20:09+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3242#p3242</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3242#p3242"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3242#p3242"><![CDATA[
Luckily I'm not really using it for deformable stuff -- I'm abusing it to simulate rigid bodies in 2D -- "shape matching" is a type of constraint inside my Position Based Dynamics-based simulator (the "alpha" param is 1 and the "beta" is 0).<br><br>My view is that using shape-matching in this way is the explicit representation of a constraint which is often implicitly modeled by simply connecting every particle with every other particle using a distance constraint (i.e it lets each particle propagate forces to every other particle). Shape matching scales much better, and converges in a single solver iteration. Which makes it very easy to model a destructible world <img class="smilies" src="https://pybullet.org/Bullet/phpBB3/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>Plus, unlike particle+stick networks, it should prevent against things turning inside-out.. as soon as I implement that sqrt algorithm!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=748">raigan2</a> — Tue Jan 16, 2007 7:20 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Antonio Martini]]></name></author>
		<updated>2007-01-16T18:44:52+00:00</updated>

		<published>2007-01-16T18:44:52+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3241#p3241</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3241#p3241"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3241#p3241"><![CDATA[
at the following link there is a demo which implements a few deformable algorithms. In my opinion the shape matching approach is the one that behaves the worst:<br><br><a href="http://graphics.ethz.ch/~brunoh/defcolstudio.html" class="postlink">http://graphics.ethz.ch/~brunoh/defcolstudio.html</a><br><br>some available choices for deformable bodies are:<br><br>1. FEM with implicit integration<br><br>2. Position Based Dynamics with added volume conservation constraints for tetrahedra.<br><br>3. Shape Matching<br><br>as usual what method is the best depends on what our objectives are.<br><br>cheers,<br>Antonio<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=145">Antonio Martini</a> — Tue Jan 16, 2007 6:44 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[raigan2]]></name></author>
		<updated>2007-01-16T16:40:31+00:00</updated>

		<published>2007-01-16T16:40:31+00:00</published>
		<id>https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3240#p3240</id>
		<link href="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3240#p3240"/>
		<title type="html"><![CDATA[Meshless Deformations Based on Shape Matching]]></title>

		
		<content type="html" xml:base="https://pybullet.org/Bullet/phpBB3/viewtopic.php?p=3240#p3240"><![CDATA[
I see -- I'll definitely try the DB method then; I didn't realize the square root could cause the axes to flip!<p>Statistics: Posted by <a href="https://pybullet.org/Bullet/phpBB3/memberlist.php?mode=viewprofile&amp;u=748">raigan2</a> — Tue Jan 16, 2007 4:40 pm</p><hr />
]]></content>
	</entry>
	</feed>
