#### Archived

This topic is now archived and is closed to further replies.

# Just a brief explanation

This topic is 5615 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Ok so I''m talking about a projection problem from vector1 to vector2. Once I do all the math I use the angle and apply the same angle to x,y,z and it gives the new direction. Can someone explain why? I mean wouldnt you have to get a different angle for each direction to apply the yaw, pitch, and roll to be correct? I''m sure its a trig rule I''m not aware of.

##### Share on other sites
Are you referring to vector projecting? Well if you want me to go through a proof, I could do that, but let's break the projection formula up into components: It is essentially RcosX, but in vector form. Ok You have two vectors, u and v. If you want to project u onto v, you must first form a right triangle out of the two, so the hypotenuse will be ||u||, another will be along v that is k||v|| long (which will be the length of our projected vector, k is a constant), and the third side is the dot product of u and v (the function returns the shortest distance between the ends of two vectors which is always a perpendicular to one of them). So to get the correct length of u when projected onto v, you need to know the cosine of the angle between the two vectors, which is (u dot v) / (||u||*||v||). If you need a proof of that I could go through that. so now you have everything you need!. ||u|| * cos theta will give you the adjacent side. Working this out comes out to (u dot v) / ||v||. Now all we need is a direction, so we multiply by it by v since that's the direction we wanted in the first place. Remember that direction must be normalized so its v / ||v|| and not just v. You MAY want to write this all down because it can be hard to swallow at once.

Edit: This all works because the vectors can be shifted around so that they are coplanar

[edited by - uber_n00b on May 30, 2004 1:53:20 PM]

##### Share on other sites
yeah I think i''m having a hard time picturing it and relating it to look, up, and right vectors within the 4x4 amtrix.

I have a plane flying a pattern so I need a new yaw, pitch, and roll based on his current heading.

But heres where I get lost. How can you get a right triangle in 3D space. wouldn''t it require 2. Or are you saying a right triangle U on top of a Right triangle V would create the correct right triangle based on U''s plane?

I dont need great detail I''m just trying to picture this in 3D and take the last swallow.

I''ve been readin tons of web sites and they say to multiply the dot product by the axis of each angle. So once I normalize my new result of the product, I then multiply by each of the x,y,z axises?
This may be ignorant but I cant seem to picture the steps and how one right triangle pushed into 3 axis''s of an object yields the correct results.
Nick

##### Share on other sites
Well think about this: Think of two infinite vectors, one stretching infinitely in the direction your object is traveling, and the second stretching infinitely in the direction your object must travel to get to a certain point. Since both infinite vectors have a common origin, you have yourself a unique plane on which the direction vector (u) and the desired movement vector (v) both lie on. You can form a right triangle out of those two vectors by simply dropping down a line that is perpendicular to either vector and connecting to the other. Am I making sense? That is the right triangle, although you were correct before in stating that this is formed by two right triangles (one lying along the x-y plane and one along the z-y plane), but I sort of slipped past that). Yes once you normalize the result you multiply it by the x/y/z directions of your intended trajectory. It''s alright, we all get stuck on stuff somewhere along the way. You notice I''m not answering any matrix-related questions because well, I never learned matrices in my life! (Keep in mind I only have one more class to take to get my minor in math, which makes it doubly sad). My algebra II class 3 yrs ago skipped over matrices

##### Share on other sites
so after that saying heres what I interpret:

This angle is for the right triangle formed on plane 1. Cant really say its x-y, y-z, etc...

The dot product resolves this conflict.

That answers that question. But after that would I grab a cross product to get the next dot product and that would get the final axis angle I would need?

I mean that would form 2 right triangles crossing thier plane wouldnt it?

I''m trying to get this all straight.

I dont really care about matrices, I would just like to know exactly how this is done.

Thanks for a ll the help too.
Nick

##### Share on other sites
or is it forming a arc so all of the planes meet equally by that, applying the same angle to all would result in a correct angle for all of them since its a centr point like an arc.

Nick

if so, you wouldnt know where the arccos function exists in c++. I cant find it.

[edited by - nick5454 on May 30, 2004 9:11:01 PM]

##### Share on other sites
Check out this page at approximately 11:05 (it is currently 10:45). This will illustrate my point, and I believe clear up all your issues: http://www.geocities.com/vsage3/w333.bmp .

##### Share on other sites
Hey thanks for all the help. I understand everything now. Even though I was going the wrong way about it. But its worth the comprehension even though I was ready to scream all weekend.

Thanks

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 18
• 35
• 9
• 16
• 22