"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.

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 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

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 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 on other sites

thanks very much!

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 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

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 34
• 16
• 11
• 12
• Forum Statistics

• Total Topics
634123
• Total Posts
3015649
×