Get random point in circle moving with Yaw

Discussion in 'Spigot Plugin Development' started by KuramaStone, Mar 28, 2017.

  1. I am trying to get a random point around the player that follows their yaw. I can create a random point, but I cannot discover a method in which the point will rotate with the player. I am not well versed in using Yaw, Pitch, and other vectors, so I believe it is safe to assume that it is my knowledge that is limiting me here.

    What could I do to have the point change, so that they are in line with the player's yaw and pitch?

    Here is what I am using to get a random point:
    Code (Text):
        private Location getLocation() {
            double angle = Math.toRadians(random.nextDouble() * 360);
            double amount = 30;
            double yaw = (player.getEyeLocation().getX() + (amount * Math.cos(angle)));
            double pitch = (player.getEyeLocation().getZ() + (amount * Math.sin(angle)));
            double x = Math.sin(pitch) * Math.cos(yaw);
    //        double z = Math.sin(pitch) * Math.sin(yaw);
            double y = Math.cos(pitch);
            Vector vector = new Vector(x, y, 0);
            return player.getEyeLocation().add(vector.multiply(2));