Sign in to follow this  
homer_3

Ray creation clarifaction

Recommended Posts

homer_3    173
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
moosedude    145
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
alvaro    21246
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this