JOGL v2.6.0-rc-20250706
JOGL, High-Performance Graphics Binding for Java™ (public API).
com.jogamp.math.Vec3f Class Reference

3D Vector based upon three float components. More...

Collaboration diagram for com.jogamp.math.Vec3f:

Public Member Functions

 Vec3f ()
 
 Vec3f (final Vec3f o)
 
 Vec3f (final Vec4f o)
 Creating new Vec3f using Vec4f, dropping w. More...
 
 Vec3f (final Vec2f o, final float z)
 Creating new Vec3f using { Vec2f, z}. More...
 
Vec3f copy ()
 
 Vec3f (final float[] xyz)
 
 Vec3f (final float x, final float y, final float z)
 
Vec3f set (final Vec3f o)
 this = o, returns this. More...
 
Vec3f set (final Vec2f o, final float z)
 this = { o, z }, returns this. More...
 
Vec3f set (final Vec4f o)
 this = o while dropping w, returns this. More...
 
Vec3f set (final float x, final float y, final float z)
 this = { x, y, z }, returns this. More...
 
Vec3f set (final float[] xyz)
 this = xyz, returns this. More...
 
Vec3f toArray (final float[] xyz)
 xyz[0..2] = this. More...
 
void set (final int i, final float val)
 Sets the ith component, 0 <= i < 3. More...
 
float[] get (final float[] xyz)
 xyz = this, returns xyz. More...
 
float get (final int i)
 Gets the ith component, 0 <= i < 3. More...
 
float x ()
 
float y ()
 
float z ()
 
void setX (final float x)
 
void setY (final float y)
 
void setZ (final float z)
 
Vec3f max (final Vec3f m)
 this = max(this, m), returns this. More...
 
Vec3f min (final Vec3f m)
 this = min(this, m), returns this. More...
 
Vec3f mul (final float val)
 Returns this * val; creates new vector. More...
 
Vec3f mul (final Vec3f a, final Vec3f b)
 this = a * b, returns this. More...
 
Vec3f mul (final Vec3f s)
 this = this * s, returns this. More...
 
Vec3f mul (final float sx, final float sy, final float sz)
 this = this * { sx, sy, sz }, returns this. More...
 
Vec3f div (final Vec3f a, final Vec3f b)
 this = a / b, returns this. More...
 
Vec3f div (final Vec3f a)
 this = this / a, returns this. More...
 
Vec3f scale (final float s)
 this = this * s, returns this. More...
 
Vec3f plus (final Vec3f arg)
 Returns this + arg; creates new vector. More...
 
Vec3f plus (final Vec3f a, final Vec3f b)
 this = a + b, returns this. More...
 
Vec3f add (final float dx, final float dy, final float dz)
 this = this + { dx, dy, dz }, returns this. More...
 
Vec3f add (final Vec3f b)
 this = this + b, returns this. More...
 
Vec3f minus (final Vec3f arg)
 Returns this - arg; creates new vector. More...
 
Vec3f minus (final Vec3f a, final Vec3f b)
 this = a - b, returns this. More...
 
Vec3f sub (final Vec3f b)
 this = this - b, returns this. More...
 
boolean isZero ()
 Return true if all components are zero, i.e. More...
 
float length ()
 Return the length of this vector, a.k.a the norm or magnitude More...
 
float lengthSq ()
 Return the squared length of this vector, a.k.a the squared norm or squared magnitude More...
 
Vec3f normalize ()
 Normalize this vector in place. More...
 
float distSq (final Vec3f o)
 Return the squared distance between this vector and the given one. More...
 
float dist (final Vec3f o)
 Return the distance between this vector and the given one. More...
 
float dot (final Vec3f o)
 Return the dot product of this vector and the given one. More...
 
Vec3f cross (final Vec3f arg)
 Returns this cross arg; creates new vector. More...
 
Vec3f cross (final Vec3f a, final Vec3f b)
 this = a cross b. More...
 
float cosAngle (final Vec3f o)
 Return the cosine of the angle between two vectors using dot(Vec3f). More...
 
float angle (final Vec3f o)
 Return the angle between two vectors in radians using Math#acos(double) on cosAngle(Vec3f). More...
 
boolean isEqual (final Vec3f o, final float epsilon)
 Equals check using a given FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float). More...
 
