The reference for Serial.write implies that you can have one or more parameters of type byte[], String or int. As far as I can see it accepts only one parameter (of any of those types). The method ...
myPort.bufferUntil('.'); // reads the data from the serial port up to the character '.'. So actually it reads this: angle,distance. angle= data.substring(0, index1); // read the data from position "0" ...