Skip to content

Commit 85b983c

Browse files
committed
another go at angvelxform_dot, including notebook for derivation
1 parent b7f66fa commit 85b983c

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

spatialmath/base/transforms3d.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,20 +2256,24 @@ def angvelxform_dot(𝚪, 𝚪d, full=True, representation="rpy/xyz"):
22562256
skd = base.skew(vd)
22572257
theta_dot = np.inner(𝚪, 𝚪d) / base.norm(𝚪)
22582258
theta = base.norm(𝚪)
2259-
Theta = 1 - theta / 2 * np.sin(theta) / (1 - np.cos(theta))
2259+
Theta = (1.0 - theta / 2.0 * np.sin(theta) / (1.0 - np.cos(theta))) / theta**2
2260+
2261+
# hand optimized version of code from notebook
2262+
# TODO:
2263+
# results are close but different to numerical cross check
2264+
# something wrong in the derivation
22602265
Theta_dot = (
2261-
-0.5 * theta * theta_dot * math.cos(theta) / (1 - math.cos(theta))
2262-
+ 0.5
2263-
* theta
2264-
* theta_dot
2265-
* math.sin(theta) ** 2
2266-
/ (1 - math.cos(theta)) ** 2
2267-
- 0.5 * theta_dot * math.sin(theta) / (1 - math.cos(theta))
2268-
) / theta ** 2 - 2 * theta_dot * (
2269-
-1 / 2 * theta * math.sin(theta) / (1 - math.cos(theta)) + 1
2270-
) / theta ** 3
2271-
2272-
Ad = -0.5 * skd + 2 * sk @ skd * Theta + sk @ sk * Theta_dot
2266+
(
2267+
-theta * math.cos(theta)
2268+
-math.sin(theta) +
2269+
theta * math.sin(theta)**2 / (1 - math.cos(theta))
2270+
) * theta_dot / 2 / (1 - math.cos(theta)) / theta**2
2271+
- (
2272+
2 - theta * math.sin(theta) / (1 - math.cos(theta))
2273+
) * theta_dot / theta**3
2274+
)
2275+
2276+
Ad = -0.5 * skd + 2.0 * sk @ skd * Theta + sk @ sk * Theta_dot
22732277
else:
22742278
raise ValueError("bad representation specified")
22752279

symbolic/angvelxform_dot.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"$\n",
4444
"\\mathbf{A} = I_{3 \\times 3} - \\frac{1}{2} [v]_\\times + [v]^2_\\times \\frac{1}{\\theta^2} \\left( 1 - \\frac{\\theta}{2} \\frac{\\sin \\theta}{1 - \\cos \\theta} \\right)\n",
4545
"$\n",
46-
"where $\\theta = \\| \\varphi \\|$.\n",
46+
"where $\\theta = \\| \\varphi \\|$ and $v = \\hat{\\varphi}$\n",
4747
"\n",
4848
"We simplify the equation as\n",
4949
"\n",
@@ -56,7 +56,7 @@
5656
"\\Theta = \\frac{1}{\\theta^2} \\left( 1 - \\frac{\\theta}{2} \\frac{\\sin \\theta}{1 - \\cos \\theta} \\right)\n",
5757
"$\n",
5858
"\n",
59-
"We want to find the deriviative, which we can compute using the chain rule\n",
59+
"We can find the derivative using the chain rule\n",
6060
"\n",
6161
"$\n",
6262
"\\dot{\\mathbf{A}} = - \\frac{1}{2} [\\dot{v}]_\\times + 2 [v]_\\times [\\dot{v}]_\\times \\Theta + [v]^2_\\times \\dot{\\Theta}\n",

0 commit comments

Comments
 (0)