Drag[en]gine Script Module DragonScript 1.35
Loading...
Searching...
No Matches
Dragengine.Scenery.Vector Class Reference

Immutable 3-component double precision vector. More...

Inheritance diagram for Dragengine.Scenery.Vector:

Public Member Functions

Constructors
Vector new ()
 Create vector with all components set to 0.
Vector new (float x, float y, float z)
 Create vector using the specified components.
Vector new (Vector v)
 Create DVetor from Vector.
Management
float getX ()
 X-Component.
float getY ()
 Y-Component.
float getZ ()
 Z-Component.
float get (int component)
 Component (0=X, 1=Y, 2=Z).
float getLength ()
 Length.
float getLengthSquared ()
 Squared length.
Vector normalize ()
 Vector divided by length().
Vector absolute ()
 Vector with absolute value of each component.
Vector compMultiply (Vector v)
 Component wise multiplication.
Vector compDivide (Vector v)
 Component wise division.
Vector compSelect (bool x, bool y, bool z)
 Vector with components set to true copied while all others are set to 0.
Vector combine (Vector vector, bool x, bool y, bool z)
 Combine selected components of this vector with another.
Vector smallest (Vector v)
 Vector with all components set to the smallest value of two vectors.
Vector largest (Vector v)
 Vector with all components set to the largest value of two vectors.
Vector clamped (Vector min, Vector max)
 Vector with all components clamped to a range of two vectors.
Point3 round ()
 Components rounded to nearest integer value.
Vector round (float unit)
 Components rounded to the nearest unit.
Vector mix (Vector other, float factor)
 Mix vector with another component wise.
bool isEqualTo (Vector 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
Vector operator- ()
 Negated vector.
Vector operator+ (Vector v)
 Sum of two vectors.
Vector operator- (Vector v)
 Difference of two vectors.
Vector operator* (float scalar)
 Vector scaled by scalar.
Vector operator/ (float scalar)
 Vector with each component divided by a value.
float operator* (Vector v)
 Dot-Product between two vectors.
Vector operator% (Vector v)
 Cross-Product between two vectors.
bool operator< (Vector v)
 Vector is less than another vector in all components.
bool operator<= (Vector v)
 Vector is less than or equal to another vector in all components.
bool operator> (Vector v)
 Vector is greater than another vector in all components.
bool operator>= (Vector 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 Vector readFromFile (FileReader reader)
 Read vector from a file reader.

Detailed Description

Immutable 3-component double precision vector.

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

Member Function Documentation

◆ absolute()

Vector Dragengine.Scenery.Vector.absolute ( )

Vector with absolute value of each component.

Referenced by combine().

◆ clamped()

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

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

References compDivide().

Referenced by isAtMost().

◆ combine()

Vector Dragengine.Scenery.Vector.combine ( Vector vector,
bool x,
bool y,
bool z )

Combine selected components of this vector with another.

For each component use this vector if value is true otherwise use vector component.

References absolute().

Referenced by round().

◆ compDivide()

Vector Dragengine.Scenery.Vector.compDivide ( Vector v)

Component wise division.

Referenced by clamped().

◆ compMultiply()

Vector Dragengine.Scenery.Vector.compMultiply ( Vector v)

Component wise multiplication.

References getLengthSquared().

Referenced by largest().

◆ compSelect()

Vector Dragengine.Scenery.Vector.compSelect ( bool x,
bool y,
bool z )

Vector with components set to true copied while all others are set to 0.

References normalize().

Referenced by round().

◆ equals()

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

Vector is equal to another object.

Implements Object.equals(Object).

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

References round().

Referenced by operator-().

◆ get()

float Dragengine.Scenery.Vector.get ( int component)

Component (0=X, 1=Y, 2=Z).

Referenced by getLengthSquared().

◆ getLength()

float Dragengine.Scenery.Vector.getLength ( )

Length.

References getZ().

Referenced by normalize().

◆ getLengthSquared()

float Dragengine.Scenery.Vector.getLengthSquared ( )

Squared length.

References get().

Referenced by compMultiply().

◆ getX()

float Dragengine.Scenery.Vector.getX ( )

X-Component.

Referenced by getY().

◆ getY()

float Dragengine.Scenery.Vector.getY ( )

Y-Component.

References getX().

Referenced by getZ().

◆ getZ()

float Dragengine.Scenery.Vector.getZ ( )

Z-Component.

References getY().

Referenced by getLength().

◆ hashCode()

int Dragengine.Scenery.Vector.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

Referenced by operator*().

◆ isAtLeast()

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

All coordinates are at least of a minimal value.

Referenced by toString().

◆ isAtMost()

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

All coordinates are at most of a maximal value.

References clamped().

Referenced by readFromFile().

◆ isEqualTo()

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

Two vectors are equal.

References largest().

Referenced by toString().

◆ isZero()

bool Dragengine.Scenery.Vector.isZero ( )

Vector is equal to zero vector.

References round().

Referenced by writeToFile().

◆ largest()

Vector Dragengine.Scenery.Vector.largest ( Vector v)

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

References compMultiply().

Referenced by isEqualTo().

◆ mix()

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

Mix vector with another component wise.

Version
1.10

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

References smallest().

Referenced by toString().

◆ new() [1/3]

Vector Dragengine.Scenery.Vector.new ( )

Create vector with all components set to 0.

References new().

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

◆ new() [2/3]

Vector Dragengine.Scenery.Vector.new ( float x,
float y,
float z )

Create vector using the specified components.

References new().

◆ new() [3/3]

Vector Dragengine.Scenery.Vector.new ( Vector v)

Create DVetor from Vector.

References new().

◆ normalize()

Vector Dragengine.Scenery.Vector.normalize ( )

Vector divided by length().

Exceptions
EDivisionByZeroLength is 0.

References getLength().

Referenced by compSelect().

◆ operator%()

Vector Dragengine.Scenery.Vector.operator% ( Vector v)

Cross-Product between two vectors.

References toString().

◆ operator*() [1/2]

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

Vector scaled by scalar.

References hashCode().

◆ operator*() [2/2]

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

Dot-Product between two vectors.

◆ operator+()

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

Sum of two vectors.

◆ operator-() [1/2]

Vector Dragengine.Scenery.Vector.operator- ( )

Negated vector.

◆ operator-() [2/2]

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

Difference of two vectors.

References equals().

◆ operator/()

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

Vector with each component divided by a value.

Exceptions
EDivisionByZeroscalar is 0.

◆ operator<()

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

Vector is less than another vector in all components.

◆ operator<=()

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

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

◆ operator>()

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

Vector is greater than another vector in all components.

◆ operator>=()

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

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

References readFromFile(), toString(), and writeToFile().

◆ readFromFile()

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

Read vector from a file reader.

References isAtMost().

Referenced by operator>=().

◆ round() [1/2]

Point3 Dragengine.Scenery.Vector.round ( )

Components rounded to nearest integer value.

Version
1.8

References compSelect().

Referenced by equals(), and isZero().

◆ round() [2/2]

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

Components rounded to the nearest unit.

Version
1.8

References combine().

◆ smallest()

Vector Dragengine.Scenery.Vector.smallest ( Vector v)

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

Referenced by mix().

◆ toString() [1/2]

String Dragengine.Scenery.Vector.toString ( )

String representation of vector.

Implements Object.toString()

References isEqualTo(), and mix().

Referenced by operator%(), and operator>=().

◆ toString() [2/2]

String Dragengine.Scenery.Vector.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 isAtLeast().

◆ writeToFile()

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

Write vector to a file writer.

References isZero().

Referenced by operator>=().


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