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

2D Vector based upon two float components. More...

Collaboration diagram for com.jogamp.math.Vec2f:

Public Member Functions

 Vec2f ()
 
 Vec2f (final Vec2f o)
 
 Vec2f (final Vec2i o)
 
 Vec2f (final Vec3f o)
 Creating new Vec2f using Vec3f, dropping z. More...
 
Vec2f copy ()
 
 Vec2f (final float[] xy)
 
 Vec2f (final float x, final float y)
 
void set (final Vec2f o)
 this = o, returns this. More...
 
void set (final Vec2i o)
 this = o (int -> float), returns this. More...
 
void set (final Vec3f o)
 this = o while dropping z, returns this. More...
 
void set (final float x, final float y)
 this = { x, y }, returns this. More...
 
Vec2f set (final float[] xy)
 this = xy, returns this. More...
 
Vec2f toArray (final float[] xy)
 xy[0..1] = this. More...
 
void set (final int i, final float val)
 Sets the ith component, 0 <= i < 2. More...
 
float[] get (final float[] xy)
 xy = this, returns xy. More...
 
float get (final int i)
 Gets the ith component, 0 <= i < 2. More...
 
float x ()
 
float y ()
 
void setX (final float x)
 
void setY (final float y)
 
Vec2f max (final Vec2f m)
 this = max(this, m), returns this. More...
 
Vec2f min (final Vec2f m)
 this = min(this, m), returns this. More...
 
Vec2f mul (final float val)
 Returns this * val; creates new vector. More...
 
Vec2f mul (final Vec2f a, final Vec2f b)
 this = a * b, returns this. More...
 
Vec2f mul (final Vec2f s)
 this = this * s, returns this. More...
 
Vec2f mul (final float sx, final float sy)
 this = this * { sx, sy }, returns this. More...
 
Vec2f div (final Vec2f a, final Vec2f b)
 this = a / b, returns this. More...
 
Vec2f div (final Vec2f a)
 this = this / a, returns this. More...
 
Vec2f scale (final float s)
 this = this * s, returns this. More...
 
Vec2f plus (final Vec2f arg)
 Returns this + arg; creates new vector. More...
 
Vec2f plus (final Vec2f a, final Vec2f b)
 this = a + b, returns this. More...
 
Vec2f add (final float dx, final float dy)
 this = this + { dx, dy }, returns this. More...
 
Vec2f add (final Vec2f b)
 this = this + b, returns this. More...
 
Vec2f minus (final Vec2f arg)
 Returns this - arg; creates new vector. More...
 
Vec2f minus (final Vec2f a, final Vec2f b)
 this = a - b, returns this. More...
 
Vec2f sub (final Vec2f b)
 this = this - b, returns this. More...
 
boolean isZero ()
 Return true if all components are zero, i.e. More...
 
void rotate (final float radians, final Vec2f ctr)
 
void rotate (final float sin, final float cos, final Vec2f ctr)
 
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...
 
float angle ()
 Return the direction angle of this vector in radians. More...
 
Vec2f normalize ()
 Normalize this vector in place. More...
 
float distSq (final Vec2f o)
 Return the squared distance between this vector and the given one. More...
 
float dist (final Vec2f o)
 Return the distance between this vector and the given one. More...
 
float dot (final Vec2f arg)
 Return the dot product of this vector and the given one. More...
 
float cross (final Vec2f o)
 Returns cross product of this vectors and the given one, i.e. More...
 
float cosAngle (final Vec2f o)
 Return the cosines of the angle between two vectors. More...
 
float angle (final Vec2f o)
 Return the angle between two vectors in radians. More...
 
Vec2f normal_ccw ()
 Return the counter-clock-wise (CCW) normal of this vector, i.e. More...
 
boolean isEqual (final Vec2f o, final float epsilon)
 Equals check using a given FloatUtil#EPSILON value and FloatUtil#isEqual(float, float, float). More...
 
boolean isEqual (final Vec2f o)
 Equals check using FloatUtil#EPSILON in FloatUtil#isEqual(float, float). More...
 
