由角度分隔的轴
我正在尝试从常用于指定晶体晶胞的参数生成一些轴向量。这些参数由三个轴的长度:a、b、c 以及它们之间的角度:alpha、beta、gamma 组成。按照惯例,α 是 b 轴和 c 轴之间的角度,β 是 a 轴和 c 轴之间的角度,gamma 是 a 轴和 b 轴之间的角度。
现在获得前两个的向量表示很容易。我可以任意设置a轴为x轴,所以a_axis = [a,0,0]。然后我需要将 b 旋转远离 a 角度 gamma,这样我就可以留在 xy 平面上来执行此操作,并且 b_axis = [b*cos(gamma),b*sin(gamma),0]。
问题是第三个向量。我想不出一个很好的干净的方法来确定它。我想出了一些不同的解释,但没有一个成功。一种是想象有两个围绕轴 axis_a 和 axis_b 的圆锥体,其大小由角度 alpha 和 beta 指定。这些圆锥体的相交形成两条线,z 正方向上的一条线可用作长度为 c 的 axis_c 的方向。
有人知道我应该如何确定 axis_c 吗?
谢谢。
I'm trying to generate some axis vectors from parameters commonly used to specify crystallographic unit cells. These parameters consist of the length of the three axes: a,b,c and the angles between them: alpha,beta,gamma. By convention alpha is the angle between the b and c axes, beta is between a and c, and gamma between a and b.
Now getting vector representations for the first two is easy. I can arbitrarily set the the a axis to the x axis, so a_axis = [a,0,0]. I then need to rotate b away from a by the angle gamma, so I can stay in the x-y plane to do so, and b_axis = [b*cos(gamma),b*sin(gamma),0].
The problem is the third vector. I can't figure out a nice clean way to determine it. I've figured out some different interpretations but none of them have panned out. One is imagining the there are two cones around the axes axis_a and axis_b whose sizes are specified by the angles alpha and beta. The intersection of these cones create two lines, the one in the positive z direction can be used as the direction for axis_c, of length c.
Does someone know how I should go about determining the axis_c?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
已知长度的两个向量 u,v 之间的角度 alpha 可以从它们的内(点)积 找到:
cos(alpha) = /(| |u|| ||v||)
也就是说,alpha 的余弦是两个向量除以它们长度的乘积的内积。
所以第三个的 z 分量可以是任何非零值。在获得正确的角度后缩放任何或所有轴向量不会改变角度,因此我们假设(比方说)Cz = 1。
现在前两个向量也可能是 A = (1,0,0) 和B = (cos(伽玛),sin(伽玛),0)。它们的长度都是 1,因此选择 C 需要满足的两个条件是:
cos(alpha) = /||C||
cos(beta) = /||C||
现在我们只有两个未知数 Cx 和 Cy 需要求解。为了简单起见,我将它们称为 x 和 y,即 C = (x,y,1)。因此:
cos(alpha) = [cos(gamma)*x + sin(gamma)*y]/sqrt(x^2 + y^2 + 1)
cos(beta) = x/(sqrt(x^2 + y) ^2 + 1)
将第一个方程除以第二个方程(假设 beta 不是直角!),我们得到:
cos(alpha)/cos(beta) = cos(gamma) + sin(gamma)*(y/x)
是一个线性方程,用于求解比率 r = y/x 得到该值后,将 y = rx 代入上面的第二个方程中并平方,得到 x 的二次方程:
cos。 ^2(β)*((1+r^2)x^2 + 1) = x^2
cos^2(β) = (1 - cos^2(β)*(1 + r^2))x ^2
x^2 = cos^2(beta)/[(1 - cos^2(beta)*(1 + r^2))]
通过对方程求平方,我们引入了一个工件根,对应于选择 x 的符号。检查在“原始”第二个方程中得到的 x 的解,以确保得到正确的 cos(beta) 符号
添加:
如果 beta 是直角,事情会比更简单。上面的 x = 0 是强制的,我们只需求解 y 的第一个方程:
cos(alpha) = sin(gamma)*y/sqrt(y^2 + 1)
平方并乘以分母即可得出 y 的二次方程,与我们之前所做的类似。请记住检查您选择的 y 符号:
cos^2(alpha)*(y^2 + 1) = sin^2(gamma)*y^2
cos^2(alpha) = [sin^2(gamma) - cos^2(alpha)]*y^2
y^2 = cos^2(alpha)/[sin^2(gamma) - cos^2(alpha)]
实际上,如果角度 alpha、beta、gamma 之一是一项权利角度,最好标记该角度 gamma(前两个向量 A、B 之间)以简化计算。
The angle alpha between two vectors u,v of known length can be found from their inner (dot) product <u,v>:
cos(alpha) = <u,v>/(||u|| ||v||)
That is, the cosine of alpha is the inner product of the two vectors divided by the product of their lengths.
So the z-component of your third can be any nonzero value. Scaling any or all of the axis vectors after you get the angles right won't change the angles, so let's assume (say) Cz = 1.
Now the first two vectors might as well be A = (1,0,0) and B = (cos(gamma),sin(gamma),0). Both of these have length 1, so the two conditions to satisfy with choosing C are:
cos(alpha) = <B,C>/||C||
cos(beta) = <A,C>/||C||
Now we have only two unknowns, Cx and Cy, to solve for. To keep things simple I'm going to just refer to them as x and y, i.e. C = (x,y,1). Thus:
cos(alpha) = [cos(gamma)*x + sin(gamma)*y]/sqrt(x^2 + y^2 + 1)
cos(beta) = x/(sqrt(x^2 + y^2 + 1)
Dividing the first equation by the second (assuming beta not a right angle!), we get:
cos(alpha)/cos(beta) = cos(gamma) + sin(gamma)*(y/x)
which is a linear equation to solve for the ratio r = y/x. Once you have that, substituting y = rx in the second equation above and squaring gives a quadratic equation for x:
cos^2(beta)*((1+r^2)x^2 + 1) = x^2
cos^2(beta) = (1 - cos^2(beta)*(1 + r^2))x^2
x^2 = cos^2(beta)/[(1 - cos^2(beta)*(1 + r^2))]
By squaring the equation we introduced an artifact root, corresponding to choosing the sign of x. So check the solutions for x you get from this in the "original" second equation to make sure you get the right sign for cos(beta).
Added:
If beta is a right angle, things are simpler than the above. x = 0 is forced, and we have only to solve the first equation for y:
cos(alpha) = sin(gamma)*y/sqrt(y^2 + 1)
Squaring and multiplying away the denominator gives a quadratic for y, similar to what we did before. Remember to check your choice of a sign for y:
cos^2(alpha)*(y^2 + 1) = sin^2(gamma)*y^2
cos^2(alpha) = [sin^2(gamma) - cos^2(alpha)]*y^2
y^2 = cos^2(alpha)/[sin^2(gamma) - cos^2(alpha)]
Actually if one of the angles alpha, beta, gamma is a right angle, it might be best to label that angle gamma (between the first two vectors A,B) to simplify the computation.
这是查找所有 Cx、Cy、Cz 的方法(前两个与其他答案中的相同),假设 A = (Ax,0,0)、B = (Bx, By, 0),并假设|C| = 1
1) cos(β) = AC/(|A||C|) = AxCx/|A| =>
Cx = |A|cos(beta)/Ax = cos(beta)
2) cos(alpha) = BC/(|B||C|) = (BxCx+ByCy)/|B| =>
Cy = (|B|cos(alpha)-Bx cos(beta))/By
3) 要找到 Cz,令 O 为 (0,0,0) 处的点,T 为 ( Cx,Cy,Cz),P 是 T 在 Oxy 上的投影,Q 是 T 在 Ox 上的投影。因此 P 是 (Cx,Cy,0) 处的点,Q 是 (Cx,0,0) 处的点。因此,从直角三角形 OQT 可以得到
tan(beta) = |QT|/||OQ| = |QT|/Cx
并且从直角三角形 TPQ 我们得到 |TP|^2 + |PQ|^2 = |QT|^2。所以
Here is a way to find all Cx, Cy, Cz (first two are the same as in the other answer), given that A = (Ax,0,0), B = (Bx, By, 0), and assuming that |C| = 1
1) cos(beta) = AC/(|A||C|) = AxCx/|A| =>
Cx = |A|cos(beta)/Ax = cos(beta)
2) cos(alpha) = BC/(|B||C|) = (BxCx+ByCy)/|B| =>
Cy = (|B|cos(alpha)-Bx cos(beta))/By
3) To find Cz let O be the point at (0,0,0), T the point at (Cx,Cy,Cz), P be the projection of T on Oxy and Q be the projection of T on Ox. So P is the point at (Cx,Cy,0) and Q is the point at (Cx,0,0). Thus from the right angle triangle OQT we get
tan(beta) = |QT|/||OQ| = |QT|/Cx
and from the right triangle TPQ we get |TP|^2 + |PQ|^2 = |QT|^2. So
我不确定这是否正确,但我不妨尝试一下。希望我不会得到十亿票反对...
我太懒了,无法按必要的量缩放向量,所以我假设它们都被标准化为长度为 1。您可以进行一些简单的修改计算以考虑不同的尺寸。另外,我将使用 * 来表示点积。
A = (1, 0, 0)
B = (cos(g), sin(g), 0)
C = (Cx, Cy, Cz)
A * C = cos(beta) //这只是一个定义点积。我假设幅度为 1,所以我可以跳过该部分,并且您说 beta 是 A 和 C 之间的角度。
A * C = Cx //我通过将每个相应值相乘来做到这一点,并且 Cy 和Cz 被忽略,因为它们被乘以 0
cos(beta) = Cx //合并前两个方程
B * C = cos(alpha)
B * C = Cx*cos(g) + Cy*sin(g) = cos(beta) * cos(g) + Cy*sin(g)
(cos(alpha) - cos(beta) * cos(g))/(sin(g)) = Cy
说实话,我不确定如何获得向量 C 的 z 分量,但我希望这是一个相对简单的步骤。如果我能弄清楚,我会编辑我的帖子。
I'm not sure if this is correct but I might as well take a shot. Hopefully I won't get a billion down votes...
I'm too lazy to scale the vectors by the necessary amounts, so I'll assume they are all normalized to have a length of 1. You can make some simple modifications to the calculation to account for the varying sizes. Also, I'll use * to represent the dot product.
A = (1, 0, 0)
B = (cos(g), sin(g), 0)
C = (Cx, Cy, Cz)
A * C = cos(beta) //This is just a definition of the dot product. I'm assuming that the magnitudes are 1, so I can skip that portion, and you said that beta was the angle between A and C.
A * C = Cx //I did this by multiplying each corresponding value, and the Cy and Cz were ignored because they were being multiplied by 0
cos(beta) = Cx //Combine the previous two equations
B * C = cos(alpha)
B * C = Cx*cos(g) + Cy*sin(g) = cos(beta) * cos(g) + Cy*sin(g)
(cos(alpha) - cos(beta) * cos(g))/(sin(g)) = Cy
To be honest, I'm not sure how to get the z component of vector C, but I would expect it to be one more relatively easy step. If I can figure it out, I'll edit my post.