Table of Contents

Class Vec3d

Namespace
Vintagestory.API.MathTools
Assembly
VintagestoryAPI.dll

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

[ProtoContract]
public class Vec3d : IVec3, IEquatable<Vec3d>
Inheritance
Vec3d
Implements
Inherited Members
Extension Methods

Constructors

Vec3d()

public Vec3d()

Vec3d(double, double, double)

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

Parameters

x double
y double
z double

Vec3d(EntityPos)

public Vec3d(EntityPos vec)

Parameters

vec EntityPos

Vec3d(Vec4d)

Create a new vector with given coordinates

public Vec3d(Vec4d vec)

Parameters

vec Vec4d

Fields

X

[ProtoMember(1)]
public double X

Field Value

double

Y

[ProtoMember(2)]
public double Y

Field Value

double

Z

[ProtoMember(3)]
public double Z

Field Value

double

Properties

AsBlockPos

[JsonIgnore]
public BlockPos AsBlockPos { get; }

Property Value

BlockPos

AsVec3i

public Vec3i AsVec3i { get; }

Property Value

Vec3i

this[int]

Returns the n-th coordinate

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

Parameters

index int

Property Value

double

XInt

[JsonIgnore]
public int XInt { get; }

Property Value

int

YInt

[JsonIgnore]
public int YInt { get; }

Property Value

int

ZInt

[JsonIgnore]
public int ZInt { get; }

Property Value

int

Zero

Create a new instance with x/y/z set to 0

public static Vec3d Zero { get; }

Property Value

Vec3d

Methods

Add(double)

public Vec3d Add(double value)

Parameters

value double

Returns

Vec3d

Add(double, double, double)

