Table of Contents

Struct FastVec3f

Namespace
Vintagestory.API.MathTools
Assembly
VintagestoryAPI.dll

Represents a vector of 3 floats. Go bug Tyron of you need more utility methods in this class.

public struct FastVec3f
Inherited Members
Extension Methods

Constructors

FastVec3f(float, float, float)

Create a new vector with given coordinates

public FastVec3f(float x, float y, float z)

Parameters

x float
y float
z float

FastVec3f(float[])

Create a new vector with given coordinates

public FastVec3f(float[] values)

Parameters

values float[]

FastVec3f(Vec3i)

public FastVec3f(Vec3i vec3i)

Parameters

vec3i Vec3i

FastVec3f(Vec4f)

Create a new vector with given coordinates

public FastVec3f(Vec4f vec)

Parameters

vec Vec4f

Fields

X

The X-Component of the vector

public float X

Field Value

float

Y

The Y-Component of the vector

public float Y

Field Value

float

Z

The Z-Component of the vector

public float Z

Field Value

float

Properties

B

Synonum for Z

public float B { get; set; }

Property Value

float

G

Synonum for Y

public float G { get; set; }

Property Value

float

this[int]

Returns the n-th coordinate

public float this[int index] { get; set; }

Parameters

index int

Property Value

float

R

Synonum for X

public float R { get; set; }

Property Value

float

Methods

Add(float, float, float)

Adds given x/y/z coordinates to the vector

public FastVec3f Add(float x, float y, float z)

Parameters

x float
y float
z float

Returns

FastVec3f

AddCopy(float, float, float)

Adds given coordinates to a new vectors and returns it. The original calling vector remains unchanged

public FastVec3f AddCopy(float x, float y, float z)

Parameters

x float
y float
z float

Returns

FastVec3f

AddCopy(FastVec3f)

Adds both vectors into a new vector. Both source vectors remain unchanged.

public FastVec3f AddCopy(FastVec3f vec)

Parameters

vec FastVec3f

Returns

FastVec3f

Clone()

Creates a copy of the vetor

public FastVec3f Clone()

Returns

FastVec3f

CreateFromBytes(BinaryReader)

public static FastVec3f CreateFromBytes(BinaryReader reader)

Parameters

reader BinaryReader

Returns

FastVec3f

Distance(FastVec3f)

Calculates the distance the two endpoints

public float Distance(FastVec3f vec)

Parameters

vec FastVec3f

Returns

float

Distance(Vec3d)

Calculates the distance the two endpoints

public float Distance(Vec3d vec)

Parameters

vec Vec3d

Returns

float

DistanceSq(double, double, double)

Calculates the square distance the two endpoints

public double DistanceSq(double x, double y, double z)

Parameters

x double
y double
z double

Returns

double

Dot(double[])

Returns the dot product with given vector

public double Dot(double[] pos)

Parameters

pos double[]

Returns

double

Dot(float[])

Returns the dot product with given vector

public double Dot(float[] pos)

Parameters

pos float[]

Returns

double

Dot(Vec3d)

Returns the dot product with given vector

public float Dot(Vec3d a)

Parameters

a Vec3d

Returns

float

Dot(Vec3f)

Returns the dot product with given vector

public float Dot(Vec3f a)

Parameters

a Vec3f

Returns

float

Length()

Returns the length of this vector

public float Length()

Returns

float

Mul(float)

Multiplies each coordinate with given multiplier

public FastVec3f Mul(float multiplier)

Parameters

multiplier float

Returns

FastVec3f

Negate()

public void Negate()

Normalize()

Turns the vector into a unit vector with length 1, but only if length is non-zero

public FastVec3f Normalize()

Returns

FastVec3f

NormalizedCopy()

Creates a new vectors that is the normalized version of this vector.

public FastVec3f NormalizedCopy()

Returns

FastVec3f

ReduceBy(float)

Substracts val from each coordinate if the coordinate if positive, otherwise it is added. If 0, the value is unchanged. The value must be a positive number

public void ReduceBy(float val)

Parameters

val float

Set(float, float, float)

Sets the vector to this coordinates

public FastVec3f Set(float x, float y, float z)

Parameters

x float
y float
z float

Returns

FastVec3f

Set(float[])

public FastVec3f Set(float[] vec)

Parameters

vec float[]

Returns

FastVec3f

Set(FastVec3f)

Sets the vector to the coordinates of given vector

public void Set(FastVec3f vec)

Parameters

vec FastVec3f

Set(Vec3d)

Sets the vector to the coordinates of given vector

public FastVec3f Set(Vec3d vec)

Parameters

vec Vec3d

Returns

FastVec3f

ToDoubleArray()

public double[] ToDoubleArray()

Returns

double[]

ToString()

Simple string represenation of the x/y/z components

public override string ToString()

Returns

string

ToVec3d()

Creates a new double precision vector with the same coordinates

public Vec3d ToVec3d()

Returns

Vec3d

Write(BinaryWriter)

public void Write(BinaryWriter writer)

Parameters

writer BinaryWriter