Advertisement Jump to content
Sign in to follow this  
Doublefris

"Squaring" a vector

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was reading an article on ray-sphere intersection on http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-sphere-intersection/, and came across this :

 

|o + rt|^2 - R^2 = 0

 

When we develop this equation we get (equation 3):

o^2 + rt^2 + 2ort - R^2 = 0

 

how are they able to do this? and I guess o^2 means the dot product in this case?

Share this post


Link to post
Share on other sites
Advertisement

I was reading an article on ray-sphere intersection on http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-sphere-intersection/, and came across this :

 

|o + rt|^2 - R^2 = 0

 

When we develop this equation we get (equation 3):

o^2 + rt^2 + 2ort - R^2 = 0

 

how are they able to do this? and I guess o^2 means the dot product in this case?

 

Yes, that is a common short-hand for the dot product of a vector with itself.

 

-Josh

Share this post


Link to post
Share on other sites

 

I was reading an article on ray-sphere intersection on http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-sphere-intersection/, and came across this :

 

|o + rt|^2 - R^2 = 0

 

When we develop this equation we get (equation 3):

o^2 + rt^2 + 2ort - R^2 = 0

 

how are they able to do this? and I guess o^2 means the dot product in this case?

 

Yes, that is a common short-hand for the dot product of a vector with itself.

 

-Josh

 

 

So we have something like (o + rt).(o + rt) 

what property of dot product allows us to foil it out ?

Share this post


Link to post
Share on other sites

 

 

I was reading an article on ray-sphere intersection on http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-sphere-intersection/, and came across this :

 

|o + rt|^2 - R^2 = 0

 

When we develop this equation we get (equation 3):

o^2 + rt^2 + 2ort - R^2 = 0

 

how are they able to do this? and I guess o^2 means the dot product in this case?

 

Yes, that is a common short-hand for the dot product of a vector with itself.

 

-Josh

 

 

So we have something like (o + rt).(o + rt) 

what property of dot product allows us to foil it out ?

 

 

The dot product has the properties of being commutative, distributive, and associative, which mean you can expand it as

 

(x + y).(x + y) = x.x + x.y + y.x + y.y = x.x + 2x.y + y.y = x^2 + y^2 + 2x.y

 

-Josh

Share this post


Link to post
Share on other sites

Don't the |'s usually represent magnitude or length, for example |v| is the magnitude of v.  So when he is doing |v|^2, he's just squaring the length.  (Which is also the equivalent of dotting a vector with itself)

Share this post


Link to post
Share on other sites

Don't the |'s usually represent magnitude or length, for example |v| is the magnitude of v.  So when he is doing |v|^2, he's just squaring the length.  (Which is also the equivalent of dotting a vector with itself)

 

More or less. The vertical straight lines (single and sometimes double) indicates a norm and, unless otherwise noted, that usually means a Euclidean norm for a vector which is equivalent to the square root of the dot product of a vector with itself. However, there are other norms where that is not the case.

 

-Josh

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!