Class Vec2i
Basic 2D point (or vector).
public class Vec2i : IEquatable<Vec2i>
- Inheritance
-
Vec2i
- Implements
- Inherited Members
- Extension Methods
Constructors
Vec2i(Vec2i)
Copy ctor.
public Vec2i(Vec2i src)
Parameters
src
Vec2isrc
Vec2i(BinaryReader)
Ctor by bytes: x = reader.ReadDouble(); y = reader.ReadDouble();
public Vec2i(BinaryReader reader)
Parameters
reader
BinaryReaderreader
Vec2i(int, int)
Ctor.
public Vec2i(int x = 0, int y = 0)
Parameters
Vec2i(int, int, int)
Ctor by direction offset. Direction 0,1 indicate x,y respectively.
public Vec2i(int dir, int a, int b)
Parameters
Vec2i(string)
Ctor by string. The format is (x,y).
public Vec2i(string src)
Parameters
src
stringsrc
Fields
x
Value at x direction.
public int x
Field Value
y
Value at y direction.
public int y
Field Value
Properties
AbsSum
Sum of abs(x) and abs(y).
public int AbsSum { get; }
Property Value
LengthSquare
Length square.
public int LengthSquare { get; }
Property Value
Max
Get max value from {x,y}.
public int Max { get; }
Property Value
MaxAbsDir
Get the direction of the max absolute value.
public int MaxAbsDir { get; }
Property Value
MaxDir
Get the direction of the max value.
public int MaxDir { get; }
Property Value
Min
Get min value from {x,y}.
public int Min { get; }
Property Value
NativeByteSize
public static int NativeByteSize { get; }
Property Value
- int
Byte size: sizeof(int) * 2.
One
Generate vec (1,1).
public static Vec2i One { get; }
Property Value
- Vec2i
(1,1)
UnitX
Generate vec (1,0).
public static Vec2i UnitX { get; }
Property Value
- Vec2i
(1,0)
UnitY
Generate vec (0,1).
public static Vec2i UnitY { get; }
Property Value
- Vec2i
(0,1)
Zero
Generate vec (0,0).
public static Vec2i Zero { get; }
Property Value
- Vec2i
(0,0)
Methods
At(int)
Member at direction.
public ref int At(int dir)
Parameters
dir
intdirection
Returns
- int
member
Cross(Vec2i)
Cross.
public int Cross(Vec2i src)
Parameters
src
Vec2isrc
Returns
- int
cross value
Dot(Vec2i)
Dot.
public int Dot(Vec2i src)
Parameters
src
Vec2isrc
Returns
- int
dotted value
Equals(Vec2i)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Vec2i other)
Parameters
other
Vec2iAn object to compare with this object.
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
GenOne()
Generate vec (1,1).
public static Vec2i GenOne()
Returns
- Vec2i
(1,1)
GenUnitX()
Generate vec (1,0).
public static Vec2i GenUnitX()
Returns
- Vec2i
(1,0)
GenUnitY()
Generate vec (0,1).
public static Vec2i GenUnitY()
Returns
- Vec2i
(0,1)
GenZero()
Generate vec (0,0).
public static Vec2i GenZero()
Returns
- Vec2i
(0,0)
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Output(BinaryWriter)
Output to bytes: writer.Write(x); writer.Write(y);
public void Output(BinaryWriter writer)
Parameters
writer
BinaryWriterwriter
Set(Vec2i)
Set values by copy.
public Vec2i Set(Vec2i src)
Parameters
src
Vec2isrc
Returns
- Vec2i
this
Set(int, int)
Set values.
public Vec2i Set(int x, int y)
Parameters
Returns
- Vec2i
this
Set(int, int, int)
Set values by direction offset. Direction 0,1,2 indicate x,y,z respectively.
public Vec2i Set(int dir, int a, int b)
Parameters
Returns
- Vec2i
this
Set(int[])
Set values by array.
public Vec2i Set(int[] xy)
Parameters
xy
int[]int[]{x,y}
Returns
- Vec2i
this
SetEachValueAbs()
Set all member to absolute value.
public Vec2i SetEachValueAbs()
Returns
- Vec2i
this
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
Operators
operator +(Vec2i, Vec2i)
Plus.
public static Vec2i operator +(Vec2i a, Vec2i b)
Parameters
Returns
- Vec2i
a+b
operator /(Vec2i, int)
a/d.
public static Vec2i operator /(Vec2i a, int d)
Parameters
Returns
- Vec2i
a/d
operator *(Vec2i, int)
a*s.
public static Vec2i operator *(Vec2i a, int s)
Parameters
Returns
- Vec2i
a*s
operator -(Vec2i, Vec2i)
a-b.
public static Vec2i operator -(Vec2i a, Vec2i b)
Parameters
Returns
- Vec2i
a-b
operator -(Vec2i)
Negate.
public static Vec2i operator -(Vec2i src)
Parameters
src
Vec2isrc
Returns
- Vec2i
Negate