-
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
3 changed files
with
127 additions
and
0 deletions.
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
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.Vec4f; | ||
|
||
public final class QuatF { | ||
|
||
private final float x; | ||
private final float y; | ||
private final float z; | ||
private final float w; | ||
|
||
public QuatF(Vec4f vec4f) { | ||
this(vec4f.x(), vec4f.y(), vec4f.z(), vec4f.w()); | ||
} | ||
|
||
public QuatF(float x, float y, float z, float w) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.w = w; | ||
} | ||
|
||
public float x() { | ||
return x; | ||
} | ||
|
||
public float y() { | ||
return y; | ||
} | ||
|
||
public float z() { | ||
return z; | ||
} | ||
|
||
public float w() { | ||
return w; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} else if (!(o instanceof QuatF)) { | ||
return false; | ||
} | ||
|
||
QuatF quatF = (QuatF) o; | ||
return Float.compare(quatF.x, x) == 0 && Float.compare(quatF.y, y) == 0 && Float.compare(quatF.z, z) == 0 && Float.compare(quatF.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,65 @@ | ||
package io.github.ititus.math.vector; | ||
|
||
import io.github.ititus.data.ArrayUtil; | ||
import io.github.ititus.math.quaternion.QuatF; | ||
|
||
public final class Vec4f { | ||
|
||
private final float x; | ||
private final float y; | ||
private final float z; | ||
private final float w; | ||
|
||
public Vec4f() { | ||
this(0, 0, 0, 0); | ||
} | ||
|
||
public Vec4f(QuatF quatF) { | ||
this(quatF.x(), quatF.y(), quatF.z(), quatF.w()); | ||
} | ||
|
||
public Vec4f(float x, float y, float z, float w) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.w = w; | ||
} | ||
|
||
public float x() { | ||
return x; | ||
} | ||
|
||
public float y() { | ||
return y; | ||
} | ||
|
||
public float z() { | ||
return z; | ||
} | ||
|
||
public float w() { | ||
return w; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} else if (!(o instanceof Vec4f)) { | ||
return false; | ||
} | ||
|
||
Vec4f vec4f = (Vec4f) o; | ||
return Float.compare(vec4f.x, x) == 0 && Float.compare(vec4f.y, y) == 0 && Float.compare(vec4f.z, z) == 0 && Float.compare(vec4f.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