Package cn.nukkit.math
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 Summary
Modifier and TypeMethodDescriptionadd
(double x, double y, double z) 向量加法向量加法addToPos()
添加指定模长的方向向量到Vector3(0, 0, 0)将此向量的坐标添加到pos上extend
(double length) 增加该向量的模static BVector3
fromAngle
(double yaw, double pitch) 通过传入的yaw与pitch初始化BVector3static BVector3
fromLocation
(Location location) 通过传入的Location的yaw与pitch初始化BVector3static BVector3
fromLocation
(Location location, double length) 通过传入的Location的yaw与pitch初始化BVector3static BVector3
fromPos
(double x, double y, double z) 通过传入的向量坐标初始化BVector3static BVector3
通过传入的向量坐标初始化BVector3获取单位方向向量static Vector3
getDirectionVector
(double yaw, double pitch) 通过yaw与pitch计算出等价的Vector3方向向量double
getPitch()
static double
getPitchFromVector
(Vector3 vector) 通过方向向量计算出pitch获取未克隆的单位方向向量double
getYaw()
static double
getYawFromVector
(Vector3 vector) 通过方向向量计算出yawrotate
(double yaw, double pitch) 旋转yaw和PitchrotatePitch
(double pitch) 旋转PitchrotateYaw
(double yaw) 旋转YawsetLength
(double length) 设置该向量的模setPitch
(double pitch) 设置 pitch.setYaw
(double yaw) 设置Yaw
-
Method Details
-
fromLocation
通过传入的Location的yaw与pitch初始化BVector3 此方法返回的BVector3的模长为1- Parameters:
location
- the location- Returns:
- the b vector 3
-
fromLocation
通过传入的Location的yaw与pitch初始化BVector3 此方法返回的BVector3的模长为传入的length值- Parameters:
location
- the location- Returns:
- the b vector 3
-
fromAngle
通过传入的yaw与pitch初始化BVector3 此方法返回的BVector3的模长为1- Parameters:
yaw
- the yaw (-90 270)pitch
- the pitch- Returns:
- the b vector 3
-
fromPos
通过传入的向量坐标初始化BVector3- Parameters:
pos
- 向量坐标- Returns:
- the b vector 3
-
fromPos
通过传入的向量坐标初始化BVector3- Parameters:
x
- the xy
- the yz
- the z- Returns:
- the b vector 3
-
setYaw
设置Yaw- Parameters:
yaw
- the yaw- Returns:
- the yaw
-
setPitch
设置 pitch.- Parameters:
pitch
- the pitch- Returns:
- the pitch
-
rotateYaw
旋转Yaw- Parameters:
yaw
- the yaw- Returns:
- the b vector 3
-
rotatePitch
旋转Pitch- Parameters:
pitch
- the pitch- Returns:
- the b vector 3
-
rotate
旋转yaw和Pitch- Parameters:
yaw
- the yawpitch
- the pitch- Returns:
- the b vector 3
-
add
向量加法- Returns:
- 结果向量
-
add
向量加法- Returns:
- 结果向量
-
addToPos
添加指定模长的方向向量到Vector3(0, 0, 0) 其实就是返回此向量的坐标- Returns:
- the vector 3
-
addToPos
将此向量的坐标添加到pos上- Parameters:
pos
- the pos- Returns:
- the vector 3
-
setLength
设置该向量的模- Parameters:
length
- the length- Returns:
- the length
-
extend
增加该向量的模 当然你也可以传入负数,但请确保最终长度要大于0!- Parameters:
length
- 增加/减少的模- Returns:
- 自身
-
getYaw
public double getYaw() -
getPitch
public double getPitch() -
getDirectionVector
获取单位方向向量- Returns:
- the direction vector
-
getUnclonedDirectionVector
获取未克隆的单位方向向量- Returns:
- the direction vector
-
getDirectionVector
通过yaw与pitch计算出等价的Vector3方向向量- Parameters:
yaw
- yawpitch
- pitch- Returns:
- Vector3方向向量
-
getYawFromVector
通过方向向量计算出yaw- Parameters:
vector
- 方向向量- Returns:
- yaw
-
getPitchFromVector
通过方向向量计算出pitch- Parameters:
vector
- 方向向量- Returns:
- pitch
-