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与坐标空间的转换功能

A vector calculation tool that integrates the conversion functions of yaw and pitch and coordinate space at the same time

  • Method Details

    • fromLocation

      public static BVector3 fromLocation(Location location)
      通过传入的Location的yaw与pitch初始化BVector3
      此方法返回的BVector3的模长为1

      Initialize BVector3 by passing in the yaw and pitch of Location
      The module length of BVector3 returned by this method is 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值

      Initialize BVector3 by passing in the yaw and pitch of the Location
      The module length of the BVector3 returned by this method is the length value passed in

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

      public static BVector3 fromAngle(double yaw, double pitch)
      通过传入的yaw与pitch初始化BVector3
      此方法返回的BVector3的模长为1

      Initialize BVector3 by passing in yaw and pitch
      The module length of BVector3 returned by this method is 1

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

      public static BVector3 fromPos(Vector3 pos)
      通过传入的向量坐标初始化BVector3

      Initialize B Vector 3 with the vector coordinates passed in

      Parameters:
      pos - 向量坐标
      Returns:
      the b vector 3
    • fromPos

      public static BVector3 fromPos(double x, double y, double z)
      通过传入的向量坐标初始化BVector3

      Initialize B Vector 3 with the vector coordinates passed in

      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

      Rotate Yaw

      Parameters:
      yaw - the yaw
      Returns:
      the b vector 3
    • rotatePitch

      public BVector3 rotatePitch(double pitch)
      旋转Pitch

      Rotate Pitch

      Parameters:
      pitch - the pitch
      Returns:
      the b vector 3
    • rotate

      public BVector3 rotate(double yaw, double pitch)
      旋转yaw和Pitch

      Rotate yaw and 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)
      其实就是返回此向量的坐标

      Adding the direction vector of the specified modulus length to Vector3(0, 0, 0)
      actually returns the coordinates of this vector

      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

      Calculate yaw from the direction vector

      Parameters:
      vector - 方向向量
      Returns:
      yaw
    • getPitchFromVector

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

      Calculate the pitch by the direction vector

      Parameters:
      vector - 方向向量
      Returns:
      pitch