boolean equals (final Object o)
 
String toString ()
 

Static Public Member Functions

static Vec2f from_length_angle (final float magnitude, final float radians)
 

Detailed Description

2D Vector based upon two float components.

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

Definition at line 37 of file Vec2f.java.

Constructor & Destructor Documentation

◆ Vec2f() [1/6]

com.jogamp.math.Vec2f.Vec2f ( )

Definition at line 45 of file Vec2f.java.

Here is the caller graph for this function:

◆ Vec2f() [2/6]

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

Definition at line 47 of file Vec2f.java.

◆ Vec2f() [3/6]

com.jogamp.math.Vec2f.Vec2f ( final Vec2i  o)

Definition at line 51 of file Vec2f.java.

◆ Vec2f() [4/6]

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

Creating new Vec2f using Vec3f, dropping z.

Definition at line 56 of file Vec2f.java.

◆ Vec2f() [5/6]

com.jogamp.math.Vec2f.Vec2f ( final float[]  xy)

Definition at line 64 of file Vec2f.java.

◆ Vec2f() [6/6]

com.jogamp.math.Vec2f.Vec2f ( final float  x,
final float  y 
)

Definition at line 68 of file Vec2f.java.

Member Function Documentation

◆ add() [1/2]

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

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

Definition at line 210 of file Vec2f.java.

◆ add() [2/2]

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

this = this + b, returns this.

Definition at line 217 of file Vec2f.java.

◆ angle() [1/2]

float com.jogamp.math.Vec2f.angle ( )

Return the direction angle of this vector in radians.

Definition at line 278 of file Vec2f.java.

◆ angle() [2/2]

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

Return the angle between two vectors in radians.

Definition at line 349 of file Vec2f.java.

Here is the call graph for this function:

◆ copy()

Vec2f com.jogamp.math.Vec2f.copy ( )

Definition at line 60 of file Vec2f.java.

Here is the call graph for this function:

◆ cosAngle()

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

Return the cosines of the angle between two vectors.

Definition at line 342 of file Vec2f.java.

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

◆ cross()

float com.jogamp.math.Vec2f.cross ( final Vec2f  o)

Returns cross product of this vectors and the given one, i.e.

*this x o.

The 2D cross product is identical with the 2D perp dot product.

Returns
the resulting scalar

Definition at line 335 of file Vec2f.java.

Here is the caller graph for this function:

◆ dist()

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

Return the distance between this vector and the given one.

Definition at line 315 of file Vec2f.java.

Here is the call graph for this function:

◆ distSq()

float com.jogamp.math.Vec2f.distSq ( final Vec2f  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 306 of file Vec2f.java.

Here is the caller graph for this function:

◆ div() [1/2]

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

this = this / a, returns this.

Definition at line 184 of file Vec2f.java.

◆ div() [2/2]

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

this = a / b, returns this.

Definition at line 177 of file Vec2f.java.

◆ dot()

float com.jogamp.math.Vec2f.dot ( final Vec2f  arg)

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

Returns
the dot product as float

Definition at line 324 of file Vec2f.java.

Here is the caller graph for this function:

◆ equals()

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

Definition at line 404 of file Vec2f.java.

Here is the call graph for this function:

◆ from_length_angle()

static Vec2f com.jogamp.math.Vec2f.from_length_angle ( final float  magnitude,
final float  radians 
)
static

Definition at line 41 of file Vec2f.java.

Here is the call graph for this function:

◆ get() [1/2]

float[] com.jogamp.math.Vec2f.get ( final float[]  xy)

xy = this, returns xy.

Definition at line 120 of file Vec2f.java.

◆ get() [2/2]

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

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

Definition at line 127 of file Vec2f.java.

◆ isEqual() [1/2]

boolean com.jogamp.math.Vec2f.isEqual ( final Vec2f  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 394 of file Vec2f.java.

Here is the call graph for this function:

◆ isEqual() [2/2]

boolean com.jogamp.math.Vec2f.isEqual ( final Vec2f  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 373 of file Vec2f.java.

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

◆ isZero()

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

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

it's absolute value < EPSILON.

Definition at line 243 of file Vec2f.java.

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

◆ length()

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

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

Definition at line 264 of file Vec2f.java.

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

◆ lengthSq()

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

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

Definition at line 271 of file Vec2f.java.

Here is the caller graph for this function:

◆ max()

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

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

Definition at line 142 of file Vec2f.java.

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

◆ min()

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

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

Definition at line 148 of file Vec2f.java.

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

◆ minus() [1/2]

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

this = a - b, returns this.

Definition at line 229 of file Vec2f.java.

◆ minus() [2/2]

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

Returns this - arg; creates new vector.

Definition at line 224 of file Vec2f.java.

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

◆ mul() [1/4]

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

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

Definition at line 170 of file Vec2f.java.

◆ mul() [2/4]

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

Returns this * val; creates new vector.

Definition at line 155 of file Vec2f.java.

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

◆ mul() [3/4]

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

this = a * b, returns this.

Definition at line 160 of file Vec2f.java.

◆ mul() [4/4]

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

this = this * s, returns this.

Definition at line 167 of file Vec2f.java.

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

◆ normal_ccw()

Vec2f com.jogamp.math.Vec2f.normal_ccw ( )

Return the counter-clock-wise (CCW) normal of this vector, i.e.

perp(endicular) vector

Definition at line 356 of file Vec2f.java.

Here is the call graph for this function:

◆ normalize()

Vec2f com.jogamp.math.Vec2f.normalize ( )

Normalize this vector in place.

Definition at line 286 of file Vec2f.java.

Here is the call graph for this function:

◆ plus() [1/2]

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

this = a + b, returns this.

Definition at line 203 of file Vec2f.java.

◆ plus() [2/2]

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

Returns this + arg; creates new vector.

Definition at line 198 of file Vec2f.java.

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

◆ rotate() [1/2]

void com.jogamp.math.Vec2f.rotate ( final float  radians,
final Vec2f  ctr 
)

Definition at line 247 of file Vec2f.java.

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

◆ rotate() [2/2]

void com.jogamp.math.Vec2f.rotate ( final float  sin,
final float  cos,
final Vec2f  ctr 
)

Definition at line 253 of file Vec2f.java.

◆ scale()

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

this = this * s, returns this.

Definition at line 191 of file Vec2f.java.

◆ set() [1/6]

void com.jogamp.math.Vec2f.set ( final float  x,
final float  y 
)

this = { x, y }, returns this.

Definition at line 91 of file Vec2f.java.

◆ set() [2/6]

Vec2f com.jogamp.math.Vec2f.set ( final float[]  xy)

this = xy, returns this.

Definition at line 97 of file Vec2f.java.

◆ set() [3/6]

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

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

Definition at line 111 of file Vec2f.java.

◆ set() [4/6]

void com.jogamp.math.Vec2f.set ( final Vec2f  o)

this = o, returns this.

Definition at line 73 of file Vec2f.java.

Here is the caller graph for this function:

◆ set() [5/6]

void com.jogamp.math.Vec2f.set ( final Vec2i  o)

this = o (int -> float), returns this.

Definition at line 79 of file Vec2f.java.

◆ set() [6/6]

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

this = o while dropping z, returns this.

Definition at line 85 of file Vec2f.java.

◆ setX()

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

Definition at line 138 of file Vec2f.java.

Here is the caller graph for this function:

◆ setY()

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

Definition at line 139 of file Vec2f.java.

Here is the caller graph for this function:

◆ sub()

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

this = this - b, returns this.

Definition at line 236 of file Vec2f.java.

◆ toArray()

Vec2f com.jogamp.math.Vec2f.toArray ( final float[]  xy)

xy[0..1] = this.

{x, y}, returns this.

Definition at line 104 of file Vec2f.java.

◆ toString()

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

Definition at line 413 of file Vec2f.java.

◆ x()

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

Definition at line 135 of file Vec2f.java.

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

◆ y()

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

Definition at line 136 of file Vec2f.java.

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

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