Solved How to get yaw, pitch and roll from a vector?

Discussion in 'Spigot Plugin Development' started by fortressworks, Apr 17, 2019.

  1. SteelPhoenix


    You don't. A vector is a direction, not a position.
    • Agree Agree x 2
  2. And I think we only have pitch and yaw in Minecraft.
    #3 NascentNova, Apr 17, 2019
    Last edited: Apr 17, 2019
  3. I think maybe armor stands have some kind of roll property on some of the movable limbs, though I'm not entirely sure.

    Though, as others have said, a vector is an object which indicates movement. It's not a location. The X, Y and Z value indicate where the momentum is going. The values of the vector have no relation to an actual location. They're relative values. The higher the values, the greater the force of the vector (higher momentum).
    #4 MrDienns, Apr 17, 2019
    Last edited: Apr 17, 2019
    • Informative Informative x 1
    • Agree Agree x 1
  4. Pitch and yaw are actually direction :)

    The roll does not really exist for a direction, you don't need it.
    You can simply use
    Location l = anyLocation;

    If you do not want to use Location, you can still follow this cult tutorial:

    Finally if you want the head of an armorstand looking at a direction you can use this:

    Code (Text):
        double yaw = Math.atan2(direction.getZ(), direction.getX());
                double pitch = Math.atan2(Math.sqrt(direction.getZ() * direction.getZ() + direction.getX() * direction.getX()), direction.getY()) + Math.PI;
                projector.setHeadPose(new EulerAngle(-pitch + Math.toRadians(90), yaw + Math.toRadians(90), 0));