Calculate vector from dihedral angle.

286 Views Asked by At

I would basically like to do the reverse of this question: How do I calculate a dihedral angle given Cartesian coordinates?

I have 3 points, and i would like to find the fourth point that spans the two planes with a given dihedral angle.

If i have points A, B, C, D, than the cross product of vector AB and BC will be the normal vector of the spanned plane of ABC (same goes for BCD), but when i try to do it in reverse, i always fail.

Is there an "easy" solution to this problem?

UPDATE:

So i tried to implement the solution that was given to this question, but i am unable to replicate it. So my four points are a,b,c,d the dihedral is angle, and in principle i should get back the coordinates of point d.

a = np.array([5.588, 13.965, -22.320])
b = np.array([4.753, 13.567, -21.196])
c = np.array([3.713, 14.653, -20.905])
d = np.array([2.454, 14.243, -20.787])

angle = dihedral_from_vectors(a, b, c, d)
print(angle) # 2.2737420259103684

u = c - b
v = (b - a) - (np.dot((b - a), u)/u**2)*u

w = np.cross(u, v)

q = v/np.linalg.norm(v)*np.cos(angle)
e = w/np.linalg.norm(w)*np.sin(angle)

print(b + (q-e)) # [  5.2020659   14.45198936 -21.0729811 ]
print(b + (q+e)) # [  4.37411986  13.44621893 -20.27846974]
1

There are 1 best solutions below

3
On

Vector $u=BC$ lies on both planes, vector $v=BA-\frac{BA\cdot u}{u^2}u$ lies on $ABC$ and is perpendicular to $BC$. $w=u\times v$ (or $w=BC\times BA$) is a vector perpendicular to the plane $ABC$.

Thus, you can take vector $BD = \frac{v}{|v|}\cos\theta \pm \frac{w}{|w|}\sin\theta$.

You can show that normal $n$ to $BCD$: $$ n=BC\times BD = \frac{u\times v}{|v|}\cos\theta \pm \frac{u\times w}{|w|}\sin\theta. $$

Notice, that $|n| = |u|$

And the angle between $n$ and $w$: $$ n\cdot w = \frac{u\times v\cdot w}{|v|}\cos\theta \pm \frac{u\times w\cdot w}{|w|}\sin\theta = \frac{|u||v||w|}{|v|}\cos\theta = |n||w|\cos \theta $$