-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
412 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package io.github.ititus.math.quaternion; | ||
|
||
import io.github.ititus.data.ArrayUtil; | ||
import io.github.ititus.math.vector.Vec4d; | ||
|
||
public final class QuatD { | ||
|
||
private final double x; | ||
private final double y; | ||
private final double z; | ||
private final double w; | ||
|
||
public QuatD(Vec4d vec4d) { | ||
this(vec4d.x(), vec4d.y(), vec4d.z(), vec4d.w()); | ||
} | ||
|
||
public QuatD(double x, double y, double z, double w) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.w = w; | ||
} | ||
|
||
public double x() { | ||
return x; | ||
} | ||
|
||
public double y() { | ||
return y; | ||
} | ||
|
||
public double z() { | ||
return z; | ||
} | ||
|
||
public double w() { | ||
return w; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} else if (!(o instanceof QuatD)) { | ||
return false; | ||
} | ||
|
||
QuatD quatD = (QuatD) o; | ||
return Double.compare(quatD.x, x) == 0 && Double.compare(quatD.y, y) == 0 && Double.compare(quatD.z, z) == 0 && Double.compare(quatD.w, w) == 0; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ArrayUtil.hash(x, y, z, w); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(" + x + ", " + y + ", " + z + ", " + w + ')'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.github.ititus.math.vector; | ||
|
||
import io.github.ititus.data.ArrayUtil; | ||
|
||
public final class Vec2d { | ||
|
||
private final double x; | ||
private final double y; | ||
|
||
public Vec2d() { | ||
this(0, 0); | ||
} | ||
|
||
public Vec2d(double... arr) { | ||
if (arr.length != 2) { | ||
throw new IllegalArgumentException("illegal array size"); | ||
} | ||
|
||
this.x = arr[0]; | ||
this.y = arr[1]; | ||
} | ||
|
||
public Vec2d(double x, double y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public double x() { | ||
return x; | ||
} | ||
|
||
public double y() { | ||
return y; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} else if (!(o instanceof Vec2d)) { | ||
return false; | ||
} | ||
|
||
Vec2d vec2d = (Vec2d) o; | ||
return Double.compare(vec2d.x, x) == 0 && Double.compare(vec2d.y, y) == 0; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ArrayUtil.hash(x, y); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(" + x + ", " + y + ')'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package io.github.ititus.math.vector; | ||
|
||
import io.github.ititus.data.ArrayUtil; | ||
|
||
public final class Vec2f { | ||
|
||
private final float x; | ||
private final float y; | ||
|
||
public Vec2f() { | ||
this(0, 0); | ||
} | ||
|
||
public Vec2f(float... arr) { | ||
if (arr.length != 2) { | ||
throw new IllegalArgumentException("illegal array size"); | ||
} | ||
|
||
this.x = arr[0]; | ||
this.y = arr[1]; | ||
} | ||
|
||
public Vec2f(float x, float y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public float x() { | ||
return x; | ||
} | ||
|
||
public float y() { | ||
return y; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} else if (!(o instanceof Vec2f)) { | ||
return false; | ||
} | ||
|
||
Vec2f vec2f = (Vec2f) o; | ||
return Float.compare(vec2f.x, x) == 0 && Float.compare(vec2f.y, y) == 0; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ArrayUtil.hash(x, y); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(" + x + ", " + y + ')'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package io.github.ititus.math.vector; | ||
|
||
import io.github.ititus.data.ArrayUtil; | ||
|
||
public final class Vec3d { | ||
|
||
private final double x; | ||
private final double y; | ||
private final double z; | ||
|
||
public Vec3d() { | ||
this(0, 0, 0); | ||
} | ||
|
||
public Vec3d(double... arr) { | ||
if (arr.length != 3) { | ||
throw new IllegalArgumentException("illegal array size"); | ||
} | ||
|
||
this.x = arr[0]; | ||
this.y = arr[1]; | ||
this.z = arr[2]; | ||
} | ||
|
||
public Vec3d(double x, double y, double z) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
} | ||
|
||
public double x() { | ||
return x; | ||
} | ||
|
||
public double y() { | ||
return y; | ||
} | ||
|
||
public double z() { | ||
return z; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} else if (!(o instanceof Vec3d)) { | ||
return false; | ||
} | ||
|
||
Vec3d vec3d = (Vec3d) o; | ||
return Double.compare(vec3d.x, x) == 0 && Double.compare(vec3d.y, y) == 0 && Double.compare(vec3d.z, z) == 0; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return ArrayUtil.hash(x, y, z); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "(" + x + ", " + y + ", " + z + ')'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.