C# Class OpenBveApi.Math.Vector3

Represents a three-dimensional vector.
Show file Open project: leezer3/OpenBVE Class Usage Examples

Public Properties

Property Type Description
Backward Vector3
Down Vector3
Forward Vector3
Left Vector3
Null Vector3
Right Vector3
Up Vector3
X double
Y double
Z double

Public Methods

Method Description
AreColinear ( Vector3 a, Vector3 b, Vector3 c ) : bool

Checks whether three spatial coordinates are colinear.

CosineInterpolate ( Vector3 Vector1, Vector3 Vector2, double mu ) : Vector3

Interpolates between two Vector3 values using a simple Cosine algorithm

CreateNormal ( Vector3 a, Vector3 b, Vector3 c, Vector3 &normal ) : bool

Creates a unit vector perpendicular to the plane described by three spatial coordinates, suitable for being a surface normal.

Cross ( Vector3 a, Vector3 b ) : Vector3

Gives the cross product of two vectors.

Dot ( Vector3 a, Vector3 b ) : double

Gives the dot product of two vectors.

GetVector3 ( Vector2 Vector, double Y ) : Vector3

Returns a normalized vector based on a 2D vector in the XZ plane and an additional Y-coordinate.

IsNullVector ( ) : bool

Checks whether the vector is a null vector.

IsNullVector ( Vector3 vector ) : bool

Checks whether a vector is a null vector.

IsNullVector ( double tolerance ) : bool

Checks whether the vector is considered a null vector.

IsZero ( Vector3 Vector ) : bool

Determines whether this is a zero (0,0,0) vector

LinearInterpolate ( Vector3 Vector1, Vector3 Vector2, double mu ) : Vector3

Linearly interpolates between two vectors

Norm ( ) : double

Gets the euclidean norm.

Norm ( Vector3 vector ) : double

Gets the euclidean norm of the specified vector.

NormSquared ( ) : double

Gets the square of the euclidean norm.

NormSquared ( Vector3 vector ) : double

Gets the square of the euclidean norm of the specified vector.

Normalize ( Vector3 vector ) : Vector3

Normalizes a vector.

Normalize ( ) : void

Normalizes the vector.

Rotate ( Vector3 vector, Orientation3 orientation ) : Vector3

Rotates a vector from the default orientation into a specified orientation.

The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.

Rotate ( Vector3 vector, Vector3 direction, double cosineOfAngle, double sineOfAngle ) : Vector3

Rotates a vector on the plane perpendicular to a specified direction by a specified angle.

Rotate ( Orientation3 orientation ) : void

Rotates the vector from the default orientation into a specified orientation.

The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.

Rotate ( Vector3 direction, double cosineOfAngle, double sineOfAngle ) : void

Rotates the vector on the plane perpendicular to a specified direction by a specified angle.

Scale ( Vector3 vector, Vector3 factor ) : Vector3

Scales a vector by a specified factor.

Scale ( Vector3 factor ) : void

Scales the vector by a specified factor.

ToString ( ) : string

Returns the representation of the vector in string format

Translate ( Vector3 vector, Orientation3 orientation, Vector3 offset ) : Vector3

Translates a vector by a specified offset that is measured along a specified orientation.

Translate ( Vector3 vector, Vector3 offset ) : Vector3

Translates a vector by a specified offset.

Translate ( Orientation3 orientation, Vector3 offset ) : void

Translates the vector by a specified offset that is measured in a specified orientation.

Translate ( Vector3 offset ) : void

Translates the vector by a specified offset.

Vector3 ( double x, double y, double z ) : System

Creates a new three-dimensional vector.

operator ( ) : Vector3

Adds two vectors.

operator ( ) : bool

Checks whether the two specified vectors are equal.

Method Details

AreColinear() public static method

Checks whether three spatial coordinates are colinear.
public static AreColinear ( Vector3 a, Vector3 b, Vector3 c ) : bool
a Vector3 The first spatial coordinate.
b Vector3 The second spatial coordinate.
c Vector3 The third spatial coordinate.
return bool

CosineInterpolate() public static method

Interpolates between two Vector3 values using a simple Cosine algorithm
public static CosineInterpolate ( Vector3 Vector1, Vector3 Vector2, double mu ) : Vector3
Vector1 Vector3 The first vector
Vector2 Vector3 The second vector
mu double The position on the curve of the new vector
return Vector3

CreateNormal() public static method

Creates a unit vector perpendicular to the plane described by three spatial coordinates, suitable for being a surface normal.
public static CreateNormal ( Vector3 a, Vector3 b, Vector3 c, Vector3 &normal ) : bool
a Vector3 The first spatial coordinate.
b Vector3 The second spatial coordinate.
c Vector3 The third spatial coordinate.
normal Vector3 On success, receives the vector perpendicular to the described plane. On failure, receives Vector3.Up.
return bool

Cross() public static method

Gives the cross product of two vectors.
public static Cross ( Vector3 a, Vector3 b ) : Vector3
a Vector3 The first vector.
b Vector3 The second vector.
return Vector3

Dot() public static method

Gives the dot product of two vectors.
public static Dot ( Vector3 a, Vector3 b ) : double
a Vector3 The first vector.
b Vector3 The second vector.
return double

GetVector3() public static method

Returns a normalized vector based on a 2D vector in the XZ plane and an additional Y-coordinate.
public static GetVector3 ( Vector2 Vector, double Y ) : Vector3
Vector Vector2 The vector in the XZ-plane. The X and Y components in Vector represent the X- and Z-coordinates, respectively.
Y double The Y-coordinate.
return Vector3

