Class Vec3f
- 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.
[JsonObject(MemberSerialization.OptIn)]
[ProtoContract]
public class Vec3f : IVec3, IEquatable<Vec3f>
- Inheritance
-
Vec3f
- Implements
- Inherited Members
- Extension Methods
Constructors
Vec3f()
Creates a new vector with x/y/z = 0
public Vec3f()
Vec3f(float, float, float)
Create a new vector with given coordinates
public Vec3f(float x, float y, float z)
Parameters
Vec3f(float[])
Create a new vector with given coordinates
public Vec3f(float[] values)
Parameters
values
float[]
Vec3f(Vec3i)
public Vec3f(Vec3i vec3i)
Parameters
vec3i
Vec3i
Vec3f(Vec4f)
Create a new vector with given coordinates
public Vec3f(Vec4f vec)
Parameters
vec
Vec4f
Fields
X
The X-Component of the vector
[JsonProperty]
[ProtoMember(1)]
public float X
Field Value
Y
The Y-Component of the vector
[JsonProperty]
[ProtoMember(2)]
public float Y
Field Value
Z
The Z-Component of the vector
[JsonProperty]
[ProtoMember(3)]
public float Z
Field Value
Properties
AsVec3i
public Vec3i AsVec3i { get; }
Property Value
B
Synonum for Z
public float B { get; set; }
Property Value
G
Synonum for Y
public float G { get; set; }
Property Value
Half
public static Vec3f Half { get; }
Property Value
IsZero
public bool IsZero { get; }
Property Value
this[int]
Returns the n-th coordinate
public float this[int index] { get; set; }
Parameters
index
int
Property Value
One
public static Vec3f One { get; }
Property Value
R
Synonum for X
public float R { get; set; }
Property Value
Zero
Create a new instance with x/y/z set to 0
public static Vec3f Zero { get; }
Property Value
Methods
Add(float, float, float)
Adds given x/y/z coordinates to the vector
public Vec3f Add(float x, float y, float z)
Parameters
Returns
Add(Vec3d)
Adds given x/y/z coordinates to the vector
public Vec3f Add(Vec3d vec)
Parameters
vec
Vec3d
Returns
Add(Vec3f)
Adds given x/y/z coordinates to the vector
public Vec3f Add(Vec3f vec)
Parameters
vec
Vec3f
Returns
AddCopy(float, float, float)
Adds given coordinates to a new vectors and returns it. The original calling vector remains unchanged
public Vec3f AddCopy(float x, float y, float z)
Parameters
Returns
AddCopy(Vec3f)
Adds both vectors into a new vector. Both source vectors remain unchanged.
public Vec3f AddCopy(Vec3f vec)
Parameters
vec
Vec3f
Returns
Clone()
Creates a copy of the vetor
public Vec3f Clone()
Returns
CreateFromBytes(BinaryReader)
public static Vec3f CreateFromBytes(BinaryReader reader)
Parameters
reader
BinaryReader
Returns
Cross(Vec3f)
public Vec3f Cross(Vec3f vec)
Parameters
vec
Vec3f
Returns
Cross(Vec3f, Vec3f)
Creates the cross product from a and b and sets own values accordingly
public void Cross(Vec3f a, Vec3f b)
Parameters
Cross(Vec3f, Vec4f)
Creates the cross product from a and b and sets own values accordingly
public void Cross(Vec3f a, Vec4f b)
Parameters
DistanceSq(double, double, double)
Calculates the square distance the two endpoints
public double DistanceSq(double x, double y, double z)
Parameters
Returns
DistanceTo(Vec3d)
Calculates the distance the two endpoints
public float DistanceTo(Vec3d vec)
Parameters
vec
Vec3d
Returns
DistanceTo(Vec3f)
public float DistanceTo(Vec3f vec)
Parameters
vec
Vec3f
Returns
Dot(double[])
Returns the dot product with given vector
public double Dot(double[] pos)
Parameters
pos
double[]
Returns
Dot(float[])
Returns the dot product with given vector
public double Dot(float[] pos)
Parameters
pos
float[]
Returns
Dot(FastVec3f)
public float Dot(FastVec3f a)
Parameters
Returns
Dot(Vec3d)
Returns the dot product with given vector
public float Dot(Vec3d a)
Parameters
a
Vec3d
Returns
Dot(Vec3f)
Returns the dot product with given vector
public float Dot(Vec3f a)
Parameters
a
Vec3f
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current object.
Returns
Equals(Vec3f)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Vec3f other)
Parameters
other
Vec3fAn object to compare with this object.
Returns
Equals(Vec3f, double)
public bool Equals(Vec3f other, double epsilon)
Parameters
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Length()
Returns the length of this vector
public float Length()
Returns
Mul(float)
Multiplies each coordinate with given multiplier
public Vec3f Mul(float multiplier)
Parameters
multiplier
float
Returns
Negate()
public void Negate()
Normalize()
Turns the vector into a unit vector with length 1, but only if length is non-zero
public Vec3f Normalize()
Returns
NormalizedCopy()
Creates a new vectors that is the normalized version of this vector.
public Vec3f 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
val
float
RotatedCopy(float)
public Vec3f RotatedCopy(float yaw)
Parameters
yaw
float
Returns
Set(float, float, float)
Sets the vector to this coordinates
public Vec3f Set(float x, float y, float z)
Parameters
Returns
Set(float[])
public Vec3f Set(float[] vec)
Parameters
vec
float[]
Returns
Set(Vec3d)
Sets the vector to the coordinates of given vector
public Vec3f Set(Vec3d vec)
Parameters
vec
Vec3d
Returns
Set(Vec3f)
Sets the vector to the coordinates of given vector
public Vec3f Set(Vec3f vec)
Parameters
vec
Vec3f
Returns
Sub(Vec3d)
Substracts given x/y/z coordinates to the vector
public Vec3f Sub(Vec3d vec)
Parameters
vec
Vec3d
Returns
Sub(Vec3f)
Substracts given x/y/z coordinates to the vector
public Vec3f Sub(Vec3f vec)
Parameters
vec
Vec3f
Returns
Sub(Vec3i)
public Vec3f Sub(Vec3i vec)
Parameters
vec
Vec3i
Returns
ToBytes(BinaryWriter)
public void ToBytes(BinaryWriter writer)
Parameters
writer
BinaryWriter
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
ToVec4f(float)
public Vec4f ToVec4f(float w)
Parameters
w
float
Returns
Operators
operator +(Vec3f, float)
public static Vec3f operator +(Vec3f left, float right)
Parameters
Returns
operator +(Vec3f, Vec3f)
public static Vec3f operator +(Vec3f left, Vec3f right)
Parameters
Returns
operator /(Vec3f, float)
public static Vec3f operator /(Vec3f left, float right)
Parameters
Returns
operator ==(Vec3f, Vec3f)
public static bool operator ==(Vec3f left, Vec3f right)
Parameters
Returns
operator !=(Vec3f, Vec3f)
public static bool operator !=(Vec3f left, Vec3f right)
Parameters
Returns
operator *(float, Vec3f)
public static Vec3f operator *(float left, Vec3f right)
Parameters
Returns
operator *(Vec3f, float)
public static Vec3f operator *(Vec3f left, float right)
Parameters
Returns
operator *(Vec3f, Vec3f)
public static float operator *(Vec3f left, Vec3f right)
Parameters
Returns
operator -(float, Vec3f)
public static Vec3f operator -(float left, Vec3f right)
Parameters
Returns
operator -(Vec3f, float)
public static Vec3f operator -(Vec3f left, float right)
Parameters
Returns
operator -(Vec3f, Vec3f)
public static Vec3f operator -(Vec3f left, Vec3f right)