filmov
tv
Unit tests and Line vs Circle | Coding a 2D Physics Engine in Java #6

Показать описание
In this episode I go over how to tell if a line segment is intersecting with a circle. We use some fancy math to project the vector from the line's beginning to the center of the circle onto the line segment, then we check the length of that against the length of the line. If the length of the circle to beginning of the line segment is less than the lenght of the line segment and greater than zero, then the line is intersecting. I also go over how to create unit tests for all these functions. So, we integrate JUnit, then set up a simple test class, and finally add the test class to our build configuration so that unit tests are run before the program is started every time. This is a good way to ensure that your code doesn't break if you change things in the future.
0:00 Intro
0:44 Math behind line vs circle
6:11 Coding line vs circle
10:51 Setting up unit tests
---------------------------------------------------------------------
Here are some books I recommend if you want to learn about game engine development more thoroughly. I do not profit off any of these sales, these are just some books that have helped me out :)
My Recommended Game Engine Books:
My Recommended Beginning Game Programming Books:
My Recommended Java Books:
Комментарии