-
- All Implemented Interfaces:
public final class Vec2
2D Vectors class
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public class
Vec2.Companion
-
Method Summary
Modifier and Type Method Description final Vec2
getNormalized()
final Boolean
getIsValid()
final Boolean
getIsZero()
final Double
getX()
final Unit
setX(Double x)
final Double
getY()
final Unit
setY(Double y)
final Vec2
set(Double x, Double y)
Sets a vector to equal an x/y value and returns this. final Vec2
set(Vec2 v1)
Sets a vector to another vector and returns this. final Vec2
copy()
Copy method to return a new copy of the current instance vector. final Vec2
unaryMinus()
Negates the current instance vector and return this. final Vec2
copyNegative()
Negates the current instance vector and return this. final Vec2
add(Vec2 v)
Adds a vector to the current instance and return this. final Vec2
plus(Vec2 v)
Adds a vector and the current instance vector together and returns a new vector of them added together. final Vec2
normal()
Generates a normal of a vector. final Vec2
normalize()
Normalizes the current instance vector to length 1 and returns this. final Double
distance(Vec2 v)
Finds the distance between two vectors. final Vec2
minus(Vec2 v1)
Subtract a vector from the current instance vector. final Double
cross(Vec2 v1)
Finds cross product between two vectors. final Vec2
cross(Double a)
final Vec2
scalar(Double a)
final Double
dot(Vec2 v1)
Finds dotproduct between two vectors. final Double
length()
Gets the length of instance vector. String
toString()
Boolean
equals(Object other)
-
-
Method Detail
-
getNormalized
final Vec2 getNormalized()
-
getIsValid
final Boolean getIsValid()
-
set
final Vec2 set(Double x, Double y)
Sets a vector to equal an x/y value and returns this.
- Parameters:
x
- x value.y
- y value.
-
set
final Vec2 set(Vec2 v1)
Sets a vector to another vector and returns this.
- Parameters:
v1
- Vector to set x/y values to.
-
unaryMinus
final Vec2 unaryMinus()
Negates the current instance vector and return this.
-
copyNegative
final Vec2 copyNegative()
Negates the current instance vector and return this.
-
add
final Vec2 add(Vec2 v)
Adds a vector to the current instance and return this.
- Parameters:
v
- Vector to add.
-
plus
final Vec2 plus(Vec2 v)
Adds a vector and the current instance vector together and returns a new vector of them added together.
- Parameters:
v
- Vector to add.
-
normal
final Vec2 normal()
Generates a normal of a vector. Normal facing to the right clock wise 90 degrees.
-
normalize
final Vec2 normalize()
Normalizes the current instance vector to length 1 and returns this.
-
distance
final Double distance(Vec2 v)
Finds the distance between two vectors.
- Parameters:
v
- Vector to find distance from.
-
minus
final Vec2 minus(Vec2 v1)
Subtract a vector from the current instance vector.
- Parameters:
v1
- Vector to subtract.
-
cross
final Double cross(Vec2 v1)
Finds cross product between two vectors.
- Parameters:
v1
- Other vector to apply cross product to
-
dot
final Double dot(Vec2 v1)
Finds dotproduct between two vectors.
- Parameters:
v1
- Other vector to apply dotproduct to.
-
-
-
-