Drag[en]gine Script Module DragonScript  1.23
Dragengine.Scenery.Vector2 Class Reference

Immutable 2-component vector. More...

Inheritance diagram for Dragengine.Scenery.Vector2:

Public Member Functions

Constructors
Vector2 new ()
 Create Vector2 with all components set to 0. More...
 
Vector2 new (float x, float y)
 Create Vector2 using the specified components. More...
 
Vector2 new (Vector2 v)
 Create copy of a Vector2. More...
 
Vector2 new (Point p)
 Create Vector2 from Point. More...
 
Management
float getX ()
 X-Component. More...
 
float getY ()
 Y-Component. More...
 
float getComponentAt (int component)
 Component by index (0=X, 1=Y). More...
 
float getLength ()
 Length. More...
 
Vector2 normalize ()
 Vector divided by length(). More...
 
Vector2 absolute ()
 Vector with absolute of all components. More...
 
Vector2 smallest (Vector2 v)
 Vector with all components set to the smallest value of two vectors. More...
 
Vector2 largest (Vector2 v)
 Vector with all components set to the largest value of two vectors. More...
 
Vector2 clamped (Vector2 min, Vector2 max)
 Vector with all components clamped to a range of two vectors. More...
 
Point round ()
 Convert to point rounding to the nearest integer value. More...
 
Vector2 round (float unit)
 Components rounded to the nearest unit. More...
 
Vector2 mix (Vector2 other, float factor)
 Mix vector with another component wise. More...
 
bool isEqualTo (Vector2 v, float delta)
 Two vectors are equal. More...
 
bool isAtLeast (float value)
 All coordinates are at least of a minimal value. More...
 
bool isAtMost (float value)
 All coordinates are at most of a maximal value. More...
 
bool isZero ()
 Vector is equal to zero vector. More...
 
bool equals (Object other)
 Vector is equal to another object. More...
 
int hashCode ()
 Hash code for use as dictionary keys. More...
 
String toString ()
 String representation of vector. More...
 
String toString (int precision)
 String representation of vector with precision. More...
 
Operators
Vector2 operator- ()
 Negated vector. More...
 
Vector2 operator+ (Vector2 v)
 Sum of two vectors. More...
 
Vector2 operator- (Vector2 v)
 Difference between two vectors. More...
 
Vector2 operator* (float scalar)
 Vector multiplied by scalar. More...
 
Vector2 operator/ (float scalar)
 Vector divided by scalar. More...
 
float operator* (Vector2 v)
 Dot-Product between two vectors. More...
 
bool operator< (Vector2 v)
 Vector is less than another vector in all components. More...
 
bool operator<= (Vector2 v)
 Vector is less than or equal to another vector in all components. More...
 
bool operator> (Vector2 v)
 Vector is greater than another vector in all components. More...
 
bool operator>= (Vector2 v)
 Vector is greater than or equal to another vector in all components. More...
 

File Handling

void writeToFile (FileWriter writer)
 Write vector to a file writer. More...
 
static Vector2 readFromFile (FileReader reader)
 Read vector from a file reader. More...
 

Detailed Description

Immutable 2-component vector.

This is a native class. It can not be subclassed.

Member Function Documentation

◆ absolute()

Vector2 Dragengine.Scenery.Vector2.absolute ( )

Vector with absolute of all components.

◆ clamped()

Vector2 Dragengine.Scenery.Vector2.clamped ( Vector2  min,
Vector2  max 
)

Vector with all components clamped to a range of two vectors.

◆ equals()

bool Dragengine.Scenery.Vector2.equals ( Object  other)

Vector is equal to another object.

Implements Object.equals(Object).

Returns
true if other is of type Vector2 and components are equal.

◆ getComponentAt()

float Dragengine.Scenery.Vector2.getComponentAt ( int  component)

Component by index (0=X, 1=Y).

◆ getLength()

float Dragengine.Scenery.Vector2.getLength ( )

Length.

◆ getX()

float Dragengine.Scenery.Vector2.getX ( )

X-Component.

◆ getY()

float Dragengine.Scenery.Vector2.getY ( )

Y-Component.

◆ hashCode()

int Dragengine.Scenery.Vector2.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

◆ isAtLeast()

bool Dragengine.Scenery.Vector2.isAtLeast ( float  value)

All coordinates are at least of a minimal value.

◆ isAtMost()

bool Dragengine.Scenery.Vector2.isAtMost ( float  value)

All coordinates are at most of a maximal value.

◆ isEqualTo()

bool Dragengine.Scenery.Vector2.isEqualTo ( Vector2  v,
float  delta 
)

Two vectors are equal.

◆ isZero()

bool Dragengine.Scenery.Vector2.isZero ( )

Vector is equal to zero vector.

◆ largest()

Vector2 Dragengine.Scenery.Vector2.largest ( Vector2  v)

Vector with all components set to the largest value of two vectors.

◆ mix()

Vector2 Dragengine.Scenery.Vector2.mix ( Vector2  other,
float  factor 
)

Mix vector with another component wise.

Version
1.10

Factor 0 uses this vector, factor 1 the other vector.

◆ new() [1/4]

Vector2 Dragengine.Scenery.Vector2.new ( )

Create Vector2 with all components set to 0.

◆ new() [2/4]

Vector2 Dragengine.Scenery.Vector2.new ( float  x,
float  y 
)

Create Vector2 using the specified components.

◆ new() [3/4]

Vector2 Dragengine.Scenery.Vector2.new ( Point  p)

Create Vector2 from Point.

◆ new() [4/4]

Vector2 Dragengine.Scenery.Vector2.new ( Vector2  v)

Create copy of a Vector2.

◆ normalize()

Vector2 Dragengine.Scenery.Vector2.normalize ( )

Vector divided by length().

Exceptions
EDivisionByZeroLength is 0.

◆ operator*() [1/2]

Vector2 Dragengine.Scenery.Vector2.operator* ( float  scalar)

Vector multiplied by scalar.

◆ operator*() [2/2]

float Dragengine.Scenery.Vector2.operator* ( Vector2  v)

Dot-Product between two vectors.

◆ operator+()

Vector2 Dragengine.Scenery.Vector2.operator+ ( Vector2  v)

Sum of two vectors.

◆ operator-() [1/2]

Vector2 Dragengine.Scenery.Vector2.operator- ( )

Negated vector.

◆ operator-() [2/2]

Vector2 Dragengine.Scenery.Vector2.operator- ( Vector2  v)

Difference between two vectors.

◆ operator/()

Vector2 Dragengine.Scenery.Vector2.operator/ ( float  scalar)

Vector divided by scalar.

Exceptions
EDivisionByZeroscalar is 0.

◆ operator<()

bool Dragengine.Scenery.Vector2.operator< ( Vector2  v)

Vector is less than another vector in all components.

◆ operator<=()

bool Dragengine.Scenery.Vector2.operator<= ( Vector2  v)

Vector is less than or equal to another vector in all components.

◆ operator>()

bool Dragengine.Scenery.Vector2.operator> ( Vector2  v)

Vector is greater than another vector in all components.

◆ operator>=()

bool Dragengine.Scenery.Vector2.operator>= ( Vector2  v)

Vector is greater than or equal to another vector in all components.

◆ readFromFile()

static Vector2 Dragengine.Scenery.Vector2.readFromFile ( FileReader  reader)
static

Read vector from a file reader.

◆ round() [1/2]

Point Dragengine.Scenery.Vector2.round ( )

Convert to point rounding to the nearest integer value.

◆ round() [2/2]

Vector2 Dragengine.Scenery.Vector2.round ( float  unit)

Components rounded to the nearest unit.

Version
1.8

◆ smallest()

Vector2 Dragengine.Scenery.Vector2.smallest ( Vector2  v)

Vector with all components set to the smallest value of two vectors.

◆ toString() [1/2]

String Dragengine.Scenery.Vector2.toString ( )

String representation of vector.

Implements Object.toString()

◆ toString() [2/2]

String Dragengine.Scenery.Vector2.toString ( int  precision)

String representation of vector with precision.

Same as toString() except the count of digits of each component is precision.

Parameters
precisionPrecision in digits in the range from 0 to 9 inclusive.
Exceptions
EInvalidParamprecision is less than 0 or larger than 9.

◆ writeToFile()

void Dragengine.Scenery.Vector2.writeToFile ( FileWriter  writer)

Write vector to a file writer.


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