1

I am trying to implement soft body physics, based on this paper by Müller et al.. I'm not terribly bad at mathematics, but while implementing formula (7) I just can't figure out the semantics.

It goes like this:

A = \left( \sum_i m_i p_i q_i^T) \right) \left( \sum_i m_i q_i q_i^T \right)^{-1}

with q_i and p_i being vectors (from center of mass current position,
to be exact)

(please excuse my TeX). This does not make sense to me - a product of sums of vector products should give a scalar, but the result is treated as if it were a matrix.

Implementing the formula straightforward in clojure (core.matrix) gives me scalar results.

I tried to modify the implementation, replacing the N-vectors p and q with NxN matrices of zeroes and p and q as respetive first row/column. This gave me matrix results, but the resulting transformation makes my coordinates run away from the original positions errantly.

Does anybody have experience with this algorithm?

waechtertroll
  • 607
  • 3
  • 17

1 Answers1

0

It's the implementation of clojure.core.matrix, that caused the problem. Usually the product of a column vector and a row vector should result in a matrix (while the product of row vector and a column vector result in a scalar).

The core.matrix returns scalars in both cases, although its api documentation states otherwise. So I had to extend the trick of forcing the multiplication:

     a1
mmul a2 (b1 b2 b3)    = (mmul [[a1][a2][a3]] [b1 b2 b3])
     a3                 or (mmul [a1 a2 a3] [b1 b2 b3])

is done wrongly, so instead:

     (a1 0 0) (b1 b2 b3)
mmul (b2 0 0) (0  0  0 ) = (mmul [[a1 0 0] [a2 0 0] [a3 0 0]]
     (b3 0 0) (0  0  0 )         [[b1 b2 b3] [0 0 0] [0 0 0]] )
waechtertroll
  • 607
  • 3
  • 17