public class Vec3f
extends java.lang.Object
Constructor and Description |
---|
Vec3f()
Creates a new instance of Vec3
|
Vec3f(float[] f)
Creates a new Vec3f object using the provided float [] as the underlying
values.
|
Vec3f(float x,
float y,
float z)
Creates an new Vec3f object using the provided float values
|
Modifier and Type | Method and Description |
---|---|
static Vec3f |
convertPixel(int pixel)
Converts a 32 bit pixel value with RGB in the lower 24 bits to a Vec3f
object
|
Vec3f |
cross(Vec3f v)
Returns the cross product of this Vec3f and the Vec3f provided to the
method
|
Vec3f |
diff(Vec3f v)
Returns the difference of two vectors.
|
float |
dot(Vec3f vector)
Returns the dot product of this Vec3f and the Vec3f provided to the
method
|
boolean |
equals(Vec3f that)
Returns true if this vector is the same as the provided vector
|
float |
len()
Returns the length of the Vec3f vector
|
Vec3f |
normalize()
Normalizes the vector.
|
void |
perturb()
Perturbs the normal slightly
|
static Vec3f |
reflect(Vec3f normal,
Vec3f incedent)
Returns a vector representing the reflection of the provided incedent
vector.
|
Vec3f |
scale(float s)
Scales this vector by the provided float value
|
Vec3f |
sum(Vec3f v)
Adds two Vec3f objects together
|
float[] |
toFloat()
Returns the underlying float array for the Vec3f object.
|
int |
toPixel()
Returns a representation of this vector as a colored pixel value, with
RGB in the lower 24 bits.
|
java.lang.String |
toString()
Returns a string representation of this vector.
|
float |
x()
Returns the x component of the vector (x,y,z)
|
void |
x(float f)
Sets the x component of the vector (x,y,z) to the provided value
|
float |
y()
Returns the y component of the vector (x,y,z)
|
void |
y(float f)
Sets the y component of the vector (x,y,z) to the provided value
|
float |
z()
Returns the z component of the vector (x,y,z)
|
void |
z(float f)
Sets the z component of the vector (x,y,z) to the provided value
|
public Vec3f()
public Vec3f(float x, float y, float z)
x
- first float valuey
- second float valuez
- third float valuepublic Vec3f(float[] f)
f
- an array of 3 float values.public static Vec3f convertPixel(int pixel)
pixel
- the 32 bit pixel valuepublic static Vec3f reflect(Vec3f normal, Vec3f incedent)
normal
- The normal vector for the particular poiont.incedent
- The vector representing incedent light.public Vec3f cross(Vec3f v)
v
- The Vec3f object representing the right-hand side of the cross
productpublic Vec3f diff(Vec3f v)
v
- The vector representing the right-hand side of the difference.public float dot(Vec3f vector)
vector
- The Vec3f object representing the right-hand side of the
dot productpublic boolean equals(Vec3f that)
that
- The vector to be compared with this vectorpublic float len()
public Vec3f normalize()
public void perturb()
public Vec3f scale(float s)
s
- the amount by which each component of the vector is multipliedpublic Vec3f sum(Vec3f v)
v
- The vector to which this vector will be addedpublic float[] toFloat()
public int toPixel()
public java.lang.String toString()
toString
in class java.lang.Object
public float x()
public void x(float f)
f
- the x component of the vector (x,y,z)public float y()
public void y(float f)
f
- the y component of the vector (x,y,z)public float z()
public void z(float f)
f
- the z component of the vector (x,y,z)