How to find all the cubes that the ray intersects in a 3d mesh?

I need to cast a beam from the earth into the sun and want to find if the object is in the shade. I plan to do this by tracing the line from the cube of the earth to the sun and finding that an object is interfering. However, I am not familiar with math to find all the cubes that the line intersects, so that I can check if they are full. Can anyone shed some light on this?

+3
source share
2 answers

Brute force method - checking each cube on your line. There was some kind of non-trivial IIRC geometry.

Oh. Googling "clash with the cube of the line" attracted a lot of hits. It looks pretty promising.

http://www.devmaster.net/forums/archive/index.php/t-371.html

, ( ):

8 , . .

- 6 -. , parralel . , , ( > 0) .

, - :

(x, y, z), ABCD, . , B-A C-A ( B.x - A.x, B.y - A.y ect..)

: A B, ...

.

, , - , . , ( ).

http://www.gamedev.net/community/forums/topic.asp?topic_id=185204

, , .


: 2d: sqrt (x ^ 2 + y ^ 2). . RELATIVE , SQRT.

if ((x1 ^ 2 + y1 ^ 2) > (x2 ^ 2 + y2 ^ 2)) {   //x 1, y1 , x2, y2. }

, - , , .

, . , (, , y ... ). . ( ), "" , , .

.

, , . ... crud, - .

( ). THAT ( , ), .

+1

Source: https://habr.com/ru/post/1782793/


All Articles