Jump to content
  • Advertisement
Sign in to follow this  
homer_3

Ray creation clarifaction

This topic is 3660 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've noticed there are a few functions that take rays as input. I know a ray is two vectors, a position and a direction, but I was wondering how the direction was written. Is it just a 3d vector where you fill in a 1 for positive, 0 for non-existent, and -1 for negative? ex new Vector3(1,0,0) would mean that the direction was on the positive X axis and new Vector3(0,-1,0) would mean negative Y axis. Is this right? I haven't been able to find much info on this.

Share this post


Link to post
Share on other sites
Advertisement
yes, you are correct. I guess the best way to describe the vector examples you gave would be as normalised vectors. (values between -1 and 1)

They are essentially just "pointing" in a direction, with no start or end position; almost an infinite line.

any values would generally be valid, such as (0,0.5,0) would be the same direction as (0,1,0), but the magnitude would be different.

sometimes its difficult to find resources stating the obvious to simple questions, you're not alone. Sometimes my head needs refreshing with the basic only to be confronted with pages of equations and proofs when something plain and to the point is needed.

Share this post


Link to post
Share on other sites
Most of what you said is correct, except the part about the components of the direction vector being -1, 0 or 1. They can be any real number, really. For instance, you may have a ray that starts at (-1,4,2.33) pointing in the direction (-1.2,0.3,0.1).

If you ever learn what an affine space is (I recommend taking some kind of Linear Geometry course in college where this is covered), you'll think of points and vectors as different things: A point represents a position in space, while a vector represents a direction in which you can translate. A ray is described by a point and a vector, not two vectors.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!