How being different can make you a better designer

Having a diverse team of people is extremely important in a design and branding agency, but why? How will that impact the business, the work we do and the relationships we have with clients? Well I…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Creating Rays

The Ray Tracer Challenge — by Jamis Buck (33 / 108)

👈 Chapter 5 Ray-Sphere Intersections | TOC | Intersecting Rays with Spheres 👉

Each ray created by your ray tracer will have a starting point called the origin, and a vector called the direction which says where it points. Write the following test, showing how you create a ray and what its primary attributes should be:

Armed with a ray’s origin and direction, you can find points that lie any distance t along the ray. Why t? Blame the mathematicians! It stands for time, which only makes sense once you think of the ray’s direction vector as its speed. For example, if the ray moves one unit every second, then the following figure from Scalar Multiplication and Division, shows how far the ray travels in 3.5 seconds.

images/tuples/scalar-multiplication.png

Perform the following test, which introduces a new function called position(ray, t). This function should compute the point at the given distance t along the ray.

To find the position, you multiply the ray’s direction by t to find the total distance traveled, and then add that to the ray’s origin. In pseudocode, it looks like this:

You’ll make good use of this in Chapter 6, Light and Shading, when you start turning intersections into actual surface information. It’s part of the process of computing realistic shading for your scenes.

Make sure your tests are passing before moving on. In the next section we’ll look at intersecting those rays with spheres.

👈 Chapter 5 Ray-Sphere Intersections | TOC | Intersecting Rays with Spheres 👉

Add a comment

Related posts:

Compojure

Level up your skills by taking advantage of Clojure's powerful macro system. Macros make hard things possible and normal things easy. They can be tricky to use, and this book will help you deftly navigate the terrain. You'll discover how to write straightforward code that avoids duplication and clarifies your intentions. You'll

Beginning of 2018

kita gak pernah tahu apa yang akan terjadi sama diri kita dari tahun ke tahun, hari ke hari, jam ke jam, menit ke menit bahkan sampai detik ke detik. kita cuma bisa beresolusi, melakukan ini itu…

7 Tips to Getting the Best of Your Social Media Ad.

In the past year a lot of brands churned out tons of advertising materials with millions (if not billions) spent on digital advertising in Nigeria alone. Of course a ton of these advertising money…