|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.instantreality.InstantIO.Vec4f
public class Vec4f
Helper class for exchanging vectors of four float components.
Vec4f is a basic helper class for exchanging vectors of four
float components between different software components. It does
not contain any means for vector arithmetics, only methods for
setting and getting the components. It is not meant to be used
directly by software components for vector representation. Instead,
software components should use their own, appropriate classes for
handling vectors. Only when sending vectors to an OutSlot
,
or when receiving vectors from an InSlot
, the internal
representation of vectors should be converted to Vec4f's. This
ensures the interoperability between different software components
that use different internal representations for vectors.
The following example creates a Vec4f object and prints its components to the console:
Vec4f vec = new Vec4f(1.0f, 2.0f, 3.0f, 4.0f); System.out.println("x component = " + vec.getX()); System.out.println("y component = " + vec.getY()); System.out.println("z component = " + vec.getZ()); System.out.println("w component = " + vec.getW());
Field Summary | |
---|---|
static Vec4f |
NULL
The null vector <0,0,0,0>. |
Constructor Summary | |
---|---|
Vec4f(float[] vec)
Constructor that initializes the components of the Vec4f object with the values of a given float array. |
|
Vec4f(float x,
float y,
float z,
float w)
Constructor that initializes the components of the Vec4f object with the given float values. |
|
Vec4f(Vec4f vec)
Constructor that initializes the components of the Vec4f object with the components taken from another Vec4f object. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object obj)
Compares the vector to another object. |
void |
get(float[] vec)
Returns the values of the x, y, z and w components. |
float |
getW()
Returns the value of the w component. |
float |
getX()
Returns the value of the x component. |
float |
getY()
Returns the value of the y component. |
float |
getZ()
Returns the value of the z component. |
java.lang.String |
toString()
Converts the vector to a string. |
static Vec4f |
valueOf(java.lang.String str)
Converts a string to a Vec4f object. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Vec4f NULL
Constructor Detail |
---|
public Vec4f(float x, float y, float z, float w)
The following example demonstrates how to create a Vec4f object:
float x_component = 1.0f; float y_component = 2.0f; float z_component = 3.0f; float w_component = 4.0f; Vec4f vec = new Vec4f(x_component, y_component, z_component, w_component);
x
- Value of the x component of the new vector.y
- Value of the y component of the new vector.z
- Value of the z component of the new vector.w
- Value of the w component of the new vector.public Vec4f(float[] vec)
The following example demonstrates how to create a Vec4f object:
float x_component = 1.0f; float y_component = 2.0f; float z_component = 3.0f; float w_component = 4.0f; float[] vector_components = new float[] { x_component, y_component, z_component, w_component }; Vec4f vec = new Vec4f(vector_components);
vec
- An array of at least four float values. The x component
of the vector is set to the value of the first element of the array,
the y component is set to the value of the second element of the
array, the z component is set to the value of the third element of the
array, and the w component is set to the value of the fourth element
of the array.public Vec4f(Vec4f vec)
The following example demonstrates how to create a Vec4f object that is an exact copy of another Vec4f object:
Vec4f given_vec = ...; Vec4f vec = new Vec4f(given_vec);
vec
- The other vector used to initialize the new vector.Method Detail |
---|
public final float getX()
The following example demonstrates how to print the x component of a Vec4f object to the console:
Vec4f vec = ...; System.out.println("x component = " + vec.getX());
public final float getY()
The following example demonstrates how to print the y component of a Vec4f object to the console:
Vec4f vec = ...; System.out.println("y component = " + vec.getY());
public final float getZ()
The following example demonstrates how to print the z component of a Vec4f object to the console:
Vec4f vec = ...; System.out.println("z component = " + vec.getZ());
public final float getW()
The following example demonstrates how to print the w component of a Vec4f object to the console:
Vec4f vec = ...; System.out.println("w component = " + vec.getW());
public final void get(float[] vec)
The following example prints the components of a Vec4f object to the console:
Vec4f vec = ...; float[] vector_components = new float[4]; vec.get(vector_components); System.out.println("x component = " + vector_components[0]); System.out.println("y component = " + vector_components[1]); System.out.println("z component = " + vector_components[2]); System.out.println("w component = " + vector_components[3]);
vec
- A float array that gets filled with the components of the
vector. This array must have at least four elements. The first
element of the array is set to the x component of the vector, the
second element of the array is set to the y component of the vector,
the third element of the array is set to the z component of the
vector, and the fourth element of the array is set to the w
component of the vector.public final boolean equals(java.lang.Object obj)
The following example compares two vectors and prints the result to the console:
Vec4f vec1 = ...; Vec4f vec2 = ...; System.out.println("Vectors are the same: " + vec1.equals(vec2));
equals
in class java.lang.Object
obj
- the object to compare the vector to
public final java.lang.String toString()
The following example prints the string representation of a Vec4f object to the console:
Vec4f vec = ...; System.out.println("Vector = " + vec.toString());
toString
in class java.lang.Object
public static final Vec4f valueOf(java.lang.String str)
The following example creates a new Vec4f object:
Vec4f vec = Vec4f.valueOf("1.0 2.0 3.0 4.0");
str
- The string representation of the vector.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |