Class BVector3

java.lang.Object
cn.nukkit.math.BVector3

@PowerNukkitXOnly @Since("1.6.0.0-PNX") @PowerNukkitXDifference(info="update Angle algorithm", since="1.19.60-r1") public final class BVector3 extends Object
向量计算工具,同时整合了yaw和pitch与坐标空间的转换功能
  • Method Details

    • fromLocation

      public static BVector3 fromLocation(Location location)
      通过传入的Location的yaw与pitch初始化BVector3

      此方法返回的BVector3的模长为1

      Parameters:
      location - the location
      Returns:
      the b vector 3
    • fromLocation

      public static BVector3 fromLocation(Location location, double length)
      通过传入的Location的yaw与pitch初始化BVector3

      此方法返回的BVector3的模长为传入的length值

      Parameters:
      location - the location
      Returns:
      the b vector 3
    • fromAngle

      public static BVector3 fromAngle(double yaw, double pitch)
      通过传入的yaw与pitch初始化BVector3

      此方法返回的BVector3的模长为1

      Parameters:
      yaw - the yaw (-90 270)
      pitch - the pitch
      Returns:
      the b vector 3
    • fromPos

      public static BVector3 fromPos(Vector3 pos)
      通过传入的向量坐标初始化BVector3
      Parameters:
      pos - 向量坐标
      Returns:
      the b vector 3
    • fromPos

      public static BVector3 fromPos(double x, double y, double z)
      通过传入的向量坐标初始化BVector3
      Parameters:
      x - the x
      y - the y
      z - the z
      Returns:
      the b vector 3
    • setYaw

      public BVector3 setYaw(double yaw)
      设置Yaw
      Parameters:
      yaw - the yaw
      Returns:
      the yaw
    • setPitch

      public BVector3 setPitch(double pitch)
      设置 pitch.
      Parameters:
      pitch - the pitch
      Returns:
      the pitch
    • rotateYaw

      public BVector3 rotateYaw(double yaw)
      旋转Yaw
      Parameters:
      yaw - the yaw
      Returns:
      the b vector 3
    • rotatePitch

      public BVector3 rotatePitch(double pitch)
      旋转Pitch
      Parameters:
      pitch - the pitch
      Returns:
      the b vector 3
    • rotate

      public BVector3 rotate(double yaw, double pitch)
      旋转yaw和Pitch
      Parameters:
      yaw - the yaw
      pitch - the pitch
      Returns:
      the b vector 3
    • add

      public BVector3 add(double x, double y, double z)
      向量加法
      Returns:
      结果向量
    • add

      public BVector3 add(Vector3 vector3)
      向量加法
      Returns:
      结果向量
    • addToPos

      public Vector3 addToPos()
      添加指定模长的方向向量到Vector3(0, 0, 0)

      其实就是返回此向量的坐标

      Returns:
      the vector 3
    • addToPos

      public Vector3 addToPos(Vector3 pos)
      将此向量的坐标添加到pos上
      Parameters:
      pos - the pos
      Returns:
      the vector 3
    • setLength

      public BVector3 setLength(double length)
      设置该向量的模
      Parameters:
      length - the length
      Returns:
      the length
    • extend

      public BVector3 extend(double length)
      增加该向量的模

      当然你也可以传入负数,但请确保最终长度要大于0!

      Parameters:
      length - 增加/减少的模
      Returns:
      自身
    • getYaw

      public double getYaw()
    • getPitch

      public double getPitch()
    • getDirectionVector

      public Vector3 getDirectionVector()
      获取单位方向向量
      Returns:
      the direction vector
    • getUnclonedDirectionVector

      @DoNotModify public Vector3 getUnclonedDirectionVector()
      获取未克隆的单位方向向量
      Returns:
      the direction vector
    • getDirectionVector

      public static Vector3 getDirectionVector(double yaw, double pitch)
      通过yaw与pitch计算出等价的Vector3方向向量
      Parameters:
      yaw - yaw
      pitch - pitch
      Returns:
      Vector3方向向量
    • getYawFromVector

      public static double getYawFromVector(Vector3 vector)
      通过方向向量计算出yaw
      Parameters:
      vector - 方向向量
      Returns:
      yaw
    • getPitchFromVector

      public static double getPitchFromVector(Vector3 vector)
      通过方向向量计算出pitch
      Parameters:
      vector - 方向向量
      Returns:
      pitch