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
FastVec3f(float[])
Create a new vector with given coordinates
public FastVec3f(float[] values)
Parameters
valuesfloat[]
FastVec3f(Vec3f)
public FastVec3f(Vec3f vec)
Parameters
vecVec3f
FastVec3f(Vec3i)
public FastVec3f(Vec3i vec3i)
Parameters
vec3iVec3i
FastVec3f(Vec4f)
Create a new vector with given coordinates
public FastVec3f(Vec4f vec)
Parameters
vecVec4f
Fields
X
The X-Component of the vector
public float X
Field Value
Y
The Y-Component of the vector
public float Y
Field Value
Z
The Z-Component of the vector
public float Z
Field Value
Properties
B
Synonum for Z
public float B { get; set; }
Property Value
G
Synonum for Y
public float G { get; set; }
Property Value
this[int]
Returns the n-th coordinate
public float this[int index] { get; set; }
Parameters
indexint
Property Value
R
Synonum for X
public float R { get; set; }
Property Value
Methods
Add(float, float, float)
Adds given x/y/z coordinates to the vector
public FastVec3f Add(float x, float y, float z)
Parameters
Returns
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
Returns
AddCopy(FastVec3f)
Adds both vectors into a new vector. Both source vectors remain unchanged.
public FastVec3f AddCopy(FastVec3f vec)
Parameters
vecFastVec3f
Returns
Clone()
Creates a copy of the vetor
public FastVec3f Clone()
Returns
CreateFromBytes(BinaryReader)
public static FastVec3f CreateFromBytes(BinaryReader reader)
Parameters
readerBinaryReader
Returns
Distance(FastVec3f)
Calculates the distance the two endpoints
public float Distance(FastVec3f vec)
Parameters
vecFastVec3f
Returns
Distance(Vec3d)
Calculates the distance the two endpoints
public float Distance(Vec3d vec)
Parameters
vecVec3d
Returns
DistanceSq(double, double, double)
Calculates the square distance the two endpoints
public double DistanceSq(double x, double y, double z)
Parameters
Returns
Dot(double[])
Returns the dot product with given vector
public double Dot(double[] pos)
Parameters
posdouble[]
Returns
Dot(float[])
Returns the dot product with given vector
public double Dot(float[] pos)
Parameters
posfloat[]
Returns
Dot(Vec3d)
Returns the dot product with given vector
public float Dot(Vec3d a)
Parameters
aVec3d
Returns
Dot(Vec3f)
Returns the dot product with given vector
public float Dot(Vec3f a)
Parameters
aVec3f
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Length()
Returns the length of this vector
public float Length()
Returns
Mul(float)
Multiplies each coordinate with given multiplier
public FastVec3f Mul(float multiplier)
Parameters
multiplierfloat
Returns
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
NormalizedCopy()
Creates a new vectors that is the normalized version of this vector.
public FastVec3f NormalizedCopy()
Returns
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
valfloat
Set(float, float, float)
Sets the vector to this coordinates
public FastVec3f Set(float x, float y, float z)
Parameters
Returns
Set(float[])
public FastVec3f Set(float[] vec)
Parameters
vecfloat[]
Returns
Set(FastVec3f)
Sets the vector to the coordinates of given vector
public void Set(FastVec3f vec)
Parameters
vecFastVec3f
Set(Vec3d)
Sets the vector to the coordinates of given vector
public FastVec3f Set(Vec3d vec)
Parameters
vecVec3d
Returns
ToDoubleArray()
public double[] ToDoubleArray()
Returns
- double[]
ToString()
Simple string represenation of the x/y/z components
public override string ToString()
Returns
ToVec3d()
Creates a new double precision vector with the same coordinates
public Vec3d ToVec3d()
Returns
Write(BinaryWriter)
public void Write(BinaryWriter writer)
Parameters
writerBinaryWriter
Operators
operator +(FastVec3f, float)
public static FastVec3f operator +(FastVec3f left, float right)
Parameters
Returns
operator *(FastVec3f, float)
public static FastVec3f operator *(FastVec3f left, float right)
Parameters
Returns
operator -(FastVec3f, float)
public static FastVec3f operator -(FastVec3f left, float right)