I have a set of points that can be understood as loudspeaker positions. I want to write an algorithm that selects always three speakers given a virtual position in the two-dimensional space, and assign them amplitudes so that when the virtual position coincides with a speaker position, only that speaker has an amplitude > 0, and otherwise the tree speakers surrounding the point have a weight-balanced amplitude. The three speakers are selected using a Delaunay triangulation.
Now this all works fine when I stay within one triangle, but when I cross the boundary to the next triangle, the two speakers defining the boundary abruptly change their amplitude. I tried this first by projecting the point to the altitudes of the triangle:
Here the virtual point is a magenta circle, the speakers are black little squares, and the amplitude are visualised by blue circle. When the magenta circle slightly moves to the next triangle, the amplitudes (blue circle) change size:
Trying the same with median projection doesn't help. One triangle:
Moving to the next triangle (amplitudes jump again):
The amplitude is always based on the relative position of the point projected onto the diagonal that leaves a corner.
Any ideas how to fix this? I'm thinking I need to make sure that at the boundary, the weight of the speakers must only depend on the two speakers forming the boundary. Perhaps with an additional clever multiplication?
Actually, my first approach with the altitude projections was correct. I had a bug in the scaling of the amplitudes:
An alternative, but slightly more complicated variant, is to draw a line from each corner through the virtual point and calculate the relative position to the intersection with the opposite side:
Animated: