public class Vector3i extends Object implements Externalizable, Vector3ic
Modifier and Type | Field and Description |
---|---|
int |
x
The x component of the vector.
|
int |
y
The y component of the vector.
|
int |
z
The z component of the vector.
|
Constructor and Description |
---|
Vector3i()
Create a new
Vector3i of (0, 0, 0). |
Vector3i(ByteBuffer buffer)
Create a new
Vector3i and read this vector from the supplied
ByteBuffer at the current buffer
position . |
Vector3i(int d)
Create a new
Vector3i and initialize all three components with
the given value. |
Vector3i(IntBuffer buffer)
|
Vector3i(int index,
ByteBuffer buffer)
Create a new
Vector3i and read this vector from the supplied
ByteBuffer starting at the specified absolute buffer
position/index. |
Vector3i(int index,
IntBuffer buffer)
|
Vector3i(int x,
int y,
int z)
Create a new
Vector3i with the given component values. |
Vector3i(Vector2ic v,
int z)
|
Vector3i(Vector3ic v)
Create a new
Vector3i with the same values as v . |
Modifier and Type | Method and Description |
---|---|
Vector3i |
add(int x,
int y,
int z)
Increment the components of this vector by the given values.
|
Vector3i |
add(int x,
int y,
int z,
Vector3i dest)
Increment the components of this vector by the given values and store the
result in
dest . |
Vector3i |
add(Vector3ic v)
Add the supplied vector to this one.
|
Vector3i |
add(Vector3ic v,
Vector3i dest)
Add the supplied vector to this one and store the result in
dest . |
double |
distance(int x,
int y,
int z)
Return the distance between
this vector and (x, y, z). |
double |
distance(Vector3ic v)
Return the distance between this Vector and
v . |
long |
distanceSquared(int x,
int y,
int z)
Return the square of the distance between
this vector and (x, y, z). |
long |
distanceSquared(Vector3ic v)
Return the square of the distance between this vector and
v . |
boolean |
equals(Object obj) |
ByteBuffer |
get(ByteBuffer buffer)
Store this vector into the supplied
ByteBuffer at the current
buffer position . |
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. |
int |
hashCode() |
double |
length()
Return the length of this vector.
|
long |
lengthSquared()
Return the length squared of this vector.
|
Vector3i |
mul(int scalar)
Multiply all components of this
Vector3i by the given scalar
value. |
Vector3i |
mul(int x,
int y,
int z)
Multiply the components of this vector by the given values.
|
Vector3i |
mul(int x,
int y,
int z,
Vector3i dest)
Multiply the components of this vector by the given values and store the
result in
dest . |
Vector3i |
mul(int scalar,
Vector3i dest)
Multiply the components of this vector by the given scalar and store the result in
dest . |
Vector3i |
mul(Vector3ic v)
Add the supplied vector by this one.
|
Vector3i |
mul(Vector3ic v,
Vector3i dest)
Multiply the supplied vector by this one and store the result in
dest . |
Vector3i |
negate()
Negate this vector.
|
Vector3i |
negate(Vector3i dest)
Negate this vector and store the result in
dest . |
void |
readExternal(ObjectInput in) |
Vector3i |
set(ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer at the current
buffer position . |
Vector3i |
set(int d)
Set the x, y, and z components to the supplied value.
|
Vector3i |
set(IntBuffer buffer)
|
Vector3i |
set(int index,
ByteBuffer buffer)
Read this vector from the supplied
ByteBuffer starting at the
specified absolute buffer position/index. |
Vector3i |
set(int index,
IntBuffer buffer)
Read this vector from the supplied
IntBuffer starting at the
specified absolute buffer position/index. |
Vector3i |
set(int x,
int y,
int z)
Set the x, y and z components to the supplied values.
|
Vector3i |
set(Vector2ic v,
int z)
Set the first two components from the given
v and the z
component from the given z |
Vector3i |
set(Vector3dc v)
Set the x, y and z components to match the supplied vector.
|
Vector3i |
set(Vector3ic v)
Set the x, y and z components to match the supplied vector.
|
Vector3i |
sub(int x,
int y,
int z)
Decrement the components of this vector by the given values.
|
Vector3i |
sub(int x,
int y,
int z,
Vector3i dest)
Decrement the components of this vector by the given values and store the
result in
dest . |
Vector3i |
sub(Vector3ic v)
Subtract the supplied vector from this one and store the result in
this . |
Vector3i |
sub(Vector3ic v,
Vector3i dest)
Subtract the supplied vector from this one and store the result in
dest . |
Vector3ic |
toImmutable()
Create a new immutable view of this
Vector3i . |
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() |
int |
z() |
Vector3i |
zero()
Set all components to zero.
|
public int x
public int y
public int z
public Vector3i()
Vector3i
of (0, 0, 0).public Vector3i(int d)
Vector3i
and initialize all three components with
the given value.d
- the value of all three componentspublic Vector3i(int x, int y, int z)
Vector3i
with the given component values.x
- the value of xy
- the value of yz
- the value of zpublic Vector3i(Vector3ic v)
Vector3i
with the same values as v
.v
- the Vector3ic
to copy the values frompublic Vector3i(Vector2ic v, int z)
v
- the Vector2ic
to copy the values fromz
- the z componentpublic Vector3i(ByteBuffer buffer)
Vector3i
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 Vector3i(int, ByteBuffer)
, taking the absolute
position as parameter.
buffer
- values will be read in x, y, z orderVector3i(int, ByteBuffer)
public Vector3i(int index, ByteBuffer buffer)
Vector3i
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, z orderpublic Vector3i(IntBuffer buffer)
Vector3i
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 Vector3i(int, IntBuffer)
, taking the absolute position
as parameter.
buffer
- values will be read in x, y, z orderVector3i(int, IntBuffer)
public Vector3i(int index, IntBuffer buffer)
Vector3i
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, z orderpublic Vector3i set(Vector3ic v)
v
- contains the values of x, y and z to setpublic Vector3i set(Vector3dc v)
Note that due to the given vector v
storing the components
in double-precision, there is the possibility to lose precision.
v
- contains the values of x, y and z to setpublic Vector3i set(Vector2ic v, int z)
v
and the z
component from the given z
v
- the Vector2ic
to copy the values fromz
- the z componentpublic Vector3i set(int d)
d
- the value of all three componentspublic Vector3i set(int x, int y, int z)
x
- the x componenty
- the y componentz
- the z componentpublic Vector3i 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, z orderset(int, ByteBuffer)
public Vector3i 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, z orderpublic Vector3i 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, z orderset(int, IntBuffer)
public Vector3i 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, z orderpublic IntBuffer get(IntBuffer buffer)
Vector3ic
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
stored, use Vector3ic.get(int, IntBuffer)
, taking the absolute position as
parameter.
get
in interface Vector3ic
buffer
- will receive the values of this vector in x, y, z orderVector3ic.get(int, IntBuffer)
public IntBuffer get(int index, IntBuffer buffer)
Vector3ic
IntBuffer
starting at the
specified absolute buffer position/index.
This method will not increment the position of the given IntBuffer.
public ByteBuffer get(ByteBuffer buffer)
Vector3ic
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
stored, use Vector3ic.get(int, ByteBuffer)
, taking the absolute position
as parameter.
get
in interface Vector3ic
buffer
- will receive the values of this vector in x, y, z orderVector3ic.get(int, ByteBuffer)
public ByteBuffer get(int index, ByteBuffer buffer)
Vector3ic
ByteBuffer
starting at the
specified absolute buffer position/index.
This method will not increment the position of the given ByteBuffer.
public Vector3i sub(Vector3ic v)
this
.v
- the vector to subtractpublic Vector3i sub(Vector3ic v, Vector3i dest)
Vector3ic
dest
.public Vector3i sub(int x, int y, int z)
x
- the x component to subtracty
- the y component to subtractz
- the z component to subtractpublic Vector3i sub(int x, int y, int z, Vector3i dest)
Vector3ic
dest
.public Vector3i add(Vector3ic v)
v
- the vector to addpublic Vector3i add(Vector3ic v, Vector3i dest)
Vector3ic
dest
.public Vector3i add(int x, int y, int z)
x
- the x component to addy
- the y component to addz
- the z component to addpublic Vector3i add(int x, int y, int z, Vector3i dest)
Vector3ic
dest
.public Vector3i mul(int scalar)
Vector3i
by the given scalar
value.scalar
- the scalar to multiply this vector bypublic Vector3i mul(int scalar, Vector3i dest)
Vector3ic
dest
.public Vector3i mul(Vector3ic v)
v
- the vector to multiplypublic Vector3i mul(Vector3ic v, Vector3i dest)
Vector3ic
dest
.public Vector3i mul(int x, int y, int z)
x
- the x component to multiplyy
- the y component to multiplyz
- the z component to multiplypublic Vector3i mul(int x, int y, int z, Vector3i dest)
Vector3ic
dest
.public long lengthSquared()
Vector3ic
lengthSquared
in interface Vector3ic
public double length()
Vector3ic
public double distance(Vector3ic v)
Vector3ic
v
.public double distance(int x, int y, int z)
Vector3ic
this
vector and (x, y, z).public long distanceSquared(Vector3ic v)
Vector3ic
v
.distanceSquared
in interface Vector3ic
v
- the other vectorpublic long distanceSquared(int x, int y, int z)
Vector3ic
this
vector and (x, y, z).distanceSquared
in interface Vector3ic
x
- the x component of the other vectory
- the y component of the other vectorz
- the z component of the other vectorpublic Vector3i zero()
public String toString()
public String toString(NumberFormat formatter)
NumberFormat
.formatter
- the NumberFormat
used to format the vector components withpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public Vector3i negate()
public Vector3i negate(Vector3i dest)
Vector3ic
dest
.public Vector3ic toImmutable()
Vector3i
.
The observable state of the returned object is the same as that of this
, but casting
the returned object to Vector3i will not be possible.
This method allocates a new instance of a class implementing Vector3ic on every call.
Copyright © 2015–2016 JOML. All rights reserved.