Coder Social home page Coder Social logo

Comments (2)

leon-dae avatar leon-dae commented on June 19, 2024

Update

I dug a little bit deeper.

I compared the loop solution with an updated modulo function that takes into account 0-start-indexing and a written out matrix from p.89 "M. A. Slawinski, Seismic waves and rays in elastic media. Amsterdam: Pergamon, 2003." It does not matter which rotation I make, the looped and fully typed rotation matrix are the same and as such don't match the reference solution in the same places.

I also compared to other reference solutions, e.g. this one.

Something is not correct and I am not able to find the error.

theta = sym.pi/6
c = sym.cos(theta)
s = sym.sin(theta)
Q = sym.Matrix([[1, 0, 0], [0, c, -s], [0, s, c]])      # counterlockwise, x-axis, 30°


def mod3(k):
    k_ = k+1
    if k_ <= 3:
        return k
    return k-3


M = sym.zeros(6)
for i in range(3):
    for j in range(3):
        M[i, j] = Q[i, j]**2
        M[i, j + 3] = 2 * Q[i, mod3(j + 1)] * Q[i, mod3(j + 2)]
        M[i + 3, j] = Q[mod3(i + 1), j] * Q[mod3(i + 2), j]
        M[i + 3, j + 3] = Q[mod3(i + 1), mod3(j + 1)] * \
            Q[mod3(i + 2), mod3(j + 2)] + \
            Q[mod3(i + 1), mod3(j + 2)] * \
            Q[mod3(i + 2), mod3(j + 1)]

M_full = np.array([[Q[0, 0]**2, Q[0, 1]**2, Q[0, 2]**2, 2*Q[0, 1]*Q[0, 2], 2*Q[0, 0]*Q[0, 2], 2*Q[0, 0]*Q[0, 1]],
                   [Q[1, 0]**2, Q[1, 1]**2, Q[1, 2]**2, 2*Q[1, 1]*Q[1, 2], 2*Q[1, 0]*Q[1, 2], 2*Q[1, 0]*Q[1, 1]],
                   [Q[2, 0]**2, Q[2, 1]**2, Q[2, 2]**2, 2*Q[2, 1]*Q[2, 2], 2*Q[2, 0]*Q[2, 2], 2*Q[2, 0]*Q[2, 1]],
                   [Q[1, 0]*Q[2, 0], Q[1, 1]*Q[2, 1], Q[1, 2]*Q[2, 2], Q[1, 1]*Q[2, 2] + Q[1, 2]*Q[2, 1], Q[1, 0]*Q[2, 2] + Q[1, 2]*Q[2, 0], Q[1, 0]*Q[2, 1] + Q[1, 1]*Q[2, 0]],
                   [Q[0, 0]*Q[2, 0], Q[0, 1]*Q[2, 1], Q[0, 2]*Q[2, 2], Q[0, 1]*Q[2, 2] + Q[0, 2]*Q[2, 1], Q[0, 0]*Q[2, 2] + Q[0, 2]*Q[2, 0], Q[0, 0]*Q[2, 1] + Q[0, 1]*Q[2, 1]],
                   [Q[0, 0]*Q[1, 0], Q[0, 1]*Q[1, 1], Q[0, 2]*Q[1, 2], Q[0, 1]*Q[1, 2] + Q[0, 2]*Q[1, 1], Q[0, 0]*Q[1, 2] + Q[0, 2]*Q[1, 0], Q[0, 0]*Q[1, 1] + Q[0, 1]*Q[1, 0]]])

# Counterlockwise, x-axis
M_ref = np.array([[1, 0, 0, 0, 0, 0],
                  [0, c**2, s**2, 2*c*s, 0, 0],
                  [0, s**2, c**2, -2*c*s, 0, 0],
                  [0, -c*s, c*s, c**2-s**2, 0, 0],
                  [0, 0, 0, 0, c, -s],
                  [0, 0, 0, 0, s, c]])

print(M_ref == np.array(M))
print(M_ref == M_full)
print((M_ref == np.array(M)) == (M_ref == M_full))

from continuum_mechanics.

leon-dae avatar leon-dae commented on June 19, 2024

I solved it. The problem was about active and passive rotation. I used the same angle for both the reference and the computed rotation. It appears that for the reference the sign of the angle had to be reversed.

See also the corresponding physics stackexchange post

from continuum_mechanics.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.