Added more math
This commit is contained in:
parent
59d2f2cae8
commit
b5bcf7e515
|
|
@ -99,6 +99,17 @@ public class Matrix4 implements IBdfClassManager
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vec3d multiply(Matrix4 mat, Vec3d vec)
|
||||||
|
{
|
||||||
|
Vec3d result = new Vec3d(0, 0, 0);
|
||||||
|
|
||||||
|
result.x = mat.get(0, 0) * vec.x + mat.get(1, 0) * vec.y + mat.get(2, 0) * vec.z + mat.get(3, 0);
|
||||||
|
result.y = mat.get(0, 1) * vec.x + mat.get(1, 1) * vec.y + mat.get(2, 1) * vec.z + mat.get(3, 1);
|
||||||
|
result.z = mat.get(0, 2) * vec.x + mat.get(1, 2) * vec.y + mat.get(2, 2) * vec.z + mat.get(3, 2);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static Matrix4 transform(Vec3d position, Vec3d rotation, Vec3d scale)
|
public static Matrix4 transform(Vec3d position, Vec3d rotation, Vec3d scale)
|
||||||
{
|
{
|
||||||
Matrix4 scaleMatrix = scale(scale);
|
Matrix4 scaleMatrix = scale(scale);
|
||||||
|
|
|
||||||
|
|
@ -103,4 +103,20 @@ public class Vec2d implements IBdfClassManager
|
||||||
public Vec2d(BdfObject bdf) {
|
public Vec2d(BdfObject bdf) {
|
||||||
BdfClassLoad(bdf);
|
BdfClassLoad(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3d xny() {
|
||||||
|
return new Vec3d(x, 0, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d xyn() {
|
||||||
|
return new Vec3d(x, y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d nxy() {
|
||||||
|
return new Vec3d(0, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2d yx() {
|
||||||
|
return new Vec2d(y, x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -116,4 +116,20 @@ public class Vec2i implements IBdfClassManager
|
||||||
public Vec2i(BdfObject bdf) {
|
public Vec2i(BdfObject bdf) {
|
||||||
BdfClassLoad(bdf);
|
BdfClassLoad(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3i xny() {
|
||||||
|
return new Vec3i(x, 0, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i xyn() {
|
||||||
|
return new Vec3i(x, y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i nxy() {
|
||||||
|
return new Vec3i(0, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2i yx() {
|
||||||
|
return new Vec2i(y, x);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,14 @@ public class Vec3d implements IBdfClassManager
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3d(Vec2d vec, double z) {
|
||||||
|
this(vec.x, vec.y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d(double x, Vec2d vec) {
|
||||||
|
this(x, vec.x, vec.y);
|
||||||
|
}
|
||||||
|
|
||||||
public double distance(Vec3d other) {
|
public double distance(Vec3d other) {
|
||||||
return MathHelpers.distance3d(x, y, z, other.x, other.y, other.z);
|
return MathHelpers.distance3d(x, y, z, other.x, other.y, other.z);
|
||||||
}
|
}
|
||||||
|
|
@ -110,4 +118,16 @@ public class Vec3d implements IBdfClassManager
|
||||||
public Vec3d(BdfObject bdf) {
|
public Vec3d(BdfObject bdf) {
|
||||||
BdfClassLoad(bdf);
|
BdfClassLoad(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec2d xy() {
|
||||||
|
return new Vec2d(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2d xz() {
|
||||||
|
return new Vec2d(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2d yz() {
|
||||||
|
return new Vec2d(y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,14 @@ public class Vec3i implements IBdfClassManager
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3i(Vec2i vec, int z) {
|
||||||
|
this(vec.x, vec.y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i(int x, Vec2i vec) {
|
||||||
|
this(x, vec.x, vec.y);
|
||||||
|
}
|
||||||
|
|
||||||
public double distance(Vec3i other) {
|
public double distance(Vec3i other) {
|
||||||
return MathHelpers.distance3d(x, y, z, other.x, other.y, other.z);
|
return MathHelpers.distance3d(x, y, z, other.x, other.y, other.z);
|
||||||
}
|
}
|
||||||
|
|
@ -129,4 +137,16 @@ public class Vec3i implements IBdfClassManager
|
||||||
public Vec3i(BdfObject bdf) {
|
public Vec3i(BdfObject bdf) {
|
||||||
BdfClassLoad(bdf);
|
BdfClassLoad(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec2i xy() {
|
||||||
|
return new Vec2i(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2i xz() {
|
||||||
|
return new Vec2i(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2i yz() {
|
||||||
|
return new Vec2i(y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,30 @@ public class Vec4d implements IBdfClassManager
|
||||||
public double z;
|
public double z;
|
||||||
public double m;
|
public double m;
|
||||||
|
|
||||||
|
public Vec4d(Vec3d vec, double m) {
|
||||||
|
this(vec.x, vec.y, vec.z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4d(double x, Vec3d vec) {
|
||||||
|
this(x, vec.x, vec.y, vec.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4d(Vec2d vec1, Vec2d vec2) {
|
||||||
|
this(vec1.x, vec1.y, vec2.x, vec2.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4d(Vec2d vec, double z, double m) {
|
||||||
|
this(vec.x, vec.y, z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4d(double x, double y, Vec2d vec) {
|
||||||
|
this(x, y, vec.x, vec.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4d(double x, Vec2d vec, double m) {
|
||||||
|
this(x, vec.x, vec.y, m);
|
||||||
|
}
|
||||||
|
|
||||||
public Vec4d(double x, double y, double z, double m)
|
public Vec4d(double x, double y, double z, double m)
|
||||||
{
|
{
|
||||||
this.x = x;
|
this.x = x;
|
||||||
|
|
@ -119,4 +143,32 @@ public class Vec4d implements IBdfClassManager
|
||||||
public Vec4d(BdfObject bdf) {
|
public Vec4d(BdfObject bdf) {
|
||||||
BdfClassLoad(bdf);
|
BdfClassLoad(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3d xyz() {
|
||||||
|
return new Vec3d(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d xym() {
|
||||||
|
return new Vec3d(x, y, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d xzm() {
|
||||||
|
return new Vec3d(x, z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3d yzm() {
|
||||||
|
return new Vec3d(y, z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2d xy() {
|
||||||
|
return new Vec2d(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2d xz() {
|
||||||
|
return new Vec2d(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2d yz() {
|
||||||
|
return new Vec2d(y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,30 @@ public class Vec4i implements IBdfClassManager
|
||||||
this.m = m;
|
this.m = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec4i(Vec3i vec, int m) {
|
||||||
|
this(vec.x, vec.y, vec.z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4i(int x, Vec3i vec) {
|
||||||
|
this(x, vec.x, vec.y, vec.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4i(Vec2i vec1, Vec2i vec2) {
|
||||||
|
this(vec1.x, vec1.y, vec2.x, vec2.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4i(Vec2i vec, int z, int m) {
|
||||||
|
this(vec.x, vec.y, z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4i(int x, int y, Vec2i vec) {
|
||||||
|
this(x, y, vec.x, vec.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec4i(int x, Vec2i vec, int m) {
|
||||||
|
this(x, vec.x, vec.y, m);
|
||||||
|
}
|
||||||
|
|
||||||
public double distance(Vec4i other) {
|
public double distance(Vec4i other) {
|
||||||
return Math.sqrt(
|
return Math.sqrt(
|
||||||
MathHelpers.squared(this.x - other.x) +
|
MathHelpers.squared(this.x - other.x) +
|
||||||
|
|
@ -144,4 +168,32 @@ public class Vec4i implements IBdfClassManager
|
||||||
public Vec4i(BdfObject bdf) {
|
public Vec4i(BdfObject bdf) {
|
||||||
BdfClassLoad(bdf);
|
BdfClassLoad(bdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Vec3i xyz() {
|
||||||
|
return new Vec3i(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i xym() {
|
||||||
|
return new Vec3i(x, y, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i xzm() {
|
||||||
|
return new Vec3i(x, z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec3i yzm() {
|
||||||
|
return new Vec3i(y, z, m);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2i xy() {
|
||||||
|
return new Vec2i(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2i xz() {
|
||||||
|
return new Vec2i(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vec2i yz() {
|
||||||
|
return new Vec2i(y, z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue