I already stated:
I won’t write it for you; not my style.
I have been providing you hints and tips along the way.
I wrote test code to generate 10x10 grid data; it could just have easily been Lidar data.
I started with your Arduino code but don’t have the hardware so improvised.
Arduino Grid
void setup()
{
Serial.begin(115200);
delay(500);
}
float offset;
float angle;
void loop()
{
offset += 1;
Serial.println("Start");
for(int x = 0; x < 11; x++)
{
for(int y = 0; y < 11; y++)
{
float xval = 64+64*sin((x+offset)*PI/10);
float yval = 64+64*sin((y+offset)*PI/10);
float val = xval + yval; // This will be used as color
Serial.print(int(val));
if (y < 10) Serial.print(',');
}
Serial.print('\n');
}
Serial.println("End");
delay(10);
}
I was able to write some Processing code to generate this:

I followed my own suggestions and generated a 2D array from the 1D array that was received:
I did provide a reference to split() the data into integers… one of the tips I provided and necessary later.
I made a 2D array from the 1D array of Strings converted to integers with split() and int().
See the reference for examples.
This is your journey… take it one step at a time.
There are resources here:
:)