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

File Handling

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

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.

References getLength().

Referenced by round().

◆ clamped()

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

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

References normalize().

Referenced by mix().

◆ 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.

References mix().

Referenced by writeToFile().

◆ getComponentAt()

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

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

Referenced by getLength().

◆ getLength()

float Dragengine.Scenery.Vector2.getLength ( )

Length.

References getComponentAt(), and getY().

Referenced by absolute().

◆ getX()

float Dragengine.Scenery.Vector2.getX ( )

X-Component.

Referenced by getY().

◆ getY()

float Dragengine.Scenery.Vector2.getY ( )

Y-Component.

References getX().

Referenced by getLength().

◆ hashCode()

int Dragengine.Scenery.Vector2.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

References isEqualTo().

Referenced by operator+().

◆ isAtLeast()

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

All coordinates are at least of a minimal value.

References round().

Referenced by toString().

◆ isAtMost()

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

All coordinates are at most of a maximal value.

Referenced by toString().

◆ isEqualTo()

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

Two vectors are equal.

Referenced by hashCode().

◆ isZero()

bool Dragengine.Scenery.Vector2.isZero ( )

Vector is equal to zero vector.

References round().

Referenced by toString().

◆ largest()

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

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

Referenced by round().

◆ 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.

References clamped().

Referenced by equals().

◆ new() [1/4]

Vector2 Dragengine.Scenery.Vector2.new ( )

Create Vector2 with all components set to 0.

References new().

Referenced by new(), new(), new(), and new().

◆ new() [2/4]

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

Create Vector2 using the specified components.

References new().

◆ new() [3/4]

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

Create Vector2 from Point.

References new().

◆ new() [4/4]

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

Create copy of a Vector2.

References new().

◆ normalize()

Vector2 Dragengine.Scenery.Vector2.normalize ( )

Vector divided by length().

Exceptions
EDivisionByZeroLength is 0.

Referenced by clamped().

◆ operator*() [1/2]

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

Vector multiplied by scalar.

References toString().

◆ 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.

References hashCode().

◆ 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.

References toString().

◆ 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.

References readFromFile(), and writeToFile().

◆ readFromFile()

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

Read vector from a file reader.

Referenced by operator>=().

◆ round() [1/2]

Point Dragengine.Scenery.Vector2.round ( )

Convert to point rounding to the nearest integer value.

References absolute().

Referenced by isAtLeast(), and isZero().

◆ round() [2/2]

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

Components rounded to the nearest unit.

Version
1.8

References largest(), and smallest().

◆ smallest()

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

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

Referenced by round().

◆ toString() [1/2]

String Dragengine.Scenery.Vector2.toString ( )

String representation of vector.

Implements Object.toString()

References isAtLeast(), and isAtMost().

Referenced by operator*(), and operator<().

◆ 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.

References isZero().

◆ writeToFile()

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

Write vector to a file writer.

References equals().

Referenced by operator>=().


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