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
4 changed files
with
88 additions
and
7 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
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
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,66 @@ | ||
package com.osesm.randy.framework.math; | ||
|
||
import java.nio.FloatBuffer; | ||
|
||
public class Vector4 { | ||
public float x; | ||
public float y; | ||
public float z; | ||
public float w; | ||
|
||
public Vector4() { | ||
} | ||
|
||
public Vector4(float x, float y, float z, float w) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.w = 1.0f; | ||
} | ||
|
||
public Vector4(Vector4 other) { | ||
this(other.x, other.y, other.z, other.w); | ||
} | ||
|
||
public Vector4 copy() { | ||
return new Vector4(x, y, z, w); | ||
} | ||
|
||
public Vector4 add(float x, float y, float z, float w) { | ||
this.x += x; | ||
this.y += y; | ||
this.z += z; | ||
this.w += w; | ||
return this; | ||
} | ||
|
||
public Vector4 add(Vector4 other) { | ||
return add(other.x, other.y, other.z, other.w); | ||
} | ||
|
||
public Vector4 sub(float x, float y, float z, float w) { | ||
this.x -= x; | ||
this.y -= y; | ||
this.z -= z; | ||
this.w -= w; | ||
return this; | ||
} | ||
|
||
public Vector4 sub(Vector4 other) { | ||
return sub(other.x, other.y, other.z, other.w); | ||
} | ||
|
||
public Vector4 mul(float scalar) { | ||
this.x *= scalar; | ||
this.y *= scalar; | ||
this.z *= scalar; | ||
return this; | ||
} | ||
|
||
public FloatBuffer toFloatBuffer() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
|
||
} |