MCPcopy
hub / github.com/libgdx/libgdx / Vector3

Class Vector3

gdx/src/com/badlogic/gdx/math/Vector3.java:26–727  ·  view source on GitHub ↗

Encapsulates a 3D vector. Allows chaining operations by returning a reference to itself in all modification methods. @author badlogicgames@gmail.com

Source from the content-addressed store, hash-verified

24/** Encapsulates a 3D vector. Allows chaining operations by returning a reference to itself in all modification methods.
25 * @author badlogicgames@gmail.com */
26public class Vector3 implements Serializable, Vector<Vector3> {
27 private static final long serialVersionUID = 3840054589595372522L;
28
29 /** the x-component of this vector **/
30 public float x;
31 /** the y-component of this vector **/
32 public float y;
33 /** the z-component of this vector **/
34 public float z;
35
36 public final static Vector3 X = new Vector3(1, 0, 0);
37 public final static Vector3 Y = new Vector3(0, 1, 0);
38 public final static Vector3 Z = new Vector3(0, 0, 1);
39 public final static Vector3 Zero = new Vector3(0, 0, 0);
40 public final static Vector3 One = new Vector3(1, 1, 1);
41
42 private final static Matrix4 tmpMat = new Matrix4();
43
44 /** Constructs a vector at (0,0,0) */
45 public Vector3 () {
46 }
47
48 /** Creates a vector with the given components
49 * @param x The x-component
50 * @param y The y-component
51 * @param z The z-component */
52 public Vector3 (float x, float y, float z) {
53 this.set(x, y, z);
54 }
55
56 /** Creates a vector from the given vector
57 * @param vector The vector */
58 public Vector3 (final Vector3 vector) {
59 this.set(vector);
60 }
61
62 /** Creates a vector from the given array. The array must have at least 3 elements.
63 *
64 * @param values The array */
65 public Vector3 (final float[] values) {
66 this.set(values[0], values[1], values[2]);
67 }
68
69 /** Creates a vector from the given vector and z-component
70 *
71 * @param vector The vector
72 * @param z The z-component */
73 public Vector3 (final Vector2 vector, float z) {
74 this.set(vector.x, vector.y, z);
75 }
76
77 /** Sets the vector to the given components
78 *
79 * @param x The x-component
80 * @param y The y-component
81 * @param z The z-component
82 * @return this vector for chaining */
83 public Vector3 set (float x, float y, float z) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected