public double round(double number, int digits)
return Math.Round(number * Math.Pow(10, digits)) / Math.Pow(10, digits);
Random rng = new Random();
double angle1 = rng.Next(0, 360);
double angle2 = rng.Next(0, 360);
double xpos = round(distance * Math.Cos((angle1 * Math.PI) / 180) * Math.Cos((angle2 * Math.PI) / 180), digits);
double ypos = round(distance * Math.Sin((angle1 * Math.PI) / 180) * Math.Cos((angle2 * Math.PI) / 180), digits);
double zpos = round(distance * Math.Sin((angle2 * Math.PI) / 180), digits);
Console.WriteLine("POSITION");
Console.WriteLine("x = " + xpos);
Console.WriteLine("y = " + ypos);
Console.WriteLine("z = " + zpos);
Console.WriteLine("\nROTATION");
Console.WriteLine("x = 0");
Console.WriteLine("y = " + (0 - angle2));
Console.WriteLine("z = " + angle1);