开发者

axes separated by angles

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 abou开发者_如何学编程t determining the axis_c?

Thanks.


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.


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

Cz = |TP| = sqrt(|QT|^2 - |PQ|^2) = sqrt( Cx^2 tan(beta)^2 - Cy^2 )


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