MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Vec2

Class Vec2

src/main/java/field/linalg/Vec2.java:49–1599  ·  view source on GitHub ↗

Represents a 2D vector with double-precision. @author RGreenlees @author Kai Burjack with modifications and additions for Field

Source from the content-addressed store, hash-verified

47 * with modifications and additions for Field
48 */
49@SafeToToString
50public class Vec2 implements OverloadedMath, Externalizable, Supplier<Vec2>, Mutable, Serializable_safe, fieldlinker.AsMap_callable {
51
52 private static final long serialVersionUID = 1L;
53
54 /**
55 * The x component of the vector.
56 */
57 public double x;
58 /**
59 * The y component of the vector.
60 */
61 public double y;
62
63 /**
64 * Create a new {@link Vec2} and initialize its components to zero.
65 */
66 public Vec2() {
67 }
68
69 public Vec2(List<Number> from) {
70 this(from.get(0).doubleValue(), from.get(1).doubleValue());
71 }
72
73 public Vec2(List<Number> from, int offset) {
74 this(from.get(offset).doubleValue(), from.get(offset + 1).doubleValue());
75 }
76
77 /**
78 * Create a new {@link Vec2} and initialize both of its components with the given value.
79 *
80 * @param d the value of both components
81 */
82 public Vec2(double d) {
83 this(d, d);
84 }
85
86 /**
87 * Create a new {@link Vec2} and initialize its components to the given values.
88 *
89 * @param x the x value
90 * @param y the y value
91 */
92 public Vec2(double x, double y) {
93 this.x = x;
94 this.y = y;
95 }
96
97 protected Vec2(Object... args) {
98 if (args.length == 0) {
99 } else if (args.length == 1) {
100 this.x = this.y = ((Number) args[0]).floatValue();
101 } else if (args.length > 1) {
102 this.x = ((Number) args[0]).floatValue();
103 this.y = ((Number) args[1]).floatValue();
104 }
105 }
106

Callers 15

toVec2Method · 0.70
PadGroup.ktFile · 0.50
__MINUS__Method · 0.50
__PLUS__Method · 0.50
__MULTIPLY__Method · 0.50
__DIVIDE__Method · 0.50
loadedMethod · 0.50
intersectsMethod · 0.50
makeMethod · 0.50
notesMethod · 0.50
notes2Method · 0.50
hitRayMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected