```python
# https://colab.research.google.com/github/kassbohm/wb-snippets/blob/master/ipynb/HTM_03/Selbst/4.1.ipynb

from sympy import *

m = var("m", positive = True)
a, b, c = var("a, b, c", positive=True)
a2, b2, c2 = a*a, b*b, c*c

# Start Check Parallel Axis:
check = True
check = False
if check:
    pprint("\nK-Components of JO:")
    x, y, z = var("x, y, z")
    V = a*b*c

    pprint("11-Component:")
    # J11
    # = int ρ (y² + z²) dV
    # = ρ int (y² + z²) dV
    # = m / V int (y² + z²) dV
    tmp = y*y + z*z
    tmp = integrate(tmp, (x, 0, a))
    tmp = integrate(tmp, (y, 0, b))
    tmp = integrate(tmp, (z, 0, c))
    tmp *= m / V
    tmp = tmp.simplify()
    pprint(tmp)

    pprint("12-Component:")
    # J12
    # = - int ρ (xy) dV
    tmp = -x*y
    tmp = integrate(tmp, (x, 0, a))
    tmp = integrate(tmp, (y, 0, b))
    tmp = integrate(tmp, (z, 0, c))
    tmp *= m / V
    tmp = tmp.simplify()
    pprint(tmp)

# End Check

J11 = m * (b2 + c2)
J22 = m * (a2 + c2)
J33 = m * (a2 + b2)

pprint("\nK-Components of JC:")
J = Matrix([
    [J11, 0, 0],
    [0, J22, 0],
    [0, 0, J33]
    ])/12
pprint(J)

pprint("\nK-Components of JC for b=a and c=a:")
Jabc = J.subs([(b,a), (c,a)])
pprint(Jabc)

pprint("\nK-Components of JO:")
JParallelAxis = m/4 * Matrix([
    [b2+c2,  -a*b,   -a*c],
    [-a*b,  a2+c2,   -b*c],
    [-a*c,   -b*c,  a2+b2]
    ])
JO = J + JParallelAxis
JO = JO.applyfunc(simplify)
pprint(JO)

pprint("\nUnitvector along OE:")
dOE = Matrix([a, b, c])
d = dOE / dOE.norm()
pprint(d)

pprint("\nComponent along OE:")
JOE = d.transpose()*J*d
JOE = JOE.applyfunc(simplify)
pprint(JOE)

pprint("\nComponent along OE for b=a and c=a:")
JOE = d.transpose()*Jabc*d
JOE = JOE.applyfunc(simplify)
pprint(JOE[0])

pprint("\nRotation Matrix R:")
alpha = 45 *pi/180
beta = atan(sqrt(2))

ca, sa = cos(alpha), sin(alpha)
cb, sb = cos(beta), sin(beta)

Ra = Matrix([
    [ca, 0, -sa],
    [0,  1,   0],
    [sa, 0,  ca]
    ])

Rb = Matrix([
    [1,  0,    0],
    [0,  cb,  sb],
    [0, -sb,  cb]
    ])

R = Rb*Ra
pprint(R)
Rt = R.transpose()

# pprint("\nChecking R:")
# pprint("\n(x, y, z)-Components of d:")
# d = Matrix([dx, dy, dz])
# pprint(d)
# pprint("\n(x'', y'', z'')-Components of d:")
# dM = R*d
# pprint(dM)

pprint("\nK-Components of JO for b=a and c=a:")
JOabc = JO.subs([(b,a), (c,a)])
pprint(JOabc)

pprint("\nM-Components of JO for b=a and c=a:")
JOM = R*JOabc*Rt
JOM = JOM.applyfunc(simplify)
pprint(JOM)
                   
# K-Components of JC:
# ⎡  ⎛ 2    2⎞                          ⎤
# ⎢m⋅⎝b  + c ⎠                          ⎥
# ⎢───────────       0            0     ⎥
# ⎢     12                              ⎥
# ⎢                                     ⎥
# ⎢               ⎛ 2    2⎞             ⎥
# ⎢             m⋅⎝a  + c ⎠             ⎥
# ⎢     0       ───────────       0     ⎥
# ⎢                  12                 ⎥
# ⎢                                     ⎥
# ⎢                            ⎛ 2    2⎞⎥
# ⎢                          m⋅⎝a  + b ⎠⎥
# ⎢     0            0       ───────────⎥
# ⎣                               12    ⎦
#
# K-Components of JC for b=a and c=a:
# ⎡ 2              ⎤
# ⎢a ⋅m            ⎥
# ⎢────   0     0  ⎥
# ⎢ 6              ⎥
# ⎢                ⎥
# ⎢       2        ⎥
# ⎢      a ⋅m      ⎥
# ⎢ 0    ────   0  ⎥
# ⎢       6        ⎥
# ⎢                ⎥
# ⎢             2  ⎥
# ⎢            a ⋅m⎥
# ⎢ 0     0    ────⎥
# ⎣             6  ⎦
#
# K-Components of JO:
# ⎡  ⎛ 2    2⎞                          ⎤
# ⎢m⋅⎝b  + c ⎠    -a⋅b⋅m       -a⋅c⋅m   ⎥
# ⎢───────────    ───────      ───────  ⎥
# ⎢     3            4            4     ⎥
# ⎢                                     ⎥
# ⎢               ⎛ 2    2⎞             ⎥
# ⎢  -a⋅b⋅m     m⋅⎝a  + c ⎠    -b⋅c⋅m   ⎥
# ⎢  ───────    ───────────    ───────  ⎥
# ⎢     4            3            4     ⎥
# ⎢                                     ⎥
# ⎢                            ⎛ 2    2⎞⎥
# ⎢  -a⋅c⋅m       -b⋅c⋅m     m⋅⎝a  + b ⎠⎥
# ⎢  ───────      ───────    ───────────⎥
# ⎣     4            4            3     ⎦
#
# Unitvector along OE:
# ⎡        a        ⎤
# ⎢─────────────────⎥
# ⎢   ______________⎥
# ⎢  ╱  2    2    2 ⎥
# ⎢╲╱  a  + b  + c  ⎥
# ⎢                 ⎥
# ⎢        b        ⎥
# ⎢─────────────────⎥
# ⎢   ______________⎥
# ⎢  ╱  2    2    2 ⎥
# ⎢╲╱  a  + b  + c  ⎥
# ⎢                 ⎥
# ⎢        c        ⎥
# ⎢─────────────────⎥
# ⎢   ______________⎥
# ⎢  ╱  2    2    2 ⎥
# ⎣╲╱  a  + b  + c  ⎦
#
# Component along OE:
# ⎡  ⎛ 2  2    2  2    2  2⎞⎤
# ⎢m⋅⎝a ⋅b  + a ⋅c  + b ⋅c ⎠⎥
# ⎢─────────────────────────⎥
# ⎢       ⎛ 2    2    2⎞    ⎥
# ⎣     6⋅⎝a  + b  + c ⎠    ⎦
#
# Component along OE for b=a and c=a:
#  2
# a ⋅m
# ────
#  6
#
# Rotation Matrix R:
# ⎡√2        -√2 ⎤
# ⎢──   0    ────⎥
# ⎢2          2  ⎥
# ⎢              ⎥
# ⎢√3   √3    √3 ⎥
# ⎢──   ──    ── ⎥
# ⎢3    3     3  ⎥
# ⎢              ⎥
# ⎢√6  -√6    √6 ⎥
# ⎢──  ────   ── ⎥
# ⎣6    3     6  ⎦
#
# K-Components of JO for b=a and c=a:
# ⎡   2      2       2   ⎤
# ⎢2⋅a ⋅m  -a ⋅m   -a ⋅m ⎥
# ⎢──────  ──────  ──────⎥
# ⎢  3       4       4   ⎥
# ⎢                      ⎥
# ⎢  2        2      2   ⎥
# ⎢-a ⋅m   2⋅a ⋅m  -a ⋅m ⎥
# ⎢──────  ──────  ──────⎥
# ⎢  4       3       4   ⎥
# ⎢                      ⎥
# ⎢  2       2        2  ⎥
# ⎢-a ⋅m   -a ⋅m   2⋅a ⋅m⎥
# ⎢──────  ──────  ──────⎥
# ⎣  4       4       3   ⎦
#
# M-Components of JO for b=a and c=a:
# ⎡    2                 ⎤
# ⎢11⋅a ⋅m               ⎥
# ⎢───────   0       0   ⎥
# ⎢   12                 ⎥
# ⎢                      ⎥
# ⎢          2           ⎥
# ⎢         a ⋅m         ⎥
# ⎢   0     ────     0   ⎥
# ⎢          6           ⎥
# ⎢                      ⎥
# ⎢                   2  ⎥
# ⎢               11⋅a ⋅m⎥
# ⎢   0      0    ───────⎥
# ⎣                  12  ⎦

```

dc2a791096f1ff2c2db299c2f8f467b8ab3e873d
ipynb
Jupyter Notebook
ipynb/HTM_03/Selbst/4.1.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
ipynb/HTM_03/Selbst/4.1.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
ipynb/HTM_03/Selbst/4.1.ipynb
kassbohm/wb-snippets
f1ac5194e9f60a9260d096ba5ed1ce40b844a3fe
MIT
Qwen/Qwen-72B
1. YES
2. YES