Package com.jogamp.opengl.math
Class Vec4f
- java.lang.Object
-
- com.jogamp.opengl.math.Vec4f
-
public final class Vec4f extends Object
4D Vector based upon four float components. Implementation borrowed from [gfxbox2](https://jausoft.com/cgit/cs_class/gfxbox2.git/tree/include/pixel/pixel3f.hpp#n29) and its data layout from JOAL's Vec3f.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vec4fadd(float dx, float dy, float dz, float dw)this = this + { dx, dy, dz, dw }, returns this.Vec4fadd(Vec4f b)this = this + b, returns this.floatangle(Vec4f o)Return the angle between two vectors in radiansVec4fcopy()floatcosAngle(Vec4f o)Return the cosines of the angle between two vectorsfloatdist(Vec4f o)Return the distance between this vector and the given one.floatdistSq(Vec4f o)Return the squared distance between this vector and the given one.floatdot(Vec4f o)Return the dot product of this vector and the given onebooleanequals(Object o)float[]get(float[] xyzw)xyzw = this, returns xyzw.floatget(int i)Gets the ith component, 0 <= i < 4booleanisEqual(Vec4f o)Equals check usingFloatUtil.EPSILONvalue andFloatUtil.isEqual(float, float, float).booleanisEqual(Vec4f o, float epsilon)Equals check using a givenFloatUtil.EPSILONvalue andFloatUtil.isEqual(float, float, float).booleanisZero()Return true if all components are zero, i.e.floatlength()Return the length of this vector, a.k.a the norm or magnitudefloatlengthSq()Return the squared length of this vector, a.k.a the squared norm or squared magnitudeVec4fmax(Vec4f m)this = max(this, m), returns this.Vec4fmin(Vec4f m)this = min(this, m), returns this.Vec4fminus(Vec4f arg)Returns this - arg; creates new vectorVec4fminus(Vec4f a, Vec4f b)this = a - b, returns this.Vec4fmul(float val)Returns this * val; creates new vectorVec4fmul(Vec4f a, Vec4f b)this = a * b, returns this.Vec4fnormalize()Normalize this vector in placeVec4fplus(Vec4f arg)Returns this + arg; creates new vectorVec4fplus(Vec4f a, Vec4f b)this = a + b, returns this.Vec4fscale(float s)this = this * s, returns this.Vec4fscale(float sx, float sy, float sz, float sw)this = this * { sx, sy, sz, sw }, returns this.Vec4fset(float[] xyzw)this = xyzw, returns this.Vec4fset(float x, float y, float z, float w)this = { x, y, z, w }, returns this.voidset(int i, float val)Sets the ith component, 0 <= i < 4Vec4fset(Vec3f o, float w)this = { o, w }, returns this.Vec4fset(Vec4f o)this = o, returns this.voidsetW(float w)voidsetX(float x)voidsetY(float y)voidsetZ(float z)Vec4fsub(Vec4f b)this = this - b, returns this.StringtoString()floatw()floatx()floaty()floatz()
-
-
-
Method Detail
-
copy
public Vec4f copy()
-
set
public Vec4f set(float x, float y, float z, float w)
this = { x, y, z, w }, returns this.
-
set
public Vec4f set(float[] xyzw)
this = xyzw, returns this.
-
set
public void set(int i, float val)Sets the ith component, 0 <= i < 4
-
get
public float[] get(float[] xyzw)
xyzw = this, returns xyzw.
-
get
public float get(int i)
Gets the ith component, 0 <= i < 4
-
x
public float x()
-
y
public float y()
-
z
public float z()
-
w
public float w()
-
setX
public void setX(float x)
-
setY
public void setY(float y)
-
setZ
public void setZ(float z)
-
setW
public void setW(float w)
-
mul
public Vec4f mul(float val)
Returns this * val; creates new vector
-
scale
public Vec4f scale(float s)
this = this * s, returns this.
-
scale
public Vec4f scale(float sx, float sy, float sz, float sw)
this = this * { sx, sy, sz, sw }, returns this.
-
add
public Vec4f add(float dx, float dy, float dz, float dw)
this = this + { dx, dy, dz, dw }, returns this.
-
isZero
public boolean isZero()
Return true if all components are zero, i.e. it's absolute value <#EPSILON.
-
length
public float length()
Return the length of this vector, a.k.a the norm or magnitude
-
lengthSq
public float lengthSq()
Return the squared length of this vector, a.k.a the squared norm or squared magnitude
-
normalize
public Vec4f normalize()
Normalize this vector in place
-
distSq
public float distSq(Vec4f o)
Return the squared distance between this vector and the given one.When comparing the relative distance between two points it is usually sufficient to compare the squared distances, thus avoiding an expensive square root operation.
-
dist
public float dist(Vec4f o)
Return the distance between this vector and the given one.
-
dot
public float dot(Vec4f o)
Return the dot product of this vector and the given one- Returns:
- the dot product as float
-
cosAngle
public float cosAngle(Vec4f o)
Return the cosines of the angle between two vectors
-
angle
public float angle(Vec4f o)
Return the angle between two vectors in radians
-
isEqual
public boolean isEqual(Vec4f o, float epsilon)
Equals check using a givenFloatUtil.EPSILONvalue andFloatUtil.isEqual(float, float, float).Implementation considers following corner cases:
- NaN == NaN
- +Inf == +Inf
- -Inf == -Inf
- Parameters:
o- comparison valueepsilon- consider usingFloatUtil.EPSILON- Returns:
- true if all components differ less than
epsilon, otherwise false.
-
isEqual
public boolean isEqual(Vec4f o)
Equals check usingFloatUtil.EPSILONvalue andFloatUtil.isEqual(float, float, float).Implementation considers following corner cases:
- NaN == NaN
- +Inf == +Inf
- -Inf == -Inf
- Parameters:
o- comparison value- Returns:
- true if all components differ less than
FloatUtil.EPSILON, otherwise false.
-
-