Add 4D vectors
This commit is contained in:
parent
dd4ebcd88a
commit
f81d27060a
3 changed files with 435 additions and 0 deletions
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Authors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.base.type.vector;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a 4D double Vector.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class Vec4d {
|
||||
/**
|
||||
* The X axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the X axis value.
|
||||
*
|
||||
* @return X axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the X axis value.
|
||||
*
|
||||
* @param x X axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private double x;
|
||||
|
||||
/**
|
||||
* The Y axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the Y axis value.
|
||||
*
|
||||
* @return Y axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the Y axis value.
|
||||
*
|
||||
* @param y Y axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private double y;
|
||||
|
||||
/**
|
||||
* The Z axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the Z axis value.
|
||||
*
|
||||
* @return Z axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the Z axis value.
|
||||
*
|
||||
* @param z Z axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private double z;
|
||||
|
||||
/**
|
||||
* The W axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the W axis value.
|
||||
*
|
||||
* @return W axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the W axis value.
|
||||
*
|
||||
* @param w W axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private double w;
|
||||
|
||||
/**
|
||||
* Constructs this 3D vector.
|
||||
*
|
||||
* @param x X axis value
|
||||
* @param y Y axis value
|
||||
* @param z Z axis value
|
||||
* @param w W axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
public Vec4d(double x, double y, double z, double w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an identical copy of this vector.
|
||||
*
|
||||
* @return identical copy
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@SneakyThrows
|
||||
public @NotNull Vec4d clone() {
|
||||
return (Vec4d) super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this vector.
|
||||
*
|
||||
* @return string representation
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
||||
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
||||
: getClass().getName())
|
||||
+ "(x=" + x + " y=" + y + " z=" + z + " w=" + w + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Authors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.base.type.vector;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a 4D float Vector.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class Vec4f {
|
||||
/**
|
||||
* The X axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the X axis value.
|
||||
*
|
||||
* @return X axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the X axis value.
|
||||
*
|
||||
* @param x X axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private float x;
|
||||
|
||||
/**
|
||||
* The Y axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the Y axis value.
|
||||
*
|
||||
* @return Y axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the Y axis value.
|
||||
*
|
||||
* @param y Y axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private float y;
|
||||
|
||||
/**
|
||||
* The Z axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the Z axis value.
|
||||
*
|
||||
* @return Z axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the Z axis value.
|
||||
*
|
||||
* @param z Z axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private float z;
|
||||
|
||||
/**
|
||||
* The W axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the W axis value.
|
||||
*
|
||||
* @return W axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the W axis value.
|
||||
*
|
||||
* @param w W axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private float w;
|
||||
|
||||
/**
|
||||
* Constructs this 3D vector.
|
||||
*
|
||||
* @param x X axis value
|
||||
* @param y Y axis value
|
||||
* @param z Z axis value
|
||||
* @param w W axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
public Vec4f(float x, float y, float z, float w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an identical copy of this vector.
|
||||
*
|
||||
* @return identical copy
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@SneakyThrows
|
||||
public @NotNull Vec4f clone() {
|
||||
return (Vec4f) super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this vector.
|
||||
*
|
||||
* @return string representation
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
||||
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
||||
: getClass().getName())
|
||||
+ "(x=" + x + " y=" + y + " z=" + z + " w=" + w + ")";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* STAROPENSOURCE ENGINE SOURCE FILE
|
||||
* Copyright (c) 2024 The StarOpenSource Engine Authors
|
||||
* Licensed under the GNU Affero General Public License v3
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.staropensource.engine.base.type.vector;
|
||||
|
||||
import de.staropensource.engine.base.EngineConfiguration;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Represents a 4D integer Vector.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@SuppressWarnings({ "JavadocDeclaration" })
|
||||
public final class Vec4i {
|
||||
/**
|
||||
* The X axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the X axis value.
|
||||
*
|
||||
* @return X axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the X axis value.
|
||||
*
|
||||
* @param x X axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private int x;
|
||||
|
||||
/**
|
||||
* The Y axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the Y axis value.
|
||||
*
|
||||
* @return Y axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the Y axis value.
|
||||
*
|
||||
* @param y Y axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private int y;
|
||||
|
||||
/**
|
||||
* The Z axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the Z axis value.
|
||||
*
|
||||
* @return Z axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the Z axis value.
|
||||
*
|
||||
* @param z Z axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private int z;
|
||||
|
||||
/**
|
||||
* The W axis value.
|
||||
*
|
||||
* @since v1-alpha6
|
||||
* -- GETTER --
|
||||
* Returns the W axis value.
|
||||
*
|
||||
* @return W axis value
|
||||
* @since v1-alpha6
|
||||
* -- SETTER --
|
||||
* Sets the W axis value.
|
||||
*
|
||||
* @param w W axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
private int w;
|
||||
|
||||
/**
|
||||
* Constructs this 3D integer vector.
|
||||
*
|
||||
* @param x X axis value
|
||||
* @param y Y axis value
|
||||
* @param z Z axis value
|
||||
* @param w W axis value
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
public Vec4i(int x, int y, int z, int w) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an identical copy of this vector.
|
||||
*
|
||||
* @return identical copy
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@SneakyThrows
|
||||
public @NotNull Vec4i clone() {
|
||||
return (Vec4i) super.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this vector.
|
||||
*
|
||||
* @return string representation
|
||||
* @since v1-alpha6
|
||||
*/
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return (EngineConfiguration.getInstance().isHideFullTypePath()
|
||||
? getClass().getName().replace(getClass().getPackage() + ".", "")
|
||||
: getClass().getName())
|
||||
+ "(x=" + x + " y=" + y + " z=" + z + " w=" + w + ")";
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue