Added more code documentation (Vector3, WebSocket)

This commit is contained in:
Luca Warmenhoven
2024-05-10 12:44:58 +02:00
parent c9422db59f
commit 2d2f1a7be3
2 changed files with 151 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
# Vector3
This class represents a 3D vector with x, y, and z components.
## public Vector3(double x, double y, double z)
Constructor for creating a new vector.
## public Vector3 copy()
This method returns a new vector with the same values as the current vector.
## public static Vector3 zero()
This static method returns a new vector with all components set to zero.
## public double magnitude(): double
This method returns the magnitude of the vector.
## public Vector3 normalize()
This method returns the normalized vector. It throws an `IllegalArgumentException` if the vector is the zero vector.
## public Vector3 subtract(Vector3 other)
This method subtracts another vector from the current vector and returns the result as a new vector.
## public Vector3 add(Vector3 other)
This method adds another vector to the current vector and returns the result as a new vector.
## public Vector3 multiply(double scalar)
This method multiplies the vector by a scalar and returns the result as a new vector.
## public Vector3 divide(double scalar)
This method divides the vector by a scalar and returns the result as a new vector. It throws an `IllegalArgumentException` if the scalar is zero.
## public Vector3 negate()
This method negates the vector and returns the result as a new vector.
## public Vector3 rotate(double radX, double radY, double radZ)
This method rotates the vector around the X, Y, and Z axes by the specified angles in radians and returns the result as a new vector.
## public Vector3 rotate(Vector3 rotation)
This method rotates the vector around the X, Y, and Z axes.
## public Vector3 rotateX(double angle)
This method rotates the vector around the X axis by the specified angle in radians and returns the result as a new vector.
## public Vector3 rotateY(double angle)
This method rotates the vector around the Y axis by the specified angle in radians and returns the result as a new vector.
## public Vector3 rotateZ(double angle)
This method rotates the vector around the Z axis by the specified angle in radians and returns the result as a new vector.
## public double distanceSq(Vector3 compare)
This method returns the squared distance between the current vector and another vector.
## public double distance(Vector3 compare)
This method returns the distance between the current vector and another vector.
## public double distanceToLine(Vector3 lineStart, Vector3 lineEnd)
This method calculates the distance from the current vector to a line defined by two points and returns the result.
## public Vector3 closest(Vector3 ... vectors)
This method returns the closest vector to the current vector from a list of vectors.
## public Vector3 map(VectorMapFunction function)
This method applies a `VectorMapFunction` to the current vector and returns the result.
## public String toString()
This method returns a string representation of the vector.