Class Vector2i
- java.lang.Object
-
- org.joml.Vector2i
-
- All Implemented Interfaces:
java.io.Externalizable
,java.io.Serializable
,java.lang.Cloneable
,Vector2ic
public class Vector2i extends java.lang.Object implements java.io.Externalizable, java.lang.Cloneable, Vector2ic
Represents a 2D vector with single-precision.- Author:
- RGreenlees, Kai Burjack, Hans Uhlig
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Vector2i()
Create a newVector2i
and initialize its components to zero.Vector2i(double x, double y, int mode)
Create a newVector2i
and initialize its component values and round using the givenRoundingMode
.Vector2i(float x, float y, int mode)
Create a newVector2i
and initialize its component values and round using the givenRoundingMode
.Vector2i(int s)
Create a newVector2i
and initialize both of its components with the given value.Vector2i(int[] xy)
Create a newVector2i
and initialize its two components from the first two elements of the given array.Vector2i(int x, int y)
Create a newVector2i
and initialize its components to the given values.Vector2i(int index, java.nio.ByteBuffer buffer)
Create a newVector2i
and read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.Vector2i(int index, java.nio.IntBuffer buffer)
Create a newVector2i
and read this vector from the suppliedIntBuffer
starting at the specified absolute buffer position/index.Vector2i(java.nio.ByteBuffer buffer)
Create a newVector2i
and read this vector from the suppliedByteBuffer
at the current bufferposition
.Vector2i(java.nio.IntBuffer buffer)
Create a newVector2i
and read this vector from the suppliedIntBuffer
at the current bufferposition
.Vector2i(Vector2dc v, int mode)
Create a newVector2i
and initialize its components to the rounded value of the given vector.Vector2i(Vector2fc v, int mode)
Create a newVector2i
and initialize its components to the rounded value of the given vector.Vector2i(Vector2ic v)
Create a newVector2i
and initialize its components to the one of the given vector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2i
absolute()
Setthis
vector's components to their respective absolute values.Vector2i
absolute(Vector2i dest)
Compute the absolute of each of this vector's components and store the result intodest
.Vector2i
add(int x, int y)
Increment the components of this vector by the given values.Vector2i
add(int x, int y, Vector2i dest)
Increment the components of this vector by the given values and store the result indest
.Vector2i
add(Vector2ic v)
Addv
to this vector.Vector2i
add(Vector2ic v, Vector2i dest)
Add the supplied vector to this one and store the result indest
.java.lang.Object
clone()
double
distance(int x, int y)
Return the distance betweenthis
vector and(x, y)
.static double
distance(int x1, int y1, int x2, int y2)
Return the distance between(x1, y1)
and(x2, y2)
.double
distance(Vector2ic v)
Return the distance between this Vector andv
.long
distanceSquared(int x, int y)
Return the square of the distance betweenthis
vector and(x, y)
.static long
distanceSquared(int x1, int y1, int x2, int y2)
Return the squared distance between(x1, y1)
and(x2, y2)
.long
distanceSquared(Vector2ic v)
Return the square of the distance between this vector andv
.Vector2i
div(float scalar)
Divide all components of thisVector2i
by the given scalar value.Vector2i
div(float scalar, Vector2i dest)
Divide all components of thisVector2i
by the given scalar value and store the result indest
.Vector2i
div(int scalar)
Divide all components of thisVector2i
by the given scalar value.Vector2i
div(int scalar, Vector2i dest)
Divide all components of thisVector2i
by the given scalar value and store the result indest
.boolean
equals(int x, int y)
Compare the vector components ofthis
vector with the given(x, y)
and return whether all of them are equal.boolean
equals(java.lang.Object obj)
int
get(int component)
Get the value of the specified component of this vector.java.nio.ByteBuffer
get(int index, java.nio.ByteBuffer buffer)
Store this vector into the suppliedByteBuffer
starting at the specified absolute buffer position/index.java.nio.IntBuffer
get(int index, java.nio.IntBuffer buffer)
Store this vector into the suppliedIntBuffer
starting at the specified absolute buffer position/index.java.nio.ByteBuffer
get(java.nio.ByteBuffer buffer)
Store this vector into the suppliedByteBuffer
at the current bufferposition
.java.nio.IntBuffer
get(java.nio.IntBuffer buffer)
Store this vector into the suppliedIntBuffer
at the current bufferposition
.Vector2ic
getToAddress(long address)
Store this vector at the given off-heap memory address.long
gridDistance(int x, int y)
Return the grid distance in between (aka 1-Norm, Minkowski or Manhattan distance)(x, y)
.long
gridDistance(Vector2ic v)
Return the grid distance in between (aka 1-Norm, Minkowski or Manhattan distance)(x, y)
.int
hashCode()
double
length()
Return the length of this vector.static double
length(int x, int y)
Get the length of a 2-dimensional single-precision vector.long
lengthSquared()
Return the length squared of this vector.static long
lengthSquared(int x, int y)
Get the length squared of a 2-dimensional single-precision vector.Vector2i
max(Vector2ic v)
Set the components of this vector to be the component-wise maximum of this and the other vector.Vector2i
max(Vector2ic v, Vector2i dest)
Set the components ofdest
to be the component-wise maximum of this and the other vector.int
maxComponent()
Determine the component with the biggest absolute value.Vector2i
min(Vector2ic v)
Set the components of this vector to be the component-wise minimum of this and the other vector.Vector2i
min(Vector2ic v, Vector2i dest)
Set the components ofdest
to be the component-wise minimum of this and the other vector.int
minComponent()
Determine the component with the smallest (towards zero) absolute value.Vector2i
mul(int scalar)
Multiply all components of thisVector2i
by the given scalar value.Vector2i
mul(int x, int y)
Multiply the components of this vector by the given values.Vector2i
mul(int x, int y, Vector2i dest)
Multiply the components of this vector by the given values and store the result indest
.Vector2i
mul(int scalar, Vector2i dest)
Multiply all components of thisVector2ic
by the given scalar value and store the result indest
.Vector2i
mul(Vector2ic v)
Add the supplied vector by this one.Vector2i
mul(Vector2ic v, Vector2i dest)
Multiply the supplied vector by this one and store the result indest
.Vector2i
negate()
Negate this vector.Vector2i
negate(Vector2i dest)
Negate this vector and store the result indest
.void
readExternal(java.io.ObjectInput in)
Vector2i
set(int s)
Set the x and y components to the supplied value.Vector2i
set(int[] xy)
Set the two components of this vector to the first two elements of the given array.Vector2i
set(int x, int y)
Set the x and y components to the supplied values.Vector2i
set(int index, java.nio.ByteBuffer buffer)
Read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.Vector2i
set(int index, java.nio.IntBuffer buffer)
Read this vector from the suppliedIntBuffer
starting at the specified absolute buffer position/index.Vector2i
set(java.nio.ByteBuffer buffer)
Read this vector from the suppliedByteBuffer
at the current bufferposition
.Vector2i
set(java.nio.IntBuffer buffer)
Read this vector from the suppliedIntBuffer
at the current bufferposition
.Vector2i
set(Vector2dc v)
Set thisVector2i
to the values of v usingRoundingMode.TRUNCATE
rounding.Vector2i
set(Vector2dc v, int mode)
Set thisVector2i
to the values of v using the givenRoundingMode
.Vector2i
set(Vector2fc v, int mode)
Set thisVector2i
to the values of v using the givenRoundingMode
.Vector2i
set(Vector2ic v)
Set thisVector2i
to the values of v.Vector2i
setComponent(int component, int value)
Set the value of the specified component of this vector.Vector2i
setFromAddress(long address)
Set the values of this vector by reading 2 integer values from off-heap memory, starting at the given address.Vector2i
sub(int x, int y)
Decrement the components of this vector by the given values.Vector2i
sub(int x, int y, Vector2i dest)
Decrement the components of this vector by the given values and store the result indest
.Vector2i
sub(Vector2ic v)
Subtract the supplied vector from this one and store the result inthis
.Vector2i
sub(Vector2ic v, Vector2i dest)
Subtract the supplied vector from this one and store the result indest
.java.lang.String
toString()
Return a string representation of this vector.java.lang.String
toString(java.text.NumberFormat formatter)
Return a string representation of this vector by formatting the vector components with the givenNumberFormat
.void
writeExternal(java.io.ObjectOutput out)
int
x()
int
y()
Vector2i
zero()
Set all components to zero.
-
-
-
Constructor Detail
-
Vector2i
public Vector2i()
Create a newVector2i
and initialize its components to zero.
-
Vector2i
public Vector2i(int s)
Create a newVector2i
and initialize both of its components with the given value.- Parameters:
s
- the value of both components
-
Vector2i
public Vector2i(int x, int y)
Create a newVector2i
and initialize its components to the given values.- Parameters:
x
- the x componenty
- the y component
-
Vector2i
public Vector2i(float x, float y, int mode)
Create a newVector2i
and initialize its component values and round using the givenRoundingMode
.- Parameters:
x
- the x componenty
- the y componentmode
- theRoundingMode
to use
-
Vector2i
public Vector2i(double x, double y, int mode)
Create a newVector2i
and initialize its component values and round using the givenRoundingMode
.- Parameters:
x
- the x componenty
- the y componentmode
- theRoundingMode
to use
-
Vector2i
public Vector2i(Vector2ic v)
Create a newVector2i
and initialize its components to the one of the given vector.- Parameters:
v
- theVector2ic
to copy the values from
-
Vector2i
public Vector2i(Vector2fc v, int mode)
Create a newVector2i
and initialize its components to the rounded value of the given vector.- Parameters:
v
- theVector2fc
to round and copy the values frommode
- theRoundingMode
to use
-
Vector2i
public Vector2i(Vector2dc v, int mode)
Create a newVector2i
and initialize its components to the rounded value of the given vector.- Parameters:
v
- theVector2dc
to round and copy the values frommode
- theRoundingMode
to use
-
Vector2i
public Vector2i(int[] xy)
Create a newVector2i
and initialize its two components from the first two elements of the given array.- Parameters:
xy
- the array containing at least three elements
-
Vector2i
public Vector2i(java.nio.ByteBuffer buffer)
Create a newVector2i
and read this vector from the suppliedByteBuffer
at the current bufferposition
.This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which the vector is read, use
Vector2i(int, ByteBuffer)
, taking the absolute position as parameter.- Parameters:
buffer
- values will be read inx, y
order- See Also:
Vector2i(int, ByteBuffer)
-
Vector2i
public Vector2i(int index, java.nio.ByteBuffer buffer)
Create a newVector2i
and read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
- Parameters:
index
- the absolute position into the ByteBufferbuffer
- values will be read inx, y
order
-
Vector2i
public Vector2i(java.nio.IntBuffer buffer)
Create a newVector2i
and read this vector from the suppliedIntBuffer
at the current bufferposition
.This method will not increment the position of the given IntBuffer.
In order to specify the offset into the IntBuffer at which the vector is read, use
Vector2i(int, IntBuffer)
, taking the absolute position as parameter.- Parameters:
buffer
- values will be read inx, y
order- See Also:
Vector2i(int, IntBuffer)
-
Vector2i
public Vector2i(int index, java.nio.IntBuffer buffer)
Create a newVector2i
and read this vector from the suppliedIntBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given IntBuffer.
- Parameters:
index
- the absolute position into the IntBufferbuffer
- values will be read inx, y
order
-
-
Method Detail
-
set
public Vector2i set(int s)
Set the x and y components to the supplied value.- Parameters:
s
- scalar value of both components- Returns:
- this
-
set
public Vector2i set(int x, int y)
Set the x and y components to the supplied values.- Parameters:
x
- the x componenty
- the y component- Returns:
- this
-
set
public Vector2i set(Vector2ic v)
Set thisVector2i
to the values of v.- Parameters:
v
- the vector to copy from- Returns:
- this
-
set
public Vector2i set(Vector2dc v)
Set thisVector2i
to the values of v usingRoundingMode.TRUNCATE
rounding.Note that due to the given vector
v
storing the components in double-precision, there is the possibility to lose precision.- Parameters:
v
- the vector to copy from- Returns:
- this
-
set
public Vector2i set(Vector2dc v, int mode)
Set thisVector2i
to the values of v using the givenRoundingMode
.Note that due to the given vector
v
storing the components in double-precision, there is the possibility to lose precision.- Parameters:
v
- the vector to copy frommode
- theRoundingMode
to use- Returns:
- this
-
set
public Vector2i set(Vector2fc v, int mode)
Set thisVector2i
to the values of v using the givenRoundingMode
.Note that due to the given vector
v
storing the components in double-precision, there is the possibility to lose precision.- Parameters:
v
- the vector to copy frommode
- theRoundingMode
to use- Returns:
- this
-
set
public Vector2i set(int[] xy)
Set the two components of this vector to the first two elements of the given array.- Parameters:
xy
- the array containing at least two elements- Returns:
- this
-
set
public Vector2i set(java.nio.ByteBuffer buffer)
Read this vector from the suppliedByteBuffer
at the current bufferposition
.This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which the vector is read, use
set(int, ByteBuffer)
, taking the absolute position as parameter.- Parameters:
buffer
- values will be read inx, y
order- Returns:
- this
- See Also:
set(int, ByteBuffer)
-
set
public Vector2i set(int index, java.nio.ByteBuffer buffer)
Read this vector from the suppliedByteBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
- Parameters:
index
- the absolute position into the ByteBufferbuffer
- values will be read inx, y
order- Returns:
- this
-
set
public Vector2i set(java.nio.IntBuffer buffer)
Read this vector from the suppliedIntBuffer
at the current bufferposition
.This method will not increment the position of the given IntBuffer.
In order to specify the offset into the IntBuffer at which the vector is read, use
set(int, IntBuffer)
, taking the absolute position as parameter.- Parameters:
buffer
- values will be read inx, y
order- Returns:
- this
- See Also:
set(int, IntBuffer)
-
set
public Vector2i set(int index, java.nio.IntBuffer buffer)
Read this vector from the suppliedIntBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given IntBuffer.
- Parameters:
index
- the absolute position into the IntBufferbuffer
- values will be read inx, y
order- Returns:
- this
-
setFromAddress
public Vector2i setFromAddress(long address)
Set the values of this vector by reading 2 integer values from off-heap memory, starting at the given address.This method will throw an
UnsupportedOperationException
when JOML is used with `-Djoml.nounsafe`.This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.
- Parameters:
address
- the off-heap memory address to read the vector values from- Returns:
- this
-
get
public int get(int component) throws java.lang.IllegalArgumentException
Description copied from interface:Vector2ic
Get the value of the specified component of this vector.
-
setComponent
public Vector2i setComponent(int component, int value) throws java.lang.IllegalArgumentException
Set the value of the specified component of this vector.- Parameters:
component
- the component whose value to set, within[0..1]
value
- the value to set- Returns:
- this
- Throws:
java.lang.IllegalArgumentException
- ifcomponent
is not within[0..1]
-
get
public java.nio.ByteBuffer get(java.nio.ByteBuffer buffer)
Description copied from interface:Vector2ic
Store this vector into the suppliedByteBuffer
at the current bufferposition
.This method will not increment the position of the given ByteBuffer.
In order to specify the offset into the ByteBuffer at which the vector is stored, use
Vector2ic.get(int, ByteBuffer)
, taking the absolute position as parameter.- Specified by:
get
in interfaceVector2ic
- Parameters:
buffer
- will receive the values of this vector inx, y
order- Returns:
- the passed in buffer
- See Also:
Vector2ic.get(int, ByteBuffer)
-
get
public java.nio.ByteBuffer get(int index, java.nio.ByteBuffer buffer)
Description copied from interface:Vector2ic
Store this vector into the suppliedByteBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given ByteBuffer.
-
get
public java.nio.IntBuffer get(java.nio.IntBuffer buffer)
Description copied from interface:Vector2ic
Store this vector into the suppliedIntBuffer
at the current bufferposition
.This method will not increment the position of the given IntBuffer.
In order to specify the offset into the IntBuffer at which the vector is stored, use
Vector2ic.get(int, IntBuffer)
, taking the absolute position as parameter.- Specified by:
get
in interfaceVector2ic
- Parameters:
buffer
- will receive the values of this vector inx, y
order- Returns:
- the passed in buffer
- See Also:
Vector2ic.get(int, IntBuffer)
-
get
public java.nio.IntBuffer get(int index, java.nio.IntBuffer buffer)
Description copied from interface:Vector2ic
Store this vector into the suppliedIntBuffer
starting at the specified absolute buffer position/index.This method will not increment the position of the given IntBuffer.
-
getToAddress
public Vector2ic getToAddress(long address)
Description copied from interface:Vector2ic
Store this vector at the given off-heap memory address.This method will throw an
UnsupportedOperationException
when JOML is used with `-Djoml.nounsafe`.This method is unsafe as it can result in a crash of the JVM process when the specified address range does not belong to this process.
- Specified by:
getToAddress
in interfaceVector2ic
- Parameters:
address
- the off-heap address where to store this vector- Returns:
- this
-
sub
public Vector2i sub(Vector2ic v)
Subtract the supplied vector from this one and store the result inthis
.- Parameters:
v
- the vector to subtract- Returns:
- this
-
sub
public Vector2i sub(Vector2ic v, Vector2i dest)
Description copied from interface:Vector2ic
Subtract the supplied vector from this one and store the result indest
.
-
sub
public Vector2i sub(int x, int y)
Decrement the components of this vector by the given values.- Parameters:
x
- the x component to subtracty
- the y component to subtract- Returns:
- this
-
sub
public Vector2i sub(int x, int y, Vector2i dest)
Description copied from interface:Vector2ic
Decrement the components of this vector by the given values and store the result indest
.
-
lengthSquared
public long lengthSquared()
Description copied from interface:Vector2ic
Return the length squared of this vector.- Specified by:
lengthSquared
in interfaceVector2ic
- Returns:
- the length squared
-
lengthSquared
public static long lengthSquared(int x, int y)
Get the length squared of a 2-dimensional single-precision vector.- Parameters:
x
- The vector's x componenty
- The vector's y component- Returns:
- the length squared of the given vector
-
length
public double length()
Description copied from interface:Vector2ic
Return the length of this vector.
-
length
public static double length(int x, int y)
Get the length of a 2-dimensional single-precision vector.- Parameters:
x
- The vector's x componenty
- The vector's y component- Returns:
- the length squared of the given vector
-
distance
public double distance(Vector2ic v)
Description copied from interface:Vector2ic
Return the distance between this Vector andv
.
-
distance
public double distance(int x, int y)
Description copied from interface:Vector2ic
Return the distance betweenthis
vector and(x, y)
.
-
distanceSquared
public long distanceSquared(Vector2ic v)
Description copied from interface:Vector2ic
Return the square of the distance between this vector andv
.- Specified by:
distanceSquared
in interfaceVector2ic
- Parameters:
v
- the other vector- Returns:
- the squared of the distance
-
distanceSquared
public long distanceSquared(int x, int y)
Description copied from interface:Vector2ic
Return the square of the distance betweenthis
vector and(x, y)
.- Specified by:
distanceSquared
in interfaceVector2ic
- Parameters:
x
- the x component of the other vectory
- the y component of the other vector- Returns:
- the square of the distance
-
gridDistance
public long gridDistance(Vector2ic v)
Description copied from interface:Vector2ic
Return the grid distance in between (aka 1-Norm, Minkowski or Manhattan distance)(x, y)
.- Specified by:
gridDistance
in interfaceVector2ic
- Parameters:
v
- the other vector- Returns:
- the grid distance
-
gridDistance
public long gridDistance(int x, int y)
Description copied from interface:Vector2ic
Return the grid distance in between (aka 1-Norm, Minkowski or Manhattan distance)(x, y)
.- Specified by:
gridDistance
in interfaceVector2ic
- Parameters:
x
- the x component of the other vectory
- the y component of the other vector- Returns:
- the grid distance
-
distance
public static double distance(int x1, int y1, int x2, int y2)
Return the distance between(x1, y1)
and(x2, y2)
.- Parameters:
x1
- the x component of the first vectory1
- the y component of the first vectorx2
- the x component of the second vectory2
- the y component of the second vector- Returns:
- the euclidean distance
-
distanceSquared
public static long distanceSquared(int x1, int y1, int x2, int y2)
Return the squared distance between(x1, y1)
and(x2, y2)
.- Parameters:
x1
- the x component of the first vectory1
- the y component of the first vectorx2
- the x component of the second vectory2
- the y component of the second vector- Returns:
- the euclidean distance squared
-
add
public Vector2i add(Vector2ic v)
Addv
to this vector.- Parameters:
v
- the vector to add- Returns:
- this
-
add
public Vector2i add(Vector2ic v, Vector2i dest)
Description copied from interface:Vector2ic
Add the supplied vector to this one and store the result indest
.
-
add
public Vector2i add(int x, int y)
Increment the components of this vector by the given values.- Parameters:
x
- the x component to addy
- the y component to add- Returns:
- this
-
add
public Vector2i add(int x, int y, Vector2i dest)
Description copied from interface:Vector2ic
Increment the components of this vector by the given values and store the result indest
.
-
mul
public Vector2i mul(int scalar)
Multiply all components of thisVector2i
by the given scalar value.- Parameters:
scalar
- the scalar to multiply this vector by- Returns:
- this
-
mul
public Vector2i mul(int scalar, Vector2i dest)
Description copied from interface:Vector2ic
Multiply all components of thisVector2ic
by the given scalar value and store the result indest
.
-
mul
public Vector2i mul(Vector2ic v)
Add the supplied vector by this one.- Parameters:
v
- the vector to multiply- Returns:
- this
-
mul
public Vector2i mul(Vector2ic v, Vector2i dest)
Description copied from interface:Vector2ic
Multiply the supplied vector by this one and store the result indest
.
-
mul
public Vector2i mul(int x, int y)
Multiply the components of this vector by the given values.- Parameters:
x
- the x component to multiplyy
- the y component to multiply- Returns:
- this
-
mul
public Vector2i mul(int x, int y, Vector2i dest)
Description copied from interface:Vector2ic
Multiply the components of this vector by the given values and store the result indest
.
-
div
public Vector2i div(float scalar)
Divide all components of thisVector2i
by the given scalar value.- Parameters:
scalar
- the scalar to divide by- Returns:
- a vector holding the result
-
div
public Vector2i div(float scalar, Vector2i dest)
Description copied from interface:Vector2ic
Divide all components of thisVector2i
by the given scalar value and store the result indest
.
-
div
public Vector2i div(int scalar)
Divide all components of thisVector2i
by the given scalar value.- Parameters:
scalar
- the scalar to divide by- Returns:
- a vector holding the result
-
div
public Vector2i div(int scalar, Vector2i dest)
Description copied from interface:Vector2ic
Divide all components of thisVector2i
by the given scalar value and store the result indest
.
-
zero
public Vector2i zero()
Set all components to zero.- Returns:
- this
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
- Specified by:
writeExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
- Specified by:
readExternal
in interfacejava.io.Externalizable
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
negate
public Vector2i negate()
Negate this vector.- Returns:
- this
-
negate
public Vector2i negate(Vector2i dest)
Description copied from interface:Vector2ic
Negate this vector and store the result indest
.
-
min
public Vector2i min(Vector2ic v)
Set the components of this vector to be the component-wise minimum of this and the other vector.- Parameters:
v
- the other vector- Returns:
- this
-
min
public Vector2i min(Vector2ic v, Vector2i dest)
Description copied from interface:Vector2ic
Set the components ofdest
to be the component-wise minimum of this and the other vector.
-
max
public Vector2i max(Vector2ic v)
Set the components of this vector to be the component-wise maximum of this and the other vector.- Parameters:
v
- the other vector- Returns:
- this
-
max
public Vector2i max(Vector2ic v, Vector2i dest)
Description copied from interface:Vector2ic
Set the components ofdest
to be the component-wise maximum of this and the other vector.
-
maxComponent
public int maxComponent()
Description copied from interface:Vector2ic
Determine the component with the biggest absolute value.- Specified by:
maxComponent
in interfaceVector2ic
- Returns:
- the component index, within
[0..1]
-
minComponent
public int minComponent()
Description copied from interface:Vector2ic
Determine the component with the smallest (towards zero) absolute value.- Specified by:
minComponent
in interfaceVector2ic
- Returns:
- the component index, within
[0..1]
-
absolute
public Vector2i absolute()
Setthis
vector's components to their respective absolute values.- Returns:
- this
-
absolute
public Vector2i absolute(Vector2i dest)
Description copied from interface:Vector2ic
Compute the absolute of each of this vector's components and store the result intodest
.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
equals
public boolean equals(int x, int y)
Description copied from interface:Vector2ic
Compare the vector components ofthis
vector with the given(x, y)
and return whether all of them are equal.
-
toString
public java.lang.String toString()
Return a string representation of this vector.This method creates a new
DecimalFormat
on every invocation with the format string "0.000E0;-
".- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation
-
toString
public java.lang.String toString(java.text.NumberFormat formatter)
Return a string representation of this vector by formatting the vector components with the givenNumberFormat
.- Parameters:
formatter
- theNumberFormat
used to format the vector components with- Returns:
- the string representation
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
-