Added rotation capability and added a new calss Vector3f that holds 3 float values for ex rotation
This commit is contained in:
parent
c0c78e74dc
commit
dd696b2760
9 changed files with 208 additions and 17 deletions
|
|
@ -1,9 +1,28 @@
|
|||
package ei.engine.math;
|
||||
|
||||
/**
|
||||
* This class holds 2 float values
|
||||
*
|
||||
* @author Ziver
|
||||
*/
|
||||
|
||||
public class Vector2f {
|
||||
private float x;
|
||||
private float y;
|
||||
|
||||
/**
|
||||
* Creates a vector whit the value zero
|
||||
*/
|
||||
public Vector2f(){
|
||||
this(0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Vector by the given values
|
||||
*
|
||||
* @param x The x value
|
||||
* @param y The y value
|
||||
*/
|
||||
public Vector2f(float x, float y){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
|
@ -28,7 +47,7 @@ public class Vector2f {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add to the vectro
|
||||
* Add to the vector
|
||||
* @param i The amount to add
|
||||
*/
|
||||
public void add(float i){
|
||||
|
|
@ -37,7 +56,7 @@ public class Vector2f {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add to the vectro
|
||||
* Add to the vector
|
||||
* @param i The amount to add
|
||||
*/
|
||||
public void add(Vector2f i){
|
||||
|
|
|
|||
|
|
@ -1,9 +1,28 @@
|
|||
package ei.engine.math;
|
||||
|
||||
/**
|
||||
* This class holds 2 integer values
|
||||
*
|
||||
* @author Ziver
|
||||
*/
|
||||
|
||||
public class Vector2i {
|
||||
private int x;
|
||||
private int y;
|
||||
|
||||
/**
|
||||
* Creates a vector whit the value zero
|
||||
*/
|
||||
public Vector2i(){
|
||||
this(0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Vector by the given values
|
||||
*
|
||||
* @param x The x value
|
||||
* @param y The y value
|
||||
*/
|
||||
public Vector2i(int x, int y){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
|
@ -28,7 +47,7 @@ public class Vector2i {
|
|||
}
|
||||
|
||||
/**
|
||||
* Add to the vectro
|
||||
* Add to the vector
|
||||
* @param i The amount to add
|
||||
*/
|
||||
public void add(int i){
|
||||
|
|
|
|||
96
src/ei/engine/math/Vector3f.java
Normal file
96
src/ei/engine/math/Vector3f.java
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
package ei.engine.math;
|
||||
|
||||
/**
|
||||
* This class holds 3 float values
|
||||
*
|
||||
* @author Ziver
|
||||
*/
|
||||
|
||||
public class Vector3f {
|
||||
private float x;
|
||||
private float y;
|
||||
private float z;
|
||||
|
||||
/**
|
||||
* Creates a vector whit the value zero
|
||||
*/
|
||||
public Vector3f(){
|
||||
this(0,0,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Vector by the given values
|
||||
*
|
||||
* @param x The x value
|
||||
* @param y The y value
|
||||
* @param z The z value
|
||||
*/
|
||||
public Vector3f(float x, float y, float z){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the X value
|
||||
*
|
||||
* @return the x value in the vector
|
||||
*/
|
||||
public float getX(){
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y value
|
||||
*
|
||||
* @return the y value in the vector
|
||||
*/
|
||||
public float getY(){
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Z value
|
||||
*
|
||||
* @return the z value in the vector
|
||||
*/
|
||||
public float getZ(){
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to the vector
|
||||
* @param i The amount to add
|
||||
*/
|
||||
public void add(float i){
|
||||
x += i;
|
||||
y += i;
|
||||
z += i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to the vector
|
||||
* @param i The amount to add
|
||||
*/
|
||||
public void add(Vector3f i){
|
||||
x += i.getX();
|
||||
y += i.getY();
|
||||
z += i.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to the vector
|
||||
* @param x The value to add to the x value
|
||||
* @param y The value to add to the y value
|
||||
* @param z The value to add to the z value
|
||||
*/
|
||||
public void add(float x, float y, float z){
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return "Vector2f["+x+","+y+"]";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue