final double PITCH_FACTOR = 180;
final double PITCH_OFFSET = -90;
final double CARTESIAN_FACTOR = 256;
final double CARTESIAN_OFFSET = -128;
Vector vector;
Location location;
if (random.nextBoolean()) {
float pitch = (float) (random.nextDouble() * PITCH_FACTOR + PITCH_OFFSET);
float yaw = (float) (random.nextDouble() * YAW_FACTOR + YAW_OFFSET);
location = getEmptyLocation();
location.setPitch(pitch);
location.setYaw(yaw);
vector = location.getDirection();
} else {
double x = random.nextDouble() * CARTESIAN_FACTOR + CARTESIAN_OFFSET;
double y = random.nextDouble() * CARTESIAN_FACTOR + CARTESIAN_OFFSET;
double z = random.nextDouble() * CARTESIAN_FACTOR + CARTESIAN_OFFSET;
location = getEmptyLocation();
vector = new Vector(x, y, z).normalize();
location.setDirection(vector);
}
return new Object[] { "R" + index,
vector.getX(), vector.getY(), vector.getZ(),
location.getYaw(), location.getPitch()
};
}