Why does 2-angle between vectors give different components then individual angles?

My problem is with 3d vectors but the problem is the same in 2-d and a bit easier to explain so I will in 2-d.
I am modeling oblique impacts and I have Vx and Vy acting at an angle theta.
To get the components of velocity acting along theta it is:
Xcomponent = Vx*cos(theta)
Ycomponent = Vy*cos(90-theta)
Now I try and do the same problem but with Vx and Vy as a vector and then try to get the components acting along vector with angle theta and get a different result. How do I use vectors to get the same result?
This is what I did. Found the angle between the two vectors.
Angle_between = acos(dot(vector_along_theta,Vx_VY_vector))
Xcomponent = Vx*cos(Angle_between)
Ycomponent = Vy*cos(Angle_between)
Can not give the same result cause for the Y component the first way uses theta the second 90-thea.
Plus the resultant angle between them is not the same as theta anyway.
Help would be greatly appreciated!!! I got a C+ in physics back in the day, probably why I can't figure this out.

7 Comments

Can you explain what Vx and Vy are? You say they act at an angle theta. They act at an angle theta relative to what? Please give a very simple numerical example so I know how many elements each variable has.
Cody - I'm guessing that the above is just an example so that when you really do
cos(90-theta)
you either convert 90 degrees to radians, or use cosd instead (are the units for theta radians or degrees?). For simplicity, you could replace this with the sine equivalent since
cos(90-theta) = cos(90)*cos(theta) + sin(90)*sin(theta)
= 0*cos(theta) + 1*sin(theta)
= sin(theta)
So your x and y components become
Xcomponent = Vx*cos(theta);
Ycomponent = Vy*sin(theta);
The above assumes that theta is in radians.
Thanks you for the responses. I will answer your questions so we can get to the heart of it. Geoff Hayes yes in the code I really just used sin and it is in radians so I should have said cos(1.57-theta).
Will give you the numbers for an example case.
Vx = 59.22 Vy = -28.22 Theta = .9418
Result
VXcomponent=34.84
Vycomponent=-22.97
Now the second way
Just FYI atan2(deltax/deltay) = theta where delta X and delta Y are the distance between to collides centers. I then make them first quadrant to make sign and cos values positive.
vector_along_theta = deltax + deltay = -11.56 + 15.90
Vx_VY_vector = 59.22i - 28.41j
Angle_between = .4945
VXcomponent=52.12
Vycomponent=-25.01
I did not include all the decimals. But these are the values for my example case.
Here is a site that shows the 3d problem.
I am pretty sure there 3d equation is wrong. I calculated it two ways and got the same result. The value they take the cos of is always greater then one so it results in an imaginary number. Even if you use unit vectors. I used
Angle_between(j)=atan2(norm(cross(n1(j,[1 2 3]),v1(j,[1 2 3]))),dot(n1(j,[1 2 3]),v1(j,[1 2 3])));
Angle_between(j)= acos(dot(n1u(j,[1 2 3]),v1u(j,[1 2 3])));
For 3d and got the same result so I think that it is right.
Cody - what is n1, v1, n1u, and v1u? Please write out all code from start to finish, with all local variables assigned. As well, it isn't clear what (for example)
n1u(j,[1 2 3])
is supposed to return. Is n1u a function?
The code is not very clean at the moment and would probably bring more confusion at this point. But I can answer your questions and try to explain better. Yes it uses all local variables.
V1 is velocity1 and V1u is the unit vector for velocity1. n1 is is the vector pointing toward the colliders center which is deltax i+ deltay j+deltaz K and n1u is the unit vector for vector n1. That was just to say that I think I have the 3d angle correct. Really I am using Angle_between seen below for the example.
Angle_between = acos(dot(vector_along_theta,Vx_VY_vector))
If you look at the link that I send I am just trying to solve for step 2. However it does not seem accurate that the 3d or 2d angle found times the velocity vector will really give you the components acting along colliders center.(because it is does not give the same results as example 1 which is accurate.
Still trying to figure this out. I can answer any questions.
Can you attach your code so that I (or someone else) can run through it?

Sign in to comment.

Answers (0)

Categories

Products

Asked:

on 2 Nov 2014

Commented:

on 4 Nov 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!