IsNullVector() public method

Checks whether the vector is a null vector.
public IsNullVector ( ) : bool
return bool

IsNullVector() public static method

Checks whether a vector is a null vector.
public static IsNullVector ( Vector3 vector ) : bool
vector Vector3
return bool

IsNullVector() public method

Checks whether the vector is considered a null vector.
public IsNullVector ( double tolerance ) : bool
tolerance double The highest absolute value that each component of the vector may have before the vector is not considered a null vector.
return bool

IsZero() public static method

Determines whether this is a zero (0,0,0) vector
public static IsZero ( Vector3 Vector ) : bool
Vector Vector3
return bool

LinearInterpolate() public static method

Linearly interpolates between two vectors
public static LinearInterpolate ( Vector3 Vector1, Vector3 Vector2, double mu ) : Vector3
Vector1 Vector3 The first vector
Vector2 Vector3 The second vector
mu double The position on the interpolation curve of the new vector
return Vector3

Norm() public method

Gets the euclidean norm.
public Norm ( ) : double
return double

Norm() public static method

Gets the euclidean norm of the specified vector.
public static Norm ( Vector3 vector ) : double
vector Vector3 The vector.
return double

NormSquared() public method

Gets the square of the euclidean norm.
public NormSquared ( ) : double
return double

NormSquared() public static method

Gets the square of the euclidean norm of the specified vector.
public static NormSquared ( Vector3 vector ) : double
vector Vector3 The vector.
return double

Normalize() public static method

Normalizes a vector.
Raised when the vector is a null vector.
public static Normalize ( Vector3 vector ) : Vector3
vector Vector3 The vector.
return Vector3

Normalize() public method

Normalizes the vector.
Raised when the vector is a null vector.
public Normalize ( ) : void
return void

Rotate() public static method

Rotates a vector from the default orientation into a specified orientation.
The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.
public static Rotate ( Vector3 vector, Orientation3 orientation ) : Vector3
vector Vector3 The vector.
orientation Orientation3 The orientation.
return Vector3

Rotate() public static method

Rotates a vector on the plane perpendicular to a specified direction by a specified angle.
public static Rotate ( Vector3 vector, Vector3 direction, double cosineOfAngle, double sineOfAngle ) : Vector3
vector Vector3 The vector.
direction Vector3 The direction perpendicular to the plane on which to rotate.
cosineOfAngle double The cosine of the angle.
sineOfAngle double The sine of the angle.
return Vector3

Rotate() public method

Rotates the vector from the default orientation into a specified orientation.
The default orientation is X = {1, 0, 0), Y = {0, 1, 0} and Z = {0, 0, 1}.
public Rotate ( Orientation3 orientation ) : void
orientation Orientation3 The orientation.
return void

Rotate() public method

Rotates the vector on the plane perpendicular to a specified direction by a specified angle.
public Rotate ( Vector3 direction, double cosineOfAngle, double sineOfAngle ) : void
direction Vector3 The direction perpendicular to the plane on which to rotate.
cosineOfAngle double The cosine of the angle.
sineOfAngle double The sine of the angle.
return void

Scale() public static method

Scales a vector by a specified factor.
public static Scale ( Vector3 vector, Vector3 factor ) : Vector3
vector Vector3 The vector.
factor Vector3 The factor.
return Vector3

Scale() public method

Scales the vector by a specified factor.
public Scale ( Vector3 factor ) : void
factor Vector3 The factor.
return void

ToString() public method

Returns the representation of the vector in string format
public ToString ( ) : string
return string

Translate() public static method

Translates a vector by a specified offset that is measured along a specified orientation.
public static Translate ( Vector3 vector, Orientation3 orientation, Vector3 offset ) : Vector3
vector Vector3 The vector.
orientation Orientation3 The orientation.
offset Vector3 The offset measured in the specified orientation.
return Vector3

Translate() public static method

Translates a vector by a specified offset.
public static Translate ( Vector3 vector, Vector3 offset ) : Vector3
vector Vector3 The vector.
offset Vector3 The offset.
return Vector3

Translate() public method

Translates the vector by a specified offset that is measured in a specified orientation.
public Translate ( Orientation3 orientation, Vector3 offset ) : void
orientation Orientation3 The orientation.
offset Vector3 The offset measured in the specified orientation.
return void

Translate() public method

Translates the vector by a specified offset.
public Translate ( Vector3 offset ) : void
offset Vector3 The offset.
return void

Vector3() public method

Creates a new three-dimensional vector.
public Vector3 ( double x, double y, double z ) : System
x double The x-coordinate.
y double The y-coordinate.
z double The z-coordinate.
return System

operator() public static method

Adds two vectors.
public static operator ( ) : Vector3
return Vector3

operator() public static method

Checks whether the two specified vectors are equal.
public static operator ( ) : bool
return bool

Property Details

Backward public static property

Represents a vector pointing up.
public static Vector3 Backward
return Vector3

Down public static property

Represents a vector pointing down.
public static Vector3 Down
return Vector3

Forward public static property

Represents a vector pointing down.
public static Vector3 Forward
return Vector3

Left public static property

Represents a vector pointing left.
public static Vector3 Left
return Vector3

Null public static property

Represents a null vector.
public static Vector3 Null
return Vector3

Right public static property

Represents a vector pointing right.
public static Vector3 Right
return Vector3

Up public static property

Represents a vector pointing up.
public static Vector3 Up
return Vector3

X public property

The x-coordinate.
public double X
return double

Y public property

The y-coordinate.
public double Y
return double

Z public property

The z-coordinate.
public double Z
return double