Friday, June 27, 2025
spot_img

Figuring out whether or not two factors in 3D house fall alongside each other’s line of sight


I’ve a three-dimensional floor represented by a 3D grid of cells. This 3D grid of cells is in flip represented by a 3D matrix, whose entries are nonzero if a cell corresponds to a "floor cell", and zero in any other case. This 3D grid of cells is typically Cartesian (with cells all sq.), typically "spherical" (with the cells being "wedges", and the area being damaged up by some variety of divisions alongside theta, phi, and r), and typically one thing extra complicated.

For all factors not on the floor (or, if the floor is closed, each not on and not in the floor), I need to decide all factors on the floor which fall alongside their line of sight. A degree on the floor is claimed to fall alongside the road of sight of some extent not on the floor if there’s a straight line connecting them which doesn’t intersect the floor.

I need to accomplish this as effectively as attainable, for fairly giant grids, whereas accommodating these varied grid geometries.


Sorry, all, for the complicated wording (I haven’t got a major background in sport improvement). What I am attempting to do might be a lot less complicated than I’ve described it.

Put extra merely, what I am attempting to do is as follows:

  1. I’ve some 3D object(s) (say, a sphere, a dice, a canyon, a mountain, or perhaps a assortment of such objects) represented by a 3D grid of cells. For illustrative functions, let’s suppose we’re discussing a sphere, and work as an alternative in two dimensions.

enter image description here

  1. Given the coordinates of an observer (a cell not on the floor, and never inside any considered one of these objects), I need to decide what cells are seen to that observer. On this instance, solely a part of the aspect of the sphere dealing with the observer is seen to it (the cells drawn in inexperienced):

enter image description here

A floor cell is claimed to be seen by an observer if a straight line will be drawn between them with out crossing by means of any of the black cells.

  1. The geometry could possibly be extra complicated. There could possibly be a wall between the observer and the sphere. Then, the one floor cells seen to the observer could be these belonging to the wall:

enter image description here
4. Furthermore, whereas I am utilizing a uniform Cartesian grid for this illustration, the grid may, as an illustration, be spherical, or one thing much more complicated.

I am conscious of such easy algorithms as Bresenham’s line algorithm. All that I’ve come throughout have the next two drawbacks:

  1. They seem to be a bit slower than I would like them to be (I am working with reasonably giant grid sizes, and a comparable variety of observers).
  2. All of them assume a uniform Cartesian grid.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles