Is the trigonometry explanation correct?

I think the letters in the image are wrong and it got me all confused. I couldn’t figure out how you ended up with that formula. I think if you swap A with C and B with D it makes more sense, since then the ground offset will be at the targeted point level and not at the camera level. So I think the correct figure is this one:

I believe Sam chose to represent it the way he did because ray.direction.length (A) will always be 1, and ray.direction.y will always be scaled so that the length of ray.direction.length is equal to 1. Unless the ground offset was significantly less than 1, D will always be greater than b

1 Like

I still don’t get why the length of the ray will be 1 since this is supposed to start from the camera and reach the ground. I am sure I am not understanding something here. The ground offset was set to 1 in the code by Sam.

When a Ray is stored, it has two components, the origin, and the direction. Since a ray is infinite, it doesn’t matter if the magnitude is 1 or 12000. To make things easier for programmers, Ray.direction is always returned as a normalized vector. All normalized vectors have a magnitude of 1.

Oh alright I see. Thanks :slight_smile:

Privacy & Terms