VRay SDK for C#
Loading...
Searching...
No Matches
VRay.Vector Struct Reference

A class which represents a vector in 3D space (x, y, z). More...

Inherits IEquatable< Vector >, and IComparable< Vector >.

Public Member Functions

 Vector (double value)
 Constructs a vector with the specified x, y and z components from a value. More...
 
 Vector (double x, double y, double z)
 Constructs a vector with the specified x, y and z components. More...
 
 Vector (float value)
 Constructs a vector with the specified x, y and z components from a value. More...
 
 Vector (float x, float y, float z)
 Constructs a vector with the specified x, y and z components. More...
 
int CompareTo (Vector vector)
 Compares the vectors. More...
 
override bool Equals (object obj)
 Returns true if the components of the two vectors are exactly equal (unlike operator== which uses epsilon).
 
bool Equals (Vector vector)
 Returns true if the components of the two vectors are exactly equal (unlike operator== which uses epsilon).
 
override int GetHashCode ()
 
double GetLength ()
 Gets the length of the vector.
 
float GetLengthSqr ()
 Gets the squared length of the vector.
 
Vector Normalize ()
 Returns a new unit vector with the same direction.
 
Vector ReplaceX (double newX)
 
Vector ReplaceX (float newX)
 
Vector ReplaceY (double newY)
 
Vector ReplaceY (float newY)
 
Vector ReplaceZ (double newZ)
 
Vector ReplaceZ (float newZ)
 
Vector Rotate (Vector axis)
 Returns a vector rotated around an axis. More...
 
override string ToString ()
 

Static Public Member Functions

static Vector FromString (string vector)
 Parses a vector string value and returns a vector instance. More...
 
static double Mixed (Vector a, Vector b, Vector c)
 Returns the mixed product of the three vectors ((a ^ b) * c) More...
 
static Vector Multiply (Vector left, Vector right)
 Mutiplies the components of the given vectors. Note that this is different from operator*, which does dot product. More...
 
static bool operator!= (Vector v0, Vector v1)
 
static Vector operator* (double a, Vector v)
 Multiplies all components of the given vector by the given number.
 
static Vector operator* (float a, Vector v)
 Multiplies all components of the given vector by the given number.
 
static Vector operator* (int a, Vector v)
 Multiplies all components of the given vector by the given number.
 
static Vector operator* (Vector v, double a)
 Multiplies all components of the given vector by the given number.
 
static Vector operator* (Vector v, float a)
 Multiplies all components of the given vector by the given number.
 
static Vector operator* (Vector v, int a)
 Multiplies all components of the given vector by the given number.
 
static double operator* (Vector v0, Vector v1)
 Dot product of two vectors.
 
static Vector operator+ (Vector v)
 Unary operator +.
 
static Vector operator+ (Vector v, double a)
 Sum with a scalar.
 
static Vector operator+ (Vector v, float a)
 Sum with a scalar.
 
static Vector operator+ (Vector v, int a)
 Sum with a scalar.
 
static Vector operator+ (Vector v0, Vector v1)
 Sum of two vectors.
 
static Vector operator- (Vector v)
 Unary operator -.
 
static Vector operator- (Vector v, double a)
 Subtract a scalar.
 
static Vector operator- (Vector v, float a)
 Subtract a scalar.
 
static Vector operator- (Vector v, int a)
 Subtract a scalar.
 
static Vector operator- (Vector v0, Vector v1)
 Difference of two vectors.
 
static Vector operator/ (Vector v, double a)
 Divides all components of the given vector by the given number.
 
static Vector operator/ (Vector v, float a)
 Divides all components of the given vector by the given number.
 
static Vector operator/ (Vector v, int a)
 Divides all components of the given vector by the given number.
 
static Vector operator/ (Vector v1, Vector v2)
 Divides the two vectors component by component.
 
static bool operator== (Vector v0, Vector v1)
 
static Vector operator^ (Vector v0, Vector v1)
 Cross product of two vectors.
 

Static Public Attributes

const int Size = 12
 The size of Vector struct, measured in bytes.
 

Properties

float this[int index] [get]
 Gets the specified axis value (0 for x, 1 for y and 2 for z). More...
 
float X [get]
 Gets the value of the X axis.
 
float Y [get]
 Gets the value of the Y axis.
 
float Z [get]
 Gets the value of the Z axis.
 

Detailed Description

A class which represents a vector in 3D space (x, y, z).

Constructor & Destructor Documentation

◆ Vector() [1/4]

VRay.Vector.Vector ( float  x,
float  y,
float  z 
)

Constructs a vector with the specified x, y and z components.

Parameters
xThe x component.
yThe y component.
zThe z component.

◆ Vector() [2/4]

VRay.Vector.Vector ( double  x,
double  y,
double  z 
)

Constructs a vector with the specified x, y and z components.

Parameters
xThe x component.
yThe y component.
zThe z component.

◆ Vector() [3/4]

VRay.Vector.Vector ( float  value)

Constructs a vector with the specified x, y and z components from a value.

Parameters
valueThe x, y and z component.

◆ Vector() [4/4]

VRay.Vector.Vector ( double  value)

Constructs a vector with the specified x, y and z components from a value.

Parameters
valueThe x, y and z component.

Member Function Documentation

◆ CompareTo()

int VRay.Vector.CompareTo ( Vector  vector)

Compares the vectors.

Parameters
vectorThe vector to compare to
Returns
-1 if this vector is less than the passed one, 0 if they are equal, +1 if greater.

◆ FromString()

static Vector VRay.Vector.FromString ( string  vector)
static

Parses a vector string value and returns a vector instance.

Parameters
vectorThe string representation of the vector.
Returns
The vector instance.

◆ Mixed()

static double VRay.Vector.Mixed ( Vector  a,
Vector  b,
Vector  c 
)
static

Returns the mixed product of the three vectors ((a ^ b) * c)

Parameters
aThe first vector.
bThe second vector.
cThe third vector.
Returns
The mixed product of the three vectors as double.

◆ Multiply()

static Vector VRay.Vector.Multiply ( Vector  left,
Vector  right 
)
static

Mutiplies the components of the given vectors. Note that this is different from operator*, which does dot product.

Returns
A new vector set to the multiplied components.

◆ Rotate()

Vector VRay.Vector.Rotate ( Vector  axis)

Returns a vector rotated around an axis.

Parameters
axisAn axis vector to rotate around. The length of the axis is the tangent of the angle of rotation.
Returns
A new vector rotated around the axis.

Property Documentation

◆ this[int index]

float VRay.Vector.this[int index]
get

Gets the specified axis value (0 for x, 1 for y and 2 for z).

Parameters
indexThe index corresponding to the axis value (0 for x, 1 for y and 2 for z).
Returns
The value of the specified axis.

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