The Ray Tracer Challenge - 002 - Math & Vectors - Chapter 01 - Part 2

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ก.ค. 2024
  • Join me, while I implement chapter by chapter from the book "The Ray Tracer
    Challenge" by Jamis Buck in Rust a language completely new to me.
    Come with me on the journey of learning the Rust programming language, while
    implementing a Ray Tracer in a Test driven fashion, to have fun and (hopefully)
    create some astonishing rendered graphics.
    Let's study the inner workings of a Ray Tracer, and take a look under the hood
    of the Rust language, while taking on this challenge on a biweekly basis.
    All the code produced within this series is provided on github, for you to
    follow along.
    Github: github.com/jakobwesthoff/the_...
    The Ray Tracer Challenge (affiliate): amzn.to/3xVssbR
    Rust: www.rust-lang.org/
    0:00:00 - Welcome To Part 2
    0:00:22 - Intermission: Where to find the Code?
    0:01:04 - Recap
    0:02:22 - Subtracting two Tuples
    0:11:13 - Ensuring subtraction of two points yields a vector
    0:16:45 - Subtracting two Vectors
    0:19:03 - Implementing the negation of Tuples
    0:28:24 - Multiplying a Tuple by a Scalar value
    0:35:50 - Implementing Division of a Tuple with a Scalar
    0:39:49 - Calculating the magnitude of a Vector
    0:56:28 - Normalization of Vectors
    1:04:03 - Fuzzy float comparison
    1:15:51 - Outlook for whats to come
    1:16:38 - Thanks / Outro
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 8

  • @mrwalter1049
    @mrwalter1049 8 หลายเดือนก่อน

    One good exercise for pythagorean theorem is to algebraically solve for the hypotenuse of a triangle in three dimensions. It should spit out the same thing as you are describing here, since the square roots and squaring of the legs of the triangles cancel each other out. I highly suggest it for high schoolers if they haven't done it before.

  • @deepjaysoul
    @deepjaysoul 2 ปีที่แล้ว

    Thank you very much for this series! It actually inspired me to get the book and do the challenge while learning a new language…😀 But I have chosen go instead of rust and the test driven approach is also pretty new for me…best regards from Karlsruhe!

    • @MrJakob
      @MrJakob  2 ปีที่แล้ว +1

      That’s great to hear. Should you decide to publish your work on GitHub or the like, I would love to take a peak at it 😁

  • @MaxxxiorPL
    @MaxxxiorPL 10 หลายเดือนก่อน

    Great series! I got the book and started implementing my own ray tracer in Rust (I am learning it as well). There is nice library called glam (a linear algebra library for games and graphics), but I like implementing the math myself 😄

    • @MrJakob
      @MrJakob  10 หลายเดือนก่อน

      Thanks. Yes I discovered glam by now as well, but same as you I wanted to do things from scratch to learn 😁

  • @Iogoslavia
    @Iogoslavia 2 ปีที่แล้ว

    If vector and point are always used in different places why not just declare them as different types?

    • @MrJakob
      @MrJakob  2 ปีที่แล้ว

      As vector and point are only different with regards to their fourth value, but otherwise identical with regards to their whole implementation, I did not want to copy and paste this implementation part. By now I know that I could use a const Generic for this, which I am not sure I really much like. If you know another more elegant solution, to distinguish their type, but reuse the implementation, I would be very glad to hear about it, as I didn’t stumble across a nice way of doing this, yet. (However I didn’t really search for one either 😅).

    • @Iogoslavia
      @Iogoslavia 2 ปีที่แล้ว

      @@MrJakob I was mostly thinking on how easy it is to call invalid operations like adding two points or multiplying s point by a scalar. Having different types would avoid these possible bugs altogether.
      But you do have a point, there would be quite a bit of duplicate code. I'm still learning Rust myself só I don't know any elegant solution to this either 😅
      Anyway, I'm really enjoying this series, thank you very much for sharing this. :)