public Vec3d Add(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

Add(BlockPos)

public Vec3d Add(BlockPos a)

Parameters

a BlockPos

Returns

Vec3d

Add(Vec3d)

public Vec3d Add(Vec3d a)

Parameters

a Vec3d

Returns

Vec3d

Add(Vec3d, Vec3d)

public static Vec3d Add(Vec3d a, Vec3d b)

Parameters

a Vec3d
b Vec3d

Returns

Vec3d

Add(Vec3f)

public Vec3d Add(Vec3f a)

Parameters

a Vec3f

Returns

Vec3d

AddCopy(double, double, double)

public Vec3d AddCopy(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

AddCopy(float, float, float)

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

Parameters

x float
y float
z float

Returns

Vec3d

AddCopy(BlockFacing)

public Vec3d AddCopy(BlockFacing facing)

Parameters

facing BlockFacing

Returns

Vec3d

AddCopy(BlockPos)

public Vec3d AddCopy(BlockPos pos)

Parameters

pos BlockPos

Returns

Vec3d

AddCopy(Vec3d)

public Vec3d AddCopy(Vec3d a)

Parameters

a Vec3d

Returns

Vec3d

AddCopy(Vec3f)

public Vec3d AddCopy(Vec3f a)

Parameters

a Vec3f

Returns

Vec3d

Ahead(double, double, double)

public Vec3d Ahead(double offset, double Pitch, double Yaw)

Parameters

offset double
Pitch double
Yaw double

Returns

Vec3d

Ahead(double, float, float)

public Vec3d Ahead(double offset, float Pitch, float Yaw)

Parameters

offset double
Pitch float
Yaw float

Returns

Vec3d

AheadCopy(double, double, double)

public Vec3d AheadCopy(double offset, double Pitch, double Yaw)

Parameters

offset double
Pitch double
Yaw double

Returns

Vec3d

AheadCopy(double, float, float)

public Vec3d AheadCopy(double offset, float Pitch, float Yaw)

Parameters

offset double
Pitch float
Yaw float

Returns

Vec3d

Clone()

public Vec3d Clone()

Returns

Vec3d

CreateFromBytes(BinaryReader)

public static Vec3d CreateFromBytes(BinaryReader reader)

Parameters

reader BinaryReader

Returns

Vec3d

Cross(Vec3d)

public Vec3d Cross(Vec3d vec)

Parameters

vec Vec3d

Returns

Vec3d

Cross(Vec3d, Vec3d)

public void Cross(Vec3d a, Vec3d b)

Parameters

a Vec3d
b Vec3d

Cross(Vec3d, Vec4d)

public void Cross(Vec3d a, Vec4d b)

Parameters

a Vec3d
b Vec4d

Cross(Vec4d, Vec4d)

public void Cross(Vec4d a, Vec4d b)

Parameters

a Vec4d
b Vec4d

DistanceTo(double, double, double)

public float DistanceTo(double x, double y, double z)

Parameters

x double
y double
z double

Returns

float

DistanceTo(Vec3d)

public float DistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

float

Dot(Vec3d)

public double Dot(Vec3d a)

Parameters

a Vec3d

Returns

double

Equals(object)

Determines whether the specified object is equal to the current object.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

Equals(Vec3d)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Vec3d other)

Parameters

other Vec3d

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(Vec3d, double)

public bool Equals(Vec3d other, double epsilon)

Parameters

other Vec3d
epsilon double

Returns

bool

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

HorLength()

public double HorLength()

Returns

double

HorizontalSquareDistanceTo(double, double)

public float HorizontalSquareDistanceTo(double x, double z)

Parameters

x double
z double

Returns

float

HorizontalSquareDistanceTo(Vec3d)

public float HorizontalSquareDistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

float

Length()

public double Length()

Returns

double

LengthSq()

public double LengthSq()

Returns

double

Mul(double)

public Vec3d Mul(double val)

Parameters

val double

Returns

Vec3d

Mul(double, double, double)

public Vec3d Mul(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

Negate()

public void Negate()

Normalize()

public Vec3d Normalize()

Returns

Vec3d

Offset(double, double, double)

Note: adjusts the calling Vec3d, does not make a copy

public Vec3d Offset(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

Offset(Vec3d)

Note: adjusts the calling Vec3d, does not make a copy

public Vec3d Offset(Vec3d b)

Parameters

b Vec3d

Returns

Vec3d

OffsetCopy(double, double, double)

public Vec3d OffsetCopy(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

OffsetCopy(float, float, float)

public Vec3d OffsetCopy(float x, float y, float z)

Parameters

x float
y float
z float

Returns

Vec3d

RotatedCopy(float)

public Vec3d RotatedCopy(float yaw)

Parameters

yaw float

Returns

Vec3d

Scale(double)

Note: adjusts the calling Vec3d, does not make a copy

public Vec3d Scale(double f)

Parameters

f double

Returns

Vec3d

Set(double, double, double)

public Vec3d Set(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

Set(EntityPos)

public Vec3d Set(EntityPos pos)

Parameters

pos EntityPos

Returns

Vec3d

Set(BlockPos)

public Vec3d Set(BlockPos pos)

Parameters

pos BlockPos

Returns

Vec3d

Set(Vec3d)

public Vec3d Set(Vec3d pos)

Parameters

pos Vec3d

Returns

Vec3d

Set(Vec3f)

public Vec3d Set(Vec3f pos)

Parameters

pos Vec3f

Returns

Vec3d

Set(Vec3i)

public Vec3d Set(Vec3i pos)

Parameters

pos Vec3i

Returns

Vec3d

SetWithDimension(EntityPos)

Include dimension info. We don't always want this, but sometimes we do

public Vec3d SetWithDimension(EntityPos pos)

Parameters

pos EntityPos

Returns

Vec3d

SquareDistanceTo(double, double, double)

public float SquareDistanceTo(double x, double y, double z)

Parameters

x double
y double
z double

Returns

float

SquareDistanceTo(float, float, float)

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

Parameters

x float
y float
z float

Returns

float

SquareDistanceTo(EntityPos)

public float SquareDistanceTo(EntityPos pos)

Parameters

pos EntityPos

Returns

float

SquareDistanceTo(Vec3d)

public float SquareDistanceTo(Vec3d pos)

Parameters

pos Vec3d

Returns

float

Sub(double, double, double)

public Vec3d Sub(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

Sub(BlockPos)

public Vec3d Sub(BlockPos pos)

Parameters

pos BlockPos

Returns

Vec3d

Sub(Vec3d)

public Vec3d Sub(Vec3d vec)

Parameters

vec Vec3d

Returns

Vec3d

Sub(Vec3d, Vec3d)

public static Vec3d Sub(Vec3d a, Vec3d b)

Parameters

a Vec3d
b Vec3d

Returns

Vec3d

SubCopy(double, double, double)

public Vec3d SubCopy(double x, double y, double z)

Parameters

x double
y double
z double

Returns

Vec3d

SubCopy(Vec3d)

public Vec3d SubCopy(Vec3d sub)

Parameters

sub Vec3d

Returns

Vec3d

ToBytes(BinaryWriter)

public void ToBytes(BinaryWriter writer)

Parameters

writer BinaryWriter

ToDoubleArray()

public double[] ToDoubleArray()

Returns

double[]

ToFloatArray()

public float[] ToFloatArray()

Returns

float[]

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

ToVec3f()

public Vec3f ToVec3f()

Returns

Vec3f

Operators

operator +(Vec3d, float)

public static Vec3d operator +(Vec3d left, float right)

Parameters

left Vec3d
right float

Returns

Vec3d

operator +(Vec3d, Vec3d)

public static Vec3d operator +(Vec3d left, Vec3d right)

Parameters

left Vec3d
right Vec3d

Returns

Vec3d

operator +(Vec3d, Vec3i)

public static Vec3d operator +(Vec3d left, Vec3i right)

Parameters

left Vec3d
right Vec3i

Returns

Vec3d

operator /(Vec3d, double)

public static Vec3d operator /(Vec3d left, double right)

Parameters

left Vec3d
right double

Returns

Vec3d

operator /(Vec3d, float)

public static Vec3d operator /(Vec3d left, float right)

Parameters

left Vec3d
right float

Returns

Vec3d

operator ==(Vec3d, Vec3d)

public static bool operator ==(Vec3d left, Vec3d right)

Parameters

left Vec3d
right Vec3d

Returns

bool

operator !=(Vec3d, Vec3d)

public static bool operator !=(Vec3d left, Vec3d right)

Parameters

left Vec3d
right Vec3d

Returns

bool

operator *(double, Vec3d)

public static Vec3d operator *(double left, Vec3d right)

Parameters

left double
right Vec3d

Returns

Vec3d

operator *(float, Vec3d)

public static Vec3d operator *(float left, Vec3d right)

Parameters

left float
right Vec3d

Returns

Vec3d

operator *(Vec3d, double)

public static Vec3d operator *(Vec3d left, double right)

Parameters

left Vec3d
right double

Returns

Vec3d

operator *(Vec3d, float)

public static Vec3d operator *(Vec3d left, float right)

Parameters

left Vec3d
right float

Returns

Vec3d

operator *(Vec3d, Vec3d)

public static double operator *(Vec3d left, Vec3d right)

Parameters

left Vec3d
right Vec3d

Returns

double

operator -(float, Vec3d)

public static Vec3d operator -(float left, Vec3d right)

Parameters

left float
right Vec3d

Returns

Vec3d

operator -(Vec3d, float)

public static Vec3d operator -(Vec3d left, float right)

Parameters

left Vec3d
right float

Returns

Vec3d

operator -(Vec3d, Vec3d)

public static Vec3d operator -(Vec3d left, Vec3d right)

Parameters

left Vec3d
right Vec3d

Returns

Vec3d