boolean isEqual (final Vec3f o)
 Equals check using FloatUtil#EPSILON in FloatUtil#isEqual(float, float). More...
 
boolean equals (final Object o)
 
String toString ()
 

Static Public Attributes

static final Vec3f ONE = new Vec3f(1f, 1f, 1f)
 
static final Vec3f UNIT_X = new Vec3f(1f, 0f, 0f)
 
static final Vec3f UNIT_X_NEG = new Vec3f(-1f, 0f, 0f)
 
static final Vec3f UNIT_Y = new Vec3f(0f, 1f, 0f)
 
static final Vec3f UNIT_Y_NEG = new Vec3f(0f, -1f, 0f)
 
static final Vec3f UNIT_Z = new Vec3f(0f, 0f, 1f)
 
static final Vec3f UNIT_Z_NEG = new Vec3f(0f, 0f, -1f)
 

Detailed Description

3D Vector based upon three float components.

Implementation borrowed from gfxbox2 and its data layout from JOAL's Vec3f.

Definition at line 37 of file Vec3f.java.

Constructor & Destructor Documentation

◆ Vec3f() [1/6]

com.jogamp.math.Vec3f.Vec3f ( )

Definition at line 50 of file Vec3f.java.

Here is the caller graph for this function:

◆ Vec3f() [2/6]

com.jogamp.math.Vec3f.Vec3f ( final Vec3f  o)

Definition at line 52 of file Vec3f.java.

◆ Vec3f() [3/6]

com.jogamp.math.Vec3f.Vec3f ( final Vec4f  o)

Creating new Vec3f using Vec4f, dropping w.

Definition at line 57 of file Vec3f.java.

◆ Vec3f() [4/6]

com.jogamp.math.Vec3f.Vec3f ( final Vec2f  o,
final float  z 
)

Creating new Vec3f using { Vec2f, z}.

Definition at line 62 of file Vec3f.java.

◆ Vec3f() [5/6]

com.jogamp.math.Vec3f.Vec3f ( final float[]  xyz)

Definition at line 70 of file Vec3f.java.

◆ Vec3f() [6/6]

com.jogamp.math.Vec3f.Vec3f ( final float  x,
final float  y,
final float  z 
)

Definition at line 74 of file Vec3f.java.

Member Function Documentation

◆ add() [1/2]

Vec3f com.jogamp.math.Vec3f.add ( final float  dx,
final float  dy,
final float  dz 
)

this = this + { dx, dy, dz }, returns this.

Definition at line 239 of file Vec3f.java.

Here is the caller graph for this function:

◆ add() [2/2]

Vec3f com.jogamp.math.Vec3f.add ( final Vec3f  b)

this = this + b, returns this.

Definition at line 247 of file Vec3f.java.

◆ angle()

float com.jogamp.math.Vec3f.angle ( final Vec3f  o)

Return the angle between two vectors in radians using Math#acos(double) on cosAngle(Vec3f).

Definition at line 366 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy()

Vec3f com.jogamp.math.Vec3f.copy ( )

Definition at line 66 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cosAngle()

float com.jogamp.math.Vec3f.cosAngle ( final Vec3f  o)

Return the cosine of the angle between two vectors using dot(Vec3f).

Definition at line 359 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cross() [1/2]

Vec3f com.jogamp.math.Vec3f.cross ( final Vec3f  a,
final Vec3f  b 
)

this = a cross b.

NOTE: "this" must be a different vector than both a and b.

Definition at line 349 of file Vec3f.java.

◆ cross() [2/2]

Vec3f com.jogamp.math.Vec3f.cross ( final Vec3f  arg)

Returns this cross arg; creates new vector.

Definition at line 343 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dist()

float com.jogamp.math.Vec3f.dist ( final Vec3f  o)

Return the distance between this vector and the given one.

Definition at line 329 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ distSq()

float com.jogamp.math.Vec3f.distSq ( final Vec3f  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.

Definition at line 319 of file Vec3f.java.

Here is the caller graph for this function:

◆ div() [1/2]

Vec3f com.jogamp.math.Vec3f.div ( final Vec3f  a)

this = this / a, returns this.

Definition at line 210 of file Vec3f.java.

◆ div() [2/2]

Vec3f com.jogamp.math.Vec3f.div ( final Vec3f  a,
final Vec3f  b 
)

this = a / b, returns this.

Definition at line 202 of file Vec3f.java.

◆ dot()

float com.jogamp.math.Vec3f.dot ( final Vec3f  o)

Return the dot product of this vector and the given one.

Returns
the dot product as float

Definition at line 338 of file Vec3f.java.

Here is the caller graph for this function:

◆ equals()

boolean com.jogamp.math.Vec3f.equals ( final Object  o)

Definition at line 416 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [1/2]

float[] com.jogamp.math.Vec3f.get ( final float[]  xyz)

xyz = this, returns xyz.

Definition at line 137 of file Vec3f.java.

Here is the caller graph for this function:

◆ get() [2/2]

float com.jogamp.math.Vec3f.get ( final int  i)

Gets the ith component, 0 <= i < 3.

Definition at line 145 of file Vec3f.java.

◆ isEqual() [1/2]

boolean com.jogamp.math.Vec3f.isEqual ( final Vec3f  o)

Equals check using FloatUtil#EPSILON in FloatUtil#isEqual(float, float).

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Parameters
ocomparison value
Returns
true if all components differ less than FloatUtil#EPSILON, otherwise false.

Definition at line 405 of file Vec3f.java.

Here is the call graph for this function:

◆ isEqual() [2/2]

boolean com.jogamp.math.Vec3f.isEqual ( final Vec3f  o,
final float  epsilon 
)

Equals check using a given FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float).

Implementation considers following corner cases:

  • NaN == NaN
  • +Inf == +Inf
  • -Inf == -Inf
Parameters
ocomparison value
epsilonconsider using FloatUtil#EPSILON
Returns
true if all components differ less than epsilon, otherwise false.

Definition at line 383 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isZero()

boolean com.jogamp.math.Vec3f.isZero ( )

Return true if all components are zero, i.e.

it's absolute value < EPSILON.

Definition at line 276 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ length()

float com.jogamp.math.Vec3f.length ( )

Return the length of this vector, a.k.a the norm or magnitude

Definition at line 283 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lengthSq()

float com.jogamp.math.Vec3f.lengthSq ( )

Return the squared length of this vector, a.k.a the squared norm or squared magnitude

Definition at line 290 of file Vec3f.java.

Here is the caller graph for this function:

◆ max()

Vec3f com.jogamp.math.Vec3f.max ( final Vec3f  m)

this = max(this, m), returns this.

Definition at line 163 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ min()

Vec3f com.jogamp.math.Vec3f.min ( final Vec3f  m)

this = min(this, m), returns this.

Definition at line 170 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ minus() [1/2]

Vec3f com.jogamp.math.Vec3f.minus ( final Vec3f  a,
final Vec3f  b 
)

this = a - b, returns this.

Definition at line 260 of file Vec3f.java.

◆ minus() [2/2]

Vec3f com.jogamp.math.Vec3f.minus ( final Vec3f  arg)

Returns this - arg; creates new vector.

Definition at line 255 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mul() [1/4]

Vec3f com.jogamp.math.Vec3f.mul ( final float  sx,
final float  sy,
final float  sz 
)

this = this * { sx, sy, sz }, returns this.

Definition at line 194 of file Vec3f.java.

◆ mul() [2/4]

Vec3f com.jogamp.math.Vec3f.mul ( final float  val)

Returns this * val; creates new vector.

Definition at line 178 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mul() [3/4]

Vec3f com.jogamp.math.Vec3f.mul ( final Vec3f  a,
final Vec3f  b 
)

this = a * b, returns this.

Definition at line 183 of file Vec3f.java.

◆ mul() [4/4]

Vec3f com.jogamp.math.Vec3f.mul ( final Vec3f  s)

this = this * s, returns this.

Definition at line 191 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize()

Vec3f com.jogamp.math.Vec3f.normalize ( )

Normalize this vector in place.

Definition at line 297 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ plus() [1/2]

Vec3f com.jogamp.math.Vec3f.plus ( final Vec3f  a,
final Vec3f  b 
)

this = a + b, returns this.

Definition at line 231 of file Vec3f.java.

◆ plus() [2/2]

Vec3f com.jogamp.math.Vec3f.plus ( final Vec3f  arg)

Returns this + arg; creates new vector.

Definition at line 226 of file Vec3f.java.

Here is the call graph for this function:

◆ scale()

Vec3f com.jogamp.math.Vec3f.scale ( final float  s)

this = this * s, returns this.

Definition at line 218 of file Vec3f.java.

Here is the caller graph for this function:

◆ set() [1/6]

Vec3f com.jogamp.math.Vec3f.set ( final float  x,
final float  y,
final float  z 
)

this = { x, y, z }, returns this.

Definition at line 103 of file Vec3f.java.

◆ set() [2/6]

Vec3f com.jogamp.math.Vec3f.set ( final float[]  xyz)

this = xyz, returns this.

Definition at line 111 of file Vec3f.java.

◆ set() [3/6]

void com.jogamp.math.Vec3f.set ( final int  i,
final float  val 
)

Sets the ith component, 0 <= i < 3.

Definition at line 127 of file Vec3f.java.

◆ set() [4/6]

Vec3f com.jogamp.math.Vec3f.set ( final Vec2f  o,
final float  z 
)

this = { o, z }, returns this.

Definition at line 87 of file Vec3f.java.

◆ set() [5/6]

Vec3f com.jogamp.math.Vec3f.set ( final Vec3f  o)

this = o, returns this.

Definition at line 79 of file Vec3f.java.

◆ set() [6/6]

Vec3f com.jogamp.math.Vec3f.set ( final Vec4f  o)

this = o while dropping w, returns this.

Definition at line 95 of file Vec3f.java.

◆ setX()

void com.jogamp.math.Vec3f.setX ( final float  x)

Definition at line 158 of file Vec3f.java.

Here is the caller graph for this function:

◆ setY()

void com.jogamp.math.Vec3f.setY ( final float  y)

Definition at line 159 of file Vec3f.java.

Here is the caller graph for this function:

◆ setZ()

void com.jogamp.math.Vec3f.setZ ( final float  z)

Definition at line 160 of file Vec3f.java.

Here is the caller graph for this function:

◆ sub()

Vec3f com.jogamp.math.Vec3f.sub ( final Vec3f  b)

this = this - b, returns this.

Definition at line 268 of file Vec3f.java.

Here is the caller graph for this function:

◆ toArray()

Vec3f com.jogamp.math.Vec3f.toArray ( final float[]  xyz)

xyz[0..2] = this.

{x, y, z}, returns this.

Definition at line 119 of file Vec3f.java.

◆ toString()

String com.jogamp.math.Vec3f.toString ( )

Definition at line 425 of file Vec3f.java.

◆ x()

float com.jogamp.math.Vec3f.x ( )

Definition at line 154 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ y()

float com.jogamp.math.Vec3f.y ( )

Definition at line 155 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ z()

float com.jogamp.math.Vec3f.z ( )

Definition at line 156 of file Vec3f.java.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ ONE

final Vec3f com.jogamp.math.Vec3f.ONE = new Vec3f(1f, 1f, 1f)
static

Definition at line 38 of file Vec3f.java.

◆ UNIT_X

final Vec3f com.jogamp.math.Vec3f.UNIT_X = new Vec3f(1f, 0f, 0f)
static

Definition at line 39 of file Vec3f.java.

◆ UNIT_X_NEG

final Vec3f com.jogamp.math.Vec3f.UNIT_X_NEG = new Vec3f(-1f, 0f, 0f)
static

Definition at line 40 of file Vec3f.java.

◆ UNIT_Y

final Vec3f com.jogamp.math.Vec3f.UNIT_Y = new Vec3f(0f, 1f, 0f)
static

Definition at line 41 of file Vec3f.java.

◆ UNIT_Y_NEG

final Vec3f com.jogamp.math.Vec3f.UNIT_Y_NEG = new Vec3f(0f, -1f, 0f)
static

Definition at line 42 of file Vec3f.java.

◆ UNIT_Z

final Vec3f com.jogamp.math.Vec3f.UNIT_Z = new Vec3f(0f, 0f, 1f)
static

Definition at line 43 of file Vec3f.java.

◆ UNIT_Z_NEG

final Vec3f com.jogamp.math.Vec3f.UNIT_Z_NEG = new Vec3f(0f, 0f, -1f)
static

Definition at line 44 of file Vec3f.java.


The documentation for this class was generated from the following file: