Package net.risingworld.api.utils
Class Utils.VectorUtils
java.lang.Object
net.risingworld.api.utils.Utils.VectorUtils
- Enclosing class:
Utils
Vector functions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector3f
getAlignedDirection
(Vector3f direction, Vector3f normal) Gets a direction vector aligned to a normal.static Vector3f
getAlignedDirection
(Vector3f direction, Vector3f normal, Vector3f storeTo) static Vector3f
getDirection
(Vector3f from, Vector3f to) Gets the direction between two points (from -> to) as a normalized vector (unit vector, i.e length == 1).static Vector3f
getDirection
(Vector3f from, Vector3f to, Vector3f storeTo) Gets the direction between two points (from -> to) as a normalized vector (unit vector, i.e length == 1).static Vector3f
getXYZInFrontOfPlayer
(Player player, float distance) Gets the position in front of the player (with the given distance to the player).static Vector3f
getXYZInFrontOfPlayer
(Player player, float distance, Vector3f storeTo) Gets the position in front of the player (with the given distance to the player).static Vector3f
getXZInFrontOfPlayer
(Player player, float distance) static Vector3f
getXZInFrontOfPlayer
(Player player, float distance, Vector3f storeTo)
-
Constructor Details
-
VectorUtils
public VectorUtils()
-
-
Method Details
-
getXZInFrontOfPlayer
-
getXZInFrontOfPlayer
-
getXYZInFrontOfPlayer
Gets the position in front of the player (with the given distance to the player). This function takes the full player view direction into account, i.e. if the player looks up in the sky, the resulting position is above the player.- Parameters:
player
- the player.distance
- the desired distance between the player and the resulting position.- Returns:
- a new vector representing the position in front of the player.
- See Also:
-
getXYZInFrontOfPlayer
Gets the position in front of the player (with the given distance to the player). This function takes the full player view direction into account, i.e. if the player looks up in the sky, the resulting position is above the player.- Parameters:
player
- the player.distance
- the desired distance between the player and the resulting position.storeTo
- the vector you want to store the result in. If null is provided, a new vector will be created.- Returns:
- the position in front of the player.
- See Also:
-
getDirection
Gets the direction between two points (from -> to) as a normalized vector (unit vector, i.e length == 1).- Parameters:
from
- the start position.to
- the end position.- Returns:
- a new unit vector representing the direction between position "from" and position "to"
-
getDirection
Gets the direction between two points (from -> to) as a normalized vector (unit vector, i.e length == 1).- Parameters:
from
- the start position.to
- the end position.storeTo
- the vector you want to store the resulting direction in. If null is provided, a new vector will be created.- Returns:
- a unit vector representing the direction between position "from" and position "to"
-
getAlignedDirection
Gets a direction vector aligned to a normal.- Parameters:
direction
- the original direction (as unit vector).normal
- the normal (as unit vector) you want to align the direction to.- Returns:
- a unit vector representing the new direction, based on the original direction and the provided normal.
- Example: Get rotation based on a direction and ground normal
-
getAlignedDirection
-