Calculating angles from normalized vectors
Moderator: Alyrium Denryle
- Guy N. Cognito
- Padawan Learner
- Posts: 488
- Joined: 2004-06-02 01:26am
- Location: Vancouver B.C
- Contact:
Calculating angles from normalized vectors
Is anybody able to give me help trying to calculate angles (hell I'd even settle for radians) from a set of normalized vectors. MY attempts to do this without the math classes that teach this have come to an abysmal failure. So if anybody knows how to do this and feels like explaining it could you reply please. It's been bugging me all day. Thanks.
"Though there are only 5 colours, in combination, they can create more hues then can ever be seen" Sun Tzu, The Art of War
- Guy N. Cognito
- Padawan Learner
- Posts: 488
- Joined: 2004-06-02 01:26am
- Location: Vancouver B.C
- Contact:
Sorry, I should have said the angle between two components of normalized vectors. And yes I know it's sounds simplistic, but it's just not working for me. I'm just trying to figure out if the problem is between the seat and teh keyboard.
"Though there are only 5 colours, in combination, they can create more hues then can ever be seen" Sun Tzu, The Art of War
- Prozac the Robert
- Jedi Master
- Posts: 1327
- Joined: 2004-05-05 09:01am
- Location: UK
Sorry if I missunderstand, but...
(a,b) has two components you might be interested in. Remember that a is entirely in the x direction, and b is entirely in the y direction. Therefore the angle between the two components will always be 90 degrees.
{If you have more weird kinds of vectors with respect to silly bases, I think you can treat the components you are interested in as separate vectors and calculate the scalar (dot) product.}
(a,b) has two components you might be interested in. Remember that a is entirely in the x direction, and b is entirely in the y direction. Therefore the angle between the two components will always be 90 degrees.
{If you have more weird kinds of vectors with respect to silly bases, I think you can treat the components you are interested in as separate vectors and calculate the scalar (dot) product.}
Hi! I'm Prozac the Robert!
EBC: "We can categorically state that we will be releasing giant man-eating badgers into the area."
EBC: "We can categorically state that we will be releasing giant man-eating badgers into the area."
- Guy N. Cognito
- Padawan Learner
- Posts: 488
- Joined: 2004-06-02 01:26am
- Location: Vancouver B.C
- Contact:
- Kuroneko
- Jedi Council Member
- Posts: 2469
- Joined: 2003-03-13 03:10am
- Location: Fréchet space
- Contact:
The dot product of two vectors is by definition the product of their norms with the cosine of the angle between them. If the vectors are normalized, then they have unit norm (length), which means the dot product is exactly the cosine of the included angle: cos θ = g_{ij}x^ix^j, where g_{ij} is the metric tensor, which depends on the coordinate system one is working in. For Cartesian coordinates in ordinary n-dimensional Euclidean space, g_{ij} is the n-by-n unit matrix, so the dot product of vectors v and w is vw = v^1w^1 + v^2w^2 + ... + v^nw^n. For example, in three-dimensional space, let v = [1 2 3]' and w = [4 5 6]', making their dot product 1*4 + 2*5 + 3*6 = 32. The norm of v is sqrt(14) and the norm of w is sqrt(77), so the angle between them satisfies cos θ = 32/[sqrt(14)sqrt(77)] = 0.9756, so θ = 0.2257 = 12.93°.Guy N. Cognito wrote:Is anybody able to give me help trying to calculate angles (hell I'd even settle for radians) from a set of normalized vectors.
The angle between two components is the angle between two coordinate unit vectors at that point, which is found in just the same manner as above. Ordinarily, coordinate systems are orthogonal, making the answer either 90° or 0° in the case of the same component, but in general there is nothing to require that coordinate systems are orthogonal--this happens when the coordinate basis is not orthogonal and more generally when the metric tensor is not diagonal. That is the only case your question makes sense and is still nontrivial, which is why I ventured into tensor territory.Guy N. Cognito wrote:Sorry, I should have said the angle between two components of normalized vectors.
Are you trying to rotate by an angle around an axis? The rotation matrix is R = [ cos θ, sin θ; -sin θ, cos θ ], which rotates a vector in Cartesian coordinates [x;y] counter-clockwise from the x-axis by angle θ. For three-dimensional rotations, see here.Guy N. Cognito wrote:Bah..... I sort of have it and I don't, each axis works well with independent rotation, but when they get combined, I get really odd errors.
- Guy N. Cognito
- Padawan Learner
- Posts: 488
- Joined: 2004-06-02 01:26am
- Location: Vancouver B.C
- Contact:
I finally got it. Unfortunately, it breaks when I try to work in multiple planes of rotation. The reason being is that I'm over rotating . I thank you for the help, that web page is a definite keeper.
"Though there are only 5 colours, in combination, they can create more hues then can ever be seen" Sun Tzu, The Art of War
- Kuroneko
- Jedi Council Member
- Posts: 2469
- Joined: 2003-03-13 03:10am
- Location: Fréchet space
- Contact:
Keep in mind that general rotations are not commutative (a fact which one can easily verify with, say, doing two rotations on a book, and then the same ones from the original position in reverse order). If that is not the cause of your difficulty, what exactly are you trying to do?Guy N. Cognito wrote:Unfortunately, it breaks when I try to work in multiple planes of rotation. The reason being is that I'm over rotating .
- Guy N. Cognito
- Padawan Learner
- Posts: 488
- Joined: 2004-06-02 01:26am
- Location: Vancouver B.C
- Contact:
The problem was I first programmed each axis to rotate 100% on their own, so when an object was in the -/- quadrant of it's axis, it would still work. Unfortunately that causes over rotation when I combine the rotation in the various planes. The only problem now is the special case scenarios on the zero of axises. I think I've got it covered though. It's nice to know I can get help with complex math problems if needed.
If you were curious as to what I was actually doing, I was attempting to rotate an object to a normalized vector returned to me. It was a method of populating a tree with leaves quickly.
If you were curious as to what I was actually doing, I was attempting to rotate an object to a normalized vector returned to me. It was a method of populating a tree with leaves quickly.
"Though there are only 5 colours, in combination, they can create more hues then can ever be seen" Sun Tzu, The Art of War
- Kuroneko
- Jedi Council Member
- Posts: 2469
- Joined: 2003-03-13 03:10am
- Location: Fréchet space
- Contact:
If I understand you correctly, your task is to determine the rotation that takes a given unit vector u pointing from the origin to some reference point on an object to some other unit vector v, and apply the same rotation to another set of vectors determined by the object's geometry. In this scenario, obtaining fully indepedent rotation about the axes is a lost cause, since in this situation there are less degrees of freedom than coordinate axes. This fact is easily seen by transforming to spherical coordinates, in which all unit vectors will be represented by (1,θ,φ), x = cos θ sin φ, y = sin θ sin φ, z = cos θ, and rotations as simply an addition or subtraction of θ or φ. Incidently, transforming to spherical coordinates, rotating, and back to Cartesian ones is one way to solve this problem, although a rather inelegant and computationally cumbersome one. One can, of course, still force a decomposition into three rotations about the axes, but since rotations are not commutative, there is absolutely no advantage in doing so (a strict order of rotation would have to be enforced). Probably the computationally cleanest approach would be to treat this in quaternions, which are made for rotations. If you are not familiar with quaternions, one can recast them in terms of matrices and vectors, but before I go into that, I would like to know if my interpretation of your problem is what you actually intended. If not, well, in that case I am still unclear as to what the task is.Guy N. Cognito wrote:The problem was I first programmed each axis to rotate 100% on their own, so when an object was in the -/- quadrant of it's axis, it would still work. ... If you were curious as to what I was actually doing, I was attempting to rotate an object to a normalized vector returned to me. It was a method of populating a tree with leaves quickly.
- Darth Wong
- Sith Lord
- Posts: 70028
- Joined: 2002-07-03 12:25am
- Location: Toronto, Canada
- Contact:
Heh heh ... it's been so long since I did that stuff manually that I don't really remember it at all. I've done that sort of thing with CAD software for too long, I suppose.
"It's not evil for God to do it. Or for someone to do it at God's command."- Jonathan Boyd on baby-killing
"you guys are fascinated with the use of those "rules of logic" to the extent that you don't really want to discussus anything."- GC
"I do not believe Russian Roulette is a stupid act" - Embracer of Darkness
"Viagra commercials appear to save lives" - tharkûn on US health care.
http://www.stardestroyer.net/Mike/RantMode/Blurbs.html
"you guys are fascinated with the use of those "rules of logic" to the extent that you don't really want to discussus anything."- GC
"I do not believe Russian Roulette is a stupid act" - Embracer of Darkness
"Viagra commercials appear to save lives" - tharkûn on US health care.
http://www.stardestroyer.net/Mike/RantMode/Blurbs.html