#### Archived

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

# A 'Homework' question

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

## Recommended Posts

Hi guys, I'm reading a book, and I have a question.. There, they show an example of how to obtain the projection of one vector ontho another. they write the following equation for this: SideAdjacentOfaTriangle = P.Q / ||Q|| Where P and Q are vectors (and P.Q is the dot product between the two vectors), / is the sign of division and ||Q|| is the magnitude of the vector Q. Until now, everything is fine... but after, they say that if we multiply this equation by Q / ||Q|| we can obtain the projection of P onto Q. Then, the final equation looks like this: ProjectionofPontoQ = (P.Q / ||Q||² ) * Q So, I didn't understand how they did that... How they multiplyed the first equation by Q / ||Q||. How do they calcule Q / ||Q|| if Q is a vector and ||Q|| is a scalar and arrive to 'ProjectionofPontoQ'? It is not possible for me! Any hints? Fernando [edited by - FERNANDO-BRASIL on August 26, 2002 11:56:18 AM] [edited by - FERNANDO-BRASIL on August 26, 2002 12:09:13 PM] [edited by - FERNANDO-BRASIL on August 26, 2002 12:45:08 PM]

##### Share on other sites
P.Q and ||Q|| are scalar values. All the scalar values multiply together, leaving the vector at the end ( * Q )

At least, from where I see it, that's how it works.

Given a vector A made up of (A.x, A.y), then S * A where S is a scalar results in (S * A.x, S * A.y)

[edited by - Waverider on August 26, 2002 12:03:40 PM]

##### Share on other sites
But how they Multiply (P.Q / ||Q||) by (Q / ||Q||) ???

The problem I see here, is that the second one is very strange...
Because it returns a vector and not a scalar.

##### Share on other sites
The first part is a scalar, and the second part is the normalized vector Q, so the result will be a vector of magnitude (P.Q / ||Q||) and of direction Q.

Please, if you do post ''homework'' questions, at least, use a significant title for your thread. ''??'' is just meaningless. 95% of the posts around here are questions.

Cédric

##### Share on other sites
That''s a fraction multiplication, so the denominator of the first fraction is multiplied by the denominator of the secund fraction... And you do the same with the fraction''s numerator

e.g. (A,C,D,E scalars): A/C * D/E = (A*D)/(C*E)

##### Share on other sites
Yeahh! THank you HiddenInBSP.

I''ve thought in this too, but for example:

(P.Q / ||Q||) * (Q / ||Q||)

Should result:

( (P.Q) Q ) / (||Q||²)

and not:

( (P.Q) / (||Q||²) ) Q

why the book show this result?

Thank you
Fernando

##### Share on other sites

Seriously, you didn't have to rename this thread. I was mostly angry about the non-descriptive title.

( (P.Q) Q ) / (||Q||²)

is the same as

( (P.Q) / (||Q||²) ) Q

You're just moving the Q out of the numerator. Since it's a multiplication, it's valid. Check out associativity (I think that's the correct name for this property, but I'm not sure)

Cédric

[edited by - cedricl on August 26, 2002 1:05:10 PM]

##### Share on other sites
They are algebraically the same.

The left part is a full scalar result, the right part is a vector only. Probably to make it clear which part of the result is scalar and which part is vector.

Which would also make it easier to work with if you plan to perform further operations with the result (instead of having to hunt for the scalar and vector portions)

##### Share on other sites
Thank you guys!

I tested the two equation, made the calculus and saw that the two results the same. It is impressionant!!!! hehe

Thank you a lot!

##### Share on other sites
I''ll let this "homework" question slide, since the subject matter is commonplace in game development. But, as cedricl said, I don''t approve of homework question in general. Consider this a warning, .

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

1. 1
Rutin
68
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 21
• 10
• 33
• ### Forum Statistics

• Total Topics
633438
• Total Posts
3011881
• ### Who's Online (See full list)

There are no registered users currently online

×