Skip to content

Commit c644a2c

Browse files
committed
Removed clutter. Removed dead code.
1 parent ed175a2 commit c644a2c

File tree

1 file changed

+34
-137
lines changed

1 file changed

+34
-137
lines changed

src/main/java/math/Vector3f.java

Lines changed: 34 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,38 @@
11
package math;
22

3-
/**
4-
* Representation of 3D vectors and points.
5-
*
6-
* @author Simon
7-
* @version 0.5, 30 December 2017
8-
*
9-
*/
103
public class Vector3f {
114

12-
/**
13-
* Shorthand for writing Vector3f(0, 0, -1).
14-
*/
155
public static final Vector3f BACK = new Vector3f(0, 0, -1);
166

17-
/**
18-
* Shorthand for writing Vector3f(0, -1, -0).
19-
*/
207
public static final Vector3f DOWN = new Vector3f(0, -1, 0);
218

22-
/**
23-
* Shorthand for writing Vector3f(0, 0, 1).
24-
*/
259
public static final Vector3f FORWARD = new Vector3f(0, 0, 1);
2610

27-
/**
28-
* Shorthand for writing Vector3f(-1, 0, 0).
29-
*/
3011
public static final Vector3f LEFT = new Vector3f(-1, 0, 0);
3112

32-
/**
33-
* Shorthand for writing Vector3f(Float.MAX_VALUE, Float.MAX_VALUE,
34-
* Float.MAX_VALUE).
35-
*/
3613
public static final Vector3f MAX = new Vector3f(Float.MAX_VALUE,
3714
Float.MAX_VALUE, Float.MAX_VALUE);
3815

39-
/**
40-
* Shorthand for writing Vector3f(Float.MIN_VALUE, Float.MIN_VALUE,
41-
* FLoat.MIN_VALUE).
42-
*/
4316
public static final Vector3f MIN = new Vector3f(Float.MIN_VALUE,
4417
Float.MIN_VALUE, Float.MIN_VALUE);
4518

46-
/**
47-
* Shorthand for writing Vector3f(Float.NaN, Float.NaN, FLoat.NaN).
48-
*/
4919
public static final Vector3f NAN = new Vector3f(Float.NaN, Float.NaN,
5020
Float.NaN);
5121

52-
/**
53-
* Shorthand for writing Vector3f(Float.NEGATIVE_INFINITY,
54-
* Float.NEGATIVE_INFINITY, FLoat.NEGATIVE_INFINITY).
55-
*/
5622
public static final Vector3f NEGATIVE_INFINITY = new Vector3f(
5723
Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
5824
Float.NEGATIVE_INFINITY);
5925

60-
/**
61-
* Shorthand for writing Vector3f(1, 1, 1).
62-
*/
6326
public static final Vector3f ONE = new Vector3f(1, 1, 1);
6427

65-
/**
66-
* Shorthand for writing Vector3f(Float.POSITIVE_INFINITY,
67-
* Float.POSITIVE_INFINITY, FLoat.POSITIVE_INFINITY).
68-
*/
6928
public static final Vector3f POSITIVE_INFINITY = new Vector3f(
7029
Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY,
7130
Float.POSITIVE_INFINITY);
7231

73-
/**
74-
* Shorthand for writing Vector3f(1, 0, 0).
75-
*/
7632
public static final Vector3f RIGHT = new Vector3f(1, 0, 0);
7733

78-
/**
79-
* Shorthand for writing Vector3f(0, 1, 0).
80-
*/
8134
public static final Vector3f UP = new Vector3f(0, 1, 0);
8235

83-
/**
84-
* Shorthand for writing Vector3f(0, 0, 0).
85-
*/
8636
public static final Vector3f ZERO = new Vector3f(0, 0, 0);
8737

8838
public float x;
@@ -488,29 +438,6 @@ public Vector3f lerpLocal(Vector3f beginVec, Vector3f finalVec,
488438
return this;
489439
}
490440

491-
public Vector3f one() {
492-
x = y = z = 1;
493-
return this;
494-
}
495-
496-
public Vector3f zero() {
497-
x = y = z = 0;
498-
return this;
499-
}
500-
501-
public float[] toArray() {
502-
return toArray(null);
503-
}
504-
505-
public float[] toArray(float[] floats) {
506-
if (floats == null)
507-
floats = new float[3];
508-
floats[0] = x;
509-
floats[1] = y;
510-
floats[2] = z;
511-
return floats;
512-
}
513-
514441
public static boolean isValid(Vector3f v) {
515442
if (v == null)
516443
return false;
@@ -521,70 +448,7 @@ public static boolean isValid(Vector3f v) {
521448
return false;
522449
return true;
523450
}
524-
525-
@Override
526-
public int hashCode() {
527-
final int prime = 31;
528-
int result = 1;
529-
result = prime * result + Float.floatToIntBits(x);
530-
result = prime * result + Float.floatToIntBits(y);
531-
result = prime * result + Float.floatToIntBits(z);
532-
return result;
533-
}
534-
535-
@Override
536-
public boolean equals(Object obj) {
537-
if (this == obj)
538-
return true;
539-
if (obj == null)
540-
return false;
541-
if (getClass() != obj.getClass())
542-
return false;
543-
Vector3f other = (Vector3f) obj;
544-
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
545-
return false;
546-
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
547-
return false;
548-
if (Float.floatToIntBits(z) != Float.floatToIntBits(other.z))
549-
return false;
550-
return true;
551-
}
552-
553-
@Override
554-
public String toString() {
555-
return "Vector3f [x=" + x + ", y=" + y + ", z=" + z + "]";
556-
}
557-
558-
public float get(int index) {
559-
switch (index) {
560-
case 0:
561-
return x;
562-
case 1:
563-
return y;
564-
case 2:
565-
return z;
566-
default:
567-
throw new IndexOutOfBoundsException();
568-
}
569-
}
570-
571-
public Vector3f set(int index, float value) {
572-
switch (index) {
573-
case 0:
574-
x = value;
575-
break;
576-
case 1:
577-
y = value;
578-
break;
579-
case 2:
580-
z = value;
581-
break;
582-
default:
583-
throw new IndexOutOfBoundsException();
584-
}
585-
return this;
586-
}
587-
451+
588452
public Vector3f set(float x, float y, float z) {
589453
this.x = x;
590454
this.y = y;
@@ -632,5 +496,38 @@ public Vector3f setZ(float z) {
632496
this.z = z;
633497
return this;
634498
}
499+
500+
@Override
501+
public int hashCode() {
502+
final int prime = 31;
503+
int result = 1;
504+
result = prime * result + Float.floatToIntBits(x);
505+
result = prime * result + Float.floatToIntBits(y);
506+
result = prime * result + Float.floatToIntBits(z);
507+
return result;
508+
}
509+
510+
@Override
511+
public boolean equals(Object obj) {
512+
if (this == obj)
513+
return true;
514+
if (obj == null)
515+
return false;
516+
if (getClass() != obj.getClass())
517+
return false;
518+
Vector3f other = (Vector3f) obj;
519+
if (Float.floatToIntBits(x) != Float.floatToIntBits(other.x))
520+
return false;
521+
if (Float.floatToIntBits(y) != Float.floatToIntBits(other.y))
522+
return false;
523+
if (Float.floatToIntBits(z) != Float.floatToIntBits(other.z))
524+
return false;
525+
return true;
526+
}
527+
528+
@Override
529+
public String toString() {
530+
return "Vector3f [x=" + x + ", y=" + y + ", z=" + z + "]";
531+
}
635532

636533
}

0 commit comments

Comments
 (0)