public class Vector2i extends Object implements Externalizable, Vector2ic
| Modifier and Type | Field and Description |
|---|---|
int |
x
The x component of the vector.
|
int |
y
The y component of the vector.
|
| Constructor and Description |
|---|
Vector2i()
Create a new
Vector2i and initialize its components to zero. |
Vector2i(ByteBuffer buffer)
Create a new
Vector2i and read this vector from the supplied
ByteBuffer at the current buffer
position. |
Vector2i(int s)
Create a new
Vector2i and initialize both of its components with
the given value. |
Vector2i(IntBuffer buffer)
|
Vector2i(int index,
ByteBuffer buffer)
Create a new
Vector2i and read this vector from the supplied
ByteBuffer starting at the specified absolute buffer
position/index. |
Vector2i(int x,
int y)
Create a new
Vector2i and initialize its components to the given values. |
Vector2i(int index,
IntBuffer buffer)
|
Vector2i(Vector2ic v)
Create a new
Vector2i and initialize its components to the one of
the given vector. |
| Modifier and Type | Method and Description |
|---|---|
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 in
dest. |
Vector2i |
add(Vector2ic v)
Add
v to this vector. |
Vector2i |
add(Vector2ic v,
Vector2i dest)
Add the supplied vector to this one and store the result in
dest. |
double |
distance(int x,
int y)
Return the distance between
this 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 and
v. |
long |
distanceSquared(int x,
int y)
Return the square of the distance between
this 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 and
v. |
boolean |
equals(int x,
int y)
Compare the vector components of
this vector with the given (x, y)
and return whether all of them are equal. |
boolean |
equals(Object obj) |
ByteBuffer |
get(ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer at the current
buffer position. |
int |
get(int component)
Get the value of the specified component of this vector.
|
IntBuffer |
get(IntBuffer buffer)
|
ByteBuffer |
get(int index,
ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer starting at the
specified absolute buffer position/index. |
IntBuffer |
get(int index,
IntBuffer buffer)
Store this vector into the supplied
IntBuffer starting at the
specified absolute buffer position/index. |
long |
gridDistance(int x,
int y)
(non-Javadoc)
|
long |
gridDistance(Vector2ic v)
(non-Javadoc)
|
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 of
dest 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 of
dest 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 this
Vector2i 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 in
dest. |
Vector2i |
mul(int scalar,
Vector2i dest)
Multiply all components of this
Vector2ic by the given scalar
value and store the result in dest. |
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 in
dest. |
Vector2i |
negate()
Negate this vector.
|
Vector2i |
negate(Vector2i dest)
Negate this vector and store the result in
dest. |
void |
readExternal(ObjectInput in) |
Vector2i |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position. |
Vector2i |
set(int s)
Set the x and y components to the supplied value.
|
Vector2i |
set(IntBuffer buffer)
|
Vector2i |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the
specified absolute buffer position/index. |
Vector2i |
set(int x,
int y)
Set the x and y components to the supplied values.
|
Vector2i |
set(int index,
IntBuffer buffer)
Read this vector from the supplied
IntBuffer starting at the
specified absolute buffer position/index. |
Vector2i |
set(Vector2dc v)
Set this
Vector2i to the values of v. |
Vector2i |
set(Vector2ic v)
Set this
Vector2i to the values of v. |
Vector2i |
setComponent(int component,
int value)
Set the value of the specified component of this vector.
|
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 in
dest. |
Vector2i |
sub(Vector2ic v)
Subtract the supplied vector from this one and store the result in
this. |
Vector2i |
sub(Vector2ic v,
Vector2i dest)
Subtract the supplied vector from this one and store the result in
dest. |
String |
toString()
Return a string representation of this vector.
|
String |
toString(NumberFormat formatter)
Return a string representation of this vector by formatting the vector components with the given
NumberFormat. |
void |
writeExternal(ObjectOutput out) |
int |
x() |
int |
y() |
Vector2i |
zero()
Set all components to zero.
|
public int x
public int y
public Vector2i()
Vector2i and initialize its components to zero.public Vector2i(int s)
Vector2i and initialize both of its components with
the given value.s - the value of both componentspublic Vector2i(int x,
int y)
Vector2i and initialize its components to the given values.x - the x componenty - the y componentpublic Vector2i(Vector2ic v)
Vector2i and initialize its components to the one of
the given vector.v - the Vector2ic to copy the values frompublic Vector2i(ByteBuffer buffer)
Vector2i and read this vector from the supplied
ByteBuffer at the current buffer
position.
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.
buffer - values will be read in x, y orderVector2i(int, ByteBuffer)public Vector2i(int index,
ByteBuffer buffer)
Vector2i and read this vector from the supplied
ByteBuffer starting at the specified absolute buffer
position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - values will be read in x, y orderpublic Vector2i(IntBuffer buffer)
Vector2i and read this vector from the supplied
IntBuffer at the current buffer
position.
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.
buffer - values will be read in x, y orderVector2i(int, IntBuffer)public Vector2i(int index,
IntBuffer buffer)
Vector2i and read this vector from the supplied
IntBuffer starting at the specified absolute buffer
position/index.
This method will not increment the position of the given IntBuffer.
index - the absolute position into the IntBufferbuffer - values will be read in x, y orderpublic Vector2i set(int s)
s - scalar value of both componentspublic Vector2i set(int x, int y)
x - the x componenty - the y componentpublic Vector2i set(Vector2ic v)
Vector2i to the values of v.v - the vector to copy frompublic Vector2i set(Vector2dc v)
Vector2i to the values of v.
Note that due to the given vector v storing the components
in double-precision, there is the possibility to lose precision.
v - the vector to copy frompublic Vector2i set(ByteBuffer buffer)
ByteBuffer at the current
buffer position.
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.
buffer - values will be read in x, y orderset(int, ByteBuffer)public Vector2i set(int index, ByteBuffer buffer)
ByteBuffer starting at the
specified absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
index - the absolute position into the ByteBufferbuffer - values will be read in x, y orderpublic Vector2i set(IntBuffer buffer)
IntBuffer at the current
buffer position.
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.
buffer - values will be read in x, y orderset(int, IntBuffer)public Vector2i set(int index, IntBuffer buffer)
IntBuffer starting at the
specified absolute buffer position/index.
This method will not increment the position of the given IntBuffer.
index - the absolute position into the IntBufferbuffer - values will be read in x, y orderpublic int get(int component)
throws IllegalArgumentException
Vector2icget in interface Vector2iccomponent - the component, within [0..1]IllegalArgumentException - if component is not within [0..1]public Vector2i setComponent(int component, int value) throws IllegalArgumentException
component - the component whose value to set, within [0..1]value - the value to setIllegalArgumentException - if component is not within [0..1]public ByteBuffer get(ByteBuffer buffer)
Vector2icByteBuffer at the current
buffer position.
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.
get in interface Vector2icbuffer - will receive the values of this vector in x, y orderVector2ic.get(int, ByteBuffer)public ByteBuffer get(int index, ByteBuffer buffer)
Vector2icByteBuffer starting at the
specified absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
public IntBuffer get(IntBuffer buffer)
Vector2icIntBuffer at the current
buffer position.
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.
get in interface Vector2icbuffer - will receive the values of this vector in x, y orderVector2ic.get(int, IntBuffer)public IntBuffer get(int index, IntBuffer buffer)
Vector2icIntBuffer starting at the
specified absolute buffer position/index.
This method will not increment the position of the given IntBuffer.
public Vector2i sub(Vector2ic v)
this.v - the vector to subtractpublic Vector2i sub(Vector2ic v, Vector2i dest)
Vector2icdest.public Vector2i sub(int x, int y)
x - the x component to subtracty - the y component to subtractpublic Vector2i sub(int x, int y, Vector2i dest)
Vector2icdest.public long lengthSquared()
Vector2iclengthSquared in interface Vector2icpublic static long lengthSquared(int x,
int y)
x - The vector's x componenty - The vector's y componentpublic double length()
Vector2icpublic static double length(int x,
int y)
x - The vector's x componenty - The vector's y componentpublic double distance(Vector2ic v)
Vector2icv.public double distance(int x,
int y)
Vector2icthis vector and (x, y).public long distanceSquared(Vector2ic v)
Vector2icv.distanceSquared in interface Vector2icv - the other vectorpublic long distanceSquared(int x,
int y)
Vector2icthis vector and
(x, y).distanceSquared in interface Vector2icx - the x component of the other vectory - the y component of the other vectorpublic long gridDistance(Vector2ic v)
gridDistance in interface Vector2icv - the other vectorVector2ic.gridDistance(org.joml.Vector2ic)public long gridDistance(int x,
int y)
gridDistance in interface Vector2icx - the x component of the other vectory - the y component of the other vectorVector2ic.gridDistance(int, int)public static double distance(int x1,
int y1,
int x2,
int y2)
(x1, y1) and (x2, y2).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 vectorpublic static long distanceSquared(int x1,
int y1,
int x2,
int y2)
(x1, y1) and (x2, y2).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 vectorpublic Vector2i add(Vector2ic v)
v to this vector.v - the vector to addpublic Vector2i add(Vector2ic v, Vector2i dest)
Vector2icdest.public Vector2i add(int x, int y)
x - the x component to addy - the y component to addpublic Vector2i add(int x, int y, Vector2i dest)
Vector2icdest.public Vector2i mul(int scalar)
Vector2i by the given scalar
value.scalar - the scalar to multiply this vector bypublic Vector2i mul(int scalar, Vector2i dest)
Vector2icVector2ic by the given scalar
value and store the result in dest.public Vector2i mul(Vector2ic v)
v - the vector to multiplypublic Vector2i mul(Vector2ic v, Vector2i dest)
Vector2icdest.public Vector2i mul(int x, int y)
x - the x component to multiplyy - the y component to multiplypublic Vector2i mul(int x, int y, Vector2i dest)
Vector2icdest.public Vector2i zero()
public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic Vector2i negate()
public Vector2i negate(Vector2i dest)
Vector2icdest.public Vector2i min(Vector2ic v)
v - the other vectorpublic Vector2i min(Vector2ic v, Vector2i dest)
Vector2icdest to be the component-wise minimum of this and the other vector.public Vector2i max(Vector2ic v)
v - the other vectorpublic Vector2i max(Vector2ic v, Vector2i dest)
Vector2icdest to be the component-wise maximum of this and the other vector.public int maxComponent()
Vector2icmaxComponent in interface Vector2ic[0..1]public int minComponent()
Vector2icminComponent in interface Vector2ic[0..1]public boolean equals(int x,
int y)
Vector2icthis vector with the given (x, y)
and return whether all of them are equal.public String toString()
This method creates a new DecimalFormat on every invocation with the format string "0.000E0;-".
public String toString(NumberFormat formatter)
NumberFormat.formatter - the NumberFormat used to format the vector components withCopyright © 2015–2019 JOML. All rights reserved.