Struct FastVec3i
- Namespace
- Vintagestory.API.MathTools
- Assembly
- VintagestoryAPI.dll
Represents a vector of 3 ints, similar to a Vec3i or a BlockPos but this is a struct
[ProtoContract]
public struct FastVec3i : IEquatable<FastVec3i>, IEquatable<BlockPos>
- Implements
- Inherited Members
- Extension Methods
Constructors
FastVec3i(int, int, int)
Create a new vector with given coordinates
public FastVec3i(int x, int y, int z)
Parameters
FastVec3i(int[])
Create a new vector with given coordinates
public FastVec3i(int[] values)
Parameters
valuesint[]
FastVec3i(BlockPos)
Create a new vector with given coordinates
public FastVec3i(BlockPos pos)
Parameters
posBlockPos
FastVec3i(Vec3i)
public FastVec3i(Vec3i vec3i)
Parameters
vec3iVec3i
Fields
X
The X-Component of the vector
[ProtoMember(1)]
public int X
Field Value
Y
The Y-Component of the vector
[ProtoMember(2)]
public int Y
Field Value
Z
The Z-Component of the vector
[ProtoMember(3)]
public int Z
Field Value
Properties
B
Synonum for Z
public int B { get; set; }
Property Value
G
Synonum for Y
public int G { get; set; }
Property Value
this[int]
Returns the n-th coordinate
public int this[int index] { get; set; }
Parameters
indexint
Property Value
R
Synonum for X
public int R { get; set; }
Property Value
Methods
Add(int, int, int)
Adds given x/y/z coordinates to the vector
public FastVec3i Add(int x, int y, int z)
Parameters
Returns
Add(BlockFacing, int)
Offsets the position into the direction of given block face
public FastVec3i Add(BlockFacing facing, int length = 1)
Parameters
facingBlockFacinglengthint
Returns
Add(FastVec3i)
Offsets the position by given xyz vector
public FastVec3i Add(FastVec3i vector)
Parameters
vectorFastVec3i
Returns
Add(Vec3i)
Offsets the position by given xyz vector
public FastVec3i Add(Vec3i vector)
Parameters
vectorVec3i
Returns
AddCopy(BlockFacing, int)
Creates a copy of this blocks position and offsets it in the direction of given block face
public FastVec3i AddCopy(BlockFacing facing, int length = 1)
Parameters
facingBlockFacinglengthint
Returns
AddCopy(FastVec3i)
Adds both vectors into a new vector. Both source vectors remain unchanged.
public FastVec3i AddCopy(FastVec3i vec)
Parameters
vecFastVec3i
Returns
Clone()
Creates a copy of the vetor
public FastVec3i Clone()
Returns
CreateFromBytes(BinaryReader)
public static FastVec3i CreateFromBytes(BinaryReader reader)
Parameters
readerBinaryReader
Returns
Distance(FastVec3i)
Calculates the distance the two endpoints
public float Distance(FastVec3i vec)
Parameters
vecFastVec3i
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
Equals(object)
Indicates whether this instance and a specified object are equal.
public override readonly 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.
Equals(BlockPos)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(BlockPos other)
Parameters
otherBlockPosAn object to compare with this object.
Returns
Equals(FastVec3i)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(FastVec3i other)
Parameters
otherFastVec3iAn object to compare with this object.
Returns
Equals(Vec3i)
public bool Equals(Vec3i other)
Parameters
otherVec3i
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Length()
Returns the length of this vector
public float Length()
Returns
Mul(int)
Multiplies each coordinate with given multiplier
public FastVec3i Mul(int multiplier)
Parameters
multiplierint
Returns
Negate()
public void Negate()
Set(int, int, int)
Sets the vector to this coordinates
public FastVec3i Set(int x, int y, int z)
Parameters
Returns
Set(int[])
public FastVec3i Set(int[] vec)
Parameters
vecint[]
Returns
Set(BlockPos)
public FastVec3i Set(BlockPos pos)
Parameters
posBlockPos
Returns
Set(FastVec3i)
Sets the vector to the coordinates of given vector
public void Set(FastVec3i vec)
Parameters
vecFastVec3i
Set(Vec3d)
Sets the vector to the coordinates of given vector
public FastVec3i Set(Vec3d vec)
Parameters
vecVec3d
Returns
Sub(FastVec3i)
Subtract a position => you'll have the manhattan distance
public FastVec3i Sub(FastVec3i pos)
Parameters
posFastVec3i
Returns
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 +(FastVec3i, BlockPos)
public static FastVec3i operator +(FastVec3i left, BlockPos right)
Parameters
Returns
operator +(FastVec3i, FastVec3i)
public static FastVec3i operator +(FastVec3i left, FastVec3i right)
Parameters
Returns
operator ==(FastVec3i, FastVec3i)
public static bool operator ==(FastVec3i left, FastVec3i right)
Parameters
Returns
operator !=(FastVec3i, FastVec3i)
public static bool operator !=(FastVec3i left, FastVec3i right)