Point

Namespace: Murder.Core.Geometry
Assembly: Murder.dll

public sealed struct Point : IEquatable<T>

Represents a single point with coordinates Point.Y. Points are also often used to store sizes, with X marking the right of an object and Y marking its bottom.

Implements: IEquatable<T>

⭐ Constructors

public Point(float x, float y)

Creates a point by rounding the x and y parameters.

Parameters
x float
y float

public Point(int v)

Creates a point where both x and y and equal to v.

Parameters
v int

public Point(int x, int y)

Creates a point.

Parameters
x int
y int

⭐ Properties

Down

public static Point Down { get; }

Point with coordinates X = 0 and Y = 1.

Returns
Point

Flipped

public static Point Flipped { get; }

Point with coordinates X = -1 and Y = 1 (multiply your point by this and you get its mirror).

Returns
Point

HalfCell

public static Point HalfCell { get; }

Represents half a cell on the current Grid.

Returns
Point

One

public static Point One { get; }

Point with coordinates X = 1 and Y = 1.

Returns
Point

X

public int X;

The value of X in this point.

Returns
int

XY

public ValueTuple<T1, T2> XY { get; }

Destructuring helper for obtaining a tuple from this point.

Returns
ValueTuple<T1, T2>

Y

public int Y;

The value of Y in this point.

Returns
int

Zero

public static Point Zero { get; }

Point with coordinates X = 0 and Y = 0.

Returns
Point

⭐ Methods

Length()

public float Length()

Calculates the length of this point.

Returns
float

LengthSquared()

public int LengthSquared()

Returns the length of this point, squared (IOW: X * X + Y * Y).

Returns
int

Mirror(Point)

public Point Mirror(Point center)

Returns the mirror of this point across the X axis relative to the center point

Parameters
center Point

Returns
Point

Scale(Point)

public Point Scale(Point other)

Equivalent to this * other.

Parameters
other Point

Returns
Point

ToWorldPosition()

public Point ToWorldPosition()

Converts this point into a world position by multiplying it by the cell size.

Returns
Point

BreakInTwo()

public ValueTuple<T1, T2> BreakInTwo()

Deconstruction helper for obtaining a tuple from this point.

Returns
ValueTuple<T1, T2>

ToVector2()

public Vector2 ToVector2()

Converts this point into a Vector2 with the same X and Y values.

Returns
Vector2

ToVector3()

public Vector3 ToVector3()

Returns
Vector3

Equals(Point)

public virtual bool Equals(Point other)

Compares whether the point has the same X and Y value as this point.

Parameters
other Point

Returns
bool

Equals(Object)

public virtual bool Equals(Object obj)

Parameters
obj Object

Returns
bool

GetHashCode()

public virtual int GetHashCode()

Returns
int

ToString()

public virtual string ToString()

Returns
string

Deconstruct(out Int32&, out Int32&)

public void Deconstruct(Int32& x, Int32& y)

Parameters
x int&
y int&