public final class Vector3 extends java.lang.Object implements java.lang.Comparable<Vector3>, Struct<Vector3>, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
double |
x
The x component.
|
double |
y
The y component.
|
double |
z
The z component.
|
| Constructor and Description |
|---|
Vector3() |
Vector3(double v)
Initializes a new instance of the
Vector3 struct. |
Vector3(double x,
double y,
double z)
Initializes a new instance of the
Vector3 struct. |
Vector3(FVector3 vec)
Initializes a new instance of the
Vector3 struct. |
Vector3(Vector4 vec4)
Initializes a new instance of the
Vector3 struct. |
| Modifier and Type | Method and Description |
|---|---|
static Vector3 |
add(Vector3 lhs,
Vector3 rhs)
Operator overloading for +
|
double |
angleBetween(Vector3 dir)
Calculate the inner angle between two direction
Two direction can be non-normalized vectors
|
double |
angleBetween(Vector3 dir,
Vector3 up)
Calculate the inner angle between two direction
Two direction can be non-normalized vectors
|
Vector3 |
clone()
Clone current instance
|
int |
compareTo(Vector3 other)
Compare current vector to another instance.
|
void |
copyFrom(Vector3 src)
Copy internal state from argument t
|
Vector3 |
cos()
Calculates cosine on each component
|
static FVector3 |
create(Vector3 v)
Explicit conversion operator to cast Vector3 to FVector3
|
Vector3 |
cross(Vector3 rhs)
Cross product of two vectors
|
static Vector3 |
div(Vector3 lhs,
double rhs)
Operator overloading for /
|
static Vector3 |
div(Vector3 lhs,
Vector3 rhs)
Operator overloading for /
|
double |
dot(Vector3 rhs)
Gets the dot product of two vectors
|
boolean |
equals(java.lang.Object obj)
Check if two vector3 equals
|
double |
get(int idx)
Gets vector's component by index.
|
double |
getLength()
Gets the length of this vector.
|
double |
getLength2()
Gets the square of the length.
|
static Vector3 |
getOne()
Gets unit vector (1, 1, 1)
|
static Vector3 |
getUnitX()
Gets unit vector (1, 0, 0)
|
static Vector3 |
getUnitY()
Gets unit vector (0, 1, 0)
|
static Vector3 |
getUnitZ()
Gets unit vector (0, 0, 1)
|
static Vector3 |
getZero()
Gets unit vector (0, 0, 0)
|
int |
hashCode()
Gets the hash code of Vector3
|
static Vector3 |
mul(double lhs,
Vector3 rhs)
Operator overloading for *
|
static Vector3 |
mul(Vector3 lhs,
double rhs)
Operator overloading for *
|
static Vector3 |
mul(Vector3 lhs,
Vector3 rhs)
Operator overloading for *
|
static Vector3 |
negative(Vector3 v)
Operator overloading for -
|
Vector3 |
normalize()
Normalizes this instance.
|
static boolean |
op_eq(Vector3 lhs,
Vector3 rhs)
Equal operator for Vector3
|
static boolean |
op_ne(Vector3 lhs,
Vector3 rhs)
Not-equal operator for Vector3
|
void |
set(double newX,
double newY,
double newZ)
Sets the x/y/z component in one call.
|
void |
set(int idx,
double value)
Sets vector's component by index.
|
Vector3 |
sin()
Calculates sine on each component
|
static Vector3 |
sub(Vector3 lhs,
Vector3 rhs)
Operator overloading for - (minus)
|
java.lang.String |
toString()
Returns a
String that represents the current Vector3. |
public double x
public double y
public double z
public Vector3(double x,
double y,
double z)
Vector3 struct.x - The x coordinate.y - The y coordinate.z - The z coordinate.public Vector3(FVector3 vec)
Vector3 struct.vec - The x coordinate.public Vector3(double v)
Vector3 struct.v - V.public Vector3(Vector4 vec4)
Vector3 struct.vec4 - Vec4.public Vector3()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - The object to check equality.public static FVector3 create(Vector3 v)
public double dot(Vector3 rhs)
rhs - Right hand side value.public Vector3 normalize()
public double getLength2()
public double getLength()
public Vector3 cross(Vector3 rhs)
rhs - Right hand side value.Vector3s.public static Vector3 getZero()
public static Vector3 getOne()
public static Vector3 getUnitX()
public static Vector3 getUnitY()
public static Vector3 getUnitZ()
public static Vector3 negative(Vector3 v)
v - The origin vectorpublic static Vector3 sub(Vector3 lhs, Vector3 rhs)
lhs - The left vectorrhs - The right vectorpublic static Vector3 add(Vector3 lhs, Vector3 rhs)
lhs - The left vectorrhs - The right vectorpublic static Vector3 mul(Vector3 lhs, Vector3 rhs)
lhs - The left vectorrhs - The right vectorpublic static Vector3 mul(double lhs, Vector3 rhs)
lhs - The left scalarrhs - The right vectorpublic static Vector3 mul(Vector3 lhs, double rhs)
lhs - The left vectorrhs - The right double valuepublic static Vector3 div(Vector3 lhs, double rhs)
lhs - The left vectorrhs - The right double valuepublic static Vector3 div(Vector3 lhs, Vector3 rhs)
lhs - The left vectorrhs - The right vectorpublic static boolean op_eq(Vector3 lhs, Vector3 rhs)
lhs - Left hand side value.rhs - Right hand side value.public static boolean op_ne(Vector3 lhs, Vector3 rhs)
lhs - Left hand side value.rhs - Right hand side value.public void set(double newX,
double newY,
double newZ)
newX - The x component.newY - The y component.newZ - The z component.public java.lang.String toString()
String that represents the current Vector3.toString in class java.lang.ObjectString that represents the current Vector3.public double angleBetween(Vector3 dir, Vector3 up)
dir - The direction vector to compare withup - The up vector of the two direction's shared planepublic double angleBetween(Vector3 dir)
dir - The direction vector to compare withpublic int compareTo(Vector3 other)
compareTo in interface java.lang.Comparable<Vector3>public double get(int idx)
public void set(int idx,
double value)
value - New valuepublic void copyFrom(Vector3 src)
Structpublic int hashCode()
hashCode in class java.lang.ObjectVector3