Drag[en]gine Script Module DragonScript Script API  1.0
Vector2 Class Reference

Immutable 2-component vector. More...

Inheritance diagram for 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...
 
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 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...
 
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 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...
 
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.

Author
Roland Pl├╝ss
Version
1.0
Date
2015

Member Function Documentation

§ clamped()

Vector2 clamped ( Vector2  min,
Vector2  max 
)

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

§ equals()

bool 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 getComponentAt ( int  component)

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

§ getLength()

float getLength ( )

Length.

§ getX()

float getX ( )

X-Component.

§ getY()

float getY ( )

Y-Component.

§ hashCode()

int hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

§ isAtLeast()

bool isAtLeast ( float  value)

All coordinates are at least of a minimal value.

§ isAtMost()

bool isAtMost ( float  value)

All coordinates are at most of a maximal value.

§ isEqualTo()

bool isEqualTo ( Vector2  v,
float  delta 
)

Two vectors are equal.

§ largest()

Vector2 largest ( Vector2  v)

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

§ new() [1/3]

Vector2 new ( )

Create Vector2 with all components set to 0.

§ new() [2/3]

Vector2 new ( float  x,
float  y 
)

Create Vector2 using the specified components.

§ new() [3/3]

Vector2 new ( Vector2  v)

Create copy of a Vector2.

§ normalize()

Vector2 normalize ( )

Vector divided by length().

Exceptions
EDivisionByZeroLength is 0.

§ operator*() [1/2]

Vector2 operator* ( float  scalar)

Vector multiplied by scalar.

§ operator*() [2/2]

float operator* ( Vector2  v)

Dot-Product between two vectors.

§ operator+()

Vector2 operator+ ( Vector2  v)

Sum of two vectors.

§ operator-() [1/2]

Vector2 operator- ( )

Negated vector.

§ operator-() [2/2]

Vector2 operator- ( Vector2  v)

Difference between two vectors.

§ operator/()

Vector2 operator/ ( float  scalar)

Vector divided by scalar.

Exceptions
EDivisionByZeroscalar is 0.

§ operator<()

bool operator< ( Vector2  v)

Vector is less than another vector in all components.

§ operator<=()

bool operator<= ( Vector2  v)

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

§ operator>()

bool operator> ( Vector2  v)

Vector is greater than another vector in all components.

§ operator>=()

bool operator>= ( Vector2  v)

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

§ readFromFile()

static Vector2 readFromFile ( FileReader  reader)
static

Read vector from a file reader.

§ smallest()

Vector2 smallest ( Vector2  v)

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

§ toString()

String toString ( )

String representation of vector.

Implements Object.toString()

§ writeToFile()

void writeToFile ( FileWriter  writer)

Write vector to a file writer.


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