Contains the definition of a Vector comprising 4 doubles and associated transformations. @author Richard Greenlees @author Kai Burjack with modifications and additions for Field
| 46 | * @author Kai Burjack |
| 47 | * with modifications and additions for Field |
| 48 | */ |
| 49 | @SafeToToString |
| 50 | public class Vec4 implements Externalizable, Supplier<Vec4>, Mutable, Serializable_safe, OverloadedMath { |
| 51 | |
| 52 | |
| 53 | private static final long serialVersionUID = 1L; |
| 54 | |
| 55 | /** |
| 56 | * The x component of the vector. |
| 57 | */ |
| 58 | @SafeToToString |
| 59 | public double x; |
| 60 | /** |
| 61 | * The y component of the vector. |
| 62 | */ |
| 63 | @SafeToToString |
| 64 | public double y; |
| 65 | /** |
| 66 | * The z component of the vector. |
| 67 | */ |
| 68 | @SafeToToString |
| 69 | public double z; |
| 70 | /** |
| 71 | * The w component of the vector. |
| 72 | */ |
| 73 | @SafeToToString |
| 74 | public double w = 1.0; |
| 75 | |
| 76 | /** |
| 77 | * Create a new {@link Vec4} of <code>(0, 0, 0, 1)</code>. |
| 78 | */ |
| 79 | public Vec4() { |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Create a new {@link Vec4} with the same values as <code>v</code>. |
| 84 | * |
| 85 | * @param v the {@link Vec4} to copy the values from |
| 86 | */ |
| 87 | public Vec4(Vec4 v) { |
| 88 | this.x = v.x; |
| 89 | this.y = v.y; |
| 90 | this.z = v.z; |
| 91 | this.w = v.w; |
| 92 | } |
| 93 | |
| 94 | protected Vec4(Object... args) { |
| 95 | if (args.length == 0) { |
| 96 | this.w = 1; |
| 97 | } else if (args.length == 1) { |
| 98 | this.x = this.y = this.z = ((Number) args[0]).floatValue(); |
| 99 | this.w = 1; |
| 100 | } else if (args.length == 2) { |
| 101 | this.x = this.y = this.z = ((Number) args[0]).floatValue(); |
| 102 | this.w = ((Number) args[1]).floatValue(); |
| 103 | } else if (args.length == 3) { |
| 104 | this.x = ((Number) args[0]).floatValue(); |
| 105 | this.y = ((Number) args[1]).floatValue(); |
no outgoing calls
no test coverage detected