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

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

Inheritance diagram for Dragengine.Scenery.DVector:

Public Member Functions

Constructors
DVector new ()
 Create vector with all components set to 0.
DVector new (float x, float y, float z)
 Create vector using the specified components.
DVector new (DVector v)
 Create copy of a DVector.
DVector 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.
DVector normalize ()
 Vector divided by length().
DVector absolute ()
 Vector with absolute of all components.
DVector compMultiply (DVector v)
 Component wise multiplication.
DVector compDivide (DVector v)
 Component wise division.
DVector compSelect (bool x, bool y, bool z)
 Vector with components set to true copied while all others are set to 0.
DVector combine (DVector vector, bool x, bool y, bool z)
 Combine selected components of this vector with another.
DVector smallest (DVector v)
 Vector with all components set to the smallest value of two vectors.
DVector largest (DVector v)
 Vector with all components set to the largest value of two vectors.
DVector clamped (DVector min, DVector max)
 Vector with all components clamped to a range of two vectors.
Vector toVector ()
 Convert to single precision vector with possible loss of precision.
Point3 round ()
 Components rounded to nearest integer value.
DVector round (float unit)
 Components rounded to the nearest unit.
DVector mix (DVector other, float factor)
 Mix vector with another component wise.
bool isEqualTo (DVector 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
DVector operator- ()
 Negated vector.
DVector operator+ (DVector v)
 Sum of two vectors.
DVector operator- (DVector v)
 Difference of two vectors.
DVector operator* (float scalar)
 Vector scaled by scalar.
DVector operator/ (float scalar)
 Vector with each component divided by a value.
float operator* (DVector v)
 Dot-Product between two vectors.
DVector operator% (DVector v)
 Cross-Product between two vectors.
bool operator< (DVector v)
 Vector is less than another vector in all components.
bool operator<= (DVector v)
 Vector is less than or equal to another vector in all components.
bool operator> (DVector v)
 Vector is greater than another vector in all components.
bool operator>= (DVector 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 DVector 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()

DVector Dragengine.Scenery.DVector.absolute ( )

Vector with absolute of all components.

References getLength().

Referenced by smallest().

◆ clamped()

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

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

Referenced by isAtLeast().

◆ combine()

DVector Dragengine.Scenery.DVector.combine ( DVector 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.

Referenced by round().

◆ compDivide()

DVector Dragengine.Scenery.DVector.compDivide ( DVector v)

Component wise division.

Referenced by toVector().

◆ compMultiply()

DVector Dragengine.Scenery.DVector.compMultiply ( DVector v)

Component wise multiplication.

References getLengthSquared().

Referenced by largest().

◆ compSelect()

DVector Dragengine.Scenery.DVector.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.DVector.equals ( Object other)

Vector is equal to another object.

Implements Object.equals(Object).

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

Referenced by operator*().

◆ get()

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

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

References getY().

Referenced by getLengthSquared().

◆ getLength()

float Dragengine.Scenery.DVector.getLength ( )

Length.

References getZ().

Referenced by absolute().

◆ getLengthSquared()

float Dragengine.Scenery.DVector.getLengthSquared ( )

Squared length.

References get().

Referenced by compMultiply().

◆ getX()

float Dragengine.Scenery.DVector.getX ( )

X-Component.

Referenced by getY().

◆ getY()

float Dragengine.Scenery.DVector.getY ( )

Y-Component.

References getX().

Referenced by get().

◆ getZ()

float Dragengine.Scenery.DVector.getZ ( )

Z-Component.

Referenced by getLength().

◆ hashCode()

int Dragengine.Scenery.DVector.hashCode ( )

Hash code for use as dictionary keys.

Implements Object.hashCode().

References round().

Referenced by operator/().

◆ isAtLeast()

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

All coordinates are at least of a minimal value.

References clamped().

Referenced by toString().

◆ isAtMost()

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

All coordinates are at most of a maximal value.

Referenced by writeToFile().

◆ isEqualTo()

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

Two vectors are equal.

Referenced by toString().

◆ isZero()

bool Dragengine.Scenery.DVector.isZero ( )

Vector is equal to zero vector.

References round(), and toVector().

Referenced by writeToFile().

◆ largest()

DVector Dragengine.Scenery.DVector.largest ( DVector v)

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

References compMultiply().

Referenced by mix().

◆ mix()

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

Mix vector with another component wise.

Version
1.10

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

References largest().

Referenced by toString().

◆ new() [1/4]

DVector Dragengine.Scenery.DVector.new ( )

Create vector with all components set to 0.

References new().

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

◆ new() [2/4]

DVector Dragengine.Scenery.DVector.new ( DVector v)

Create copy of a DVector.

References new().

◆ new() [3/4]

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

Create vector using the specified components.

References new().

◆ new() [4/4]

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

Create DVetor from Vector.

References new().

◆ normalize()

DVector Dragengine.Scenery.DVector.normalize ( )

Vector divided by length().

Exceptions
EDivisionByZeroLength is 0.

Referenced by compSelect().

◆ operator%()

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

Cross-Product between two vectors.

◆ operator*() [1/2]

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

Dot-Product between two vectors.

◆ operator*() [2/2]

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

Vector scaled by scalar.

References equals().

◆ operator+()

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

Sum of two vectors.

◆ operator-() [1/2]

DVector Dragengine.Scenery.DVector.operator- ( )

Negated vector.

◆ operator-() [2/2]

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

Difference of two vectors.

◆ operator/()

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

Vector with each component divided by a value.

Exceptions
EDivisionByZeroscalar is 0.

References hashCode().

◆ operator<()

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

Vector is less than another vector in all components.

References toString().

◆ operator<=()

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

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

◆ operator>()

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

Vector is greater than another vector in all components.

◆ operator>=()

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

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

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

◆ readFromFile()

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

Read vector from a file reader.

Referenced by operator>=().

◆ round() [1/2]

Point3 Dragengine.Scenery.DVector.round ( )

Components rounded to nearest integer value.

Version
1.8

References compSelect().

Referenced by hashCode(), and isZero().

◆ round() [2/2]

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

Components rounded to the nearest unit.

Version
1.8

References combine(), and smallest().

◆ smallest()

DVector Dragengine.Scenery.DVector.smallest ( DVector v)

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

References absolute().

Referenced by round().

◆ toString() [1/2]

String Dragengine.Scenery.DVector.toString ( )

String representation of vector.

Implements Object.toString()

References mix().

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

◆ toString() [2/2]

String Dragengine.Scenery.DVector.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 17 inclusive.
Exceptions
EInvalidParamprecision is less than 0 or larger than 17.

References isAtLeast(), and isEqualTo().

◆ toVector()

Vector Dragengine.Scenery.DVector.toVector ( )

Convert to single precision vector with possible loss of precision.

References compDivide().

Referenced by isZero().

◆ writeToFile()

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

Write vector to a file writer.

References isAtMost(), and isZero().

Referenced by operator>=().


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