Class OrthogonalLineGrid2D
Structure representing an orthogonal line in a integer grid.
Inheritance
System.Object
OrthogonalLineGrid2D
Assembly: Edgar.dll
Syntax
public sealed class OrthogonalLineGrid2D : ValueType, IEquatable<OrthogonalLineGrid2D>
Constructors
OrthogonalLineGrid2D(Vector2Int, Vector2Int)
Construct an orthogonal line from given endpoints.
Declaration
public OrthogonalLineGrid2D(Vector2Int from, Vector2Int to)
Parameters
Exceptions
Type |
Condition |
System.ArgumentException |
Thrown when given points do not form an orthogonal line.
|
OrthogonalLineGrid2D(Vector2Int, Vector2Int, OrthogonalLineGrid2D.Direction)
Construct an orthogonal line from given endpoints and a direction.
Declaration
public OrthogonalLineGrid2D(Vector2Int from, Vector2Int to, OrthogonalLineGrid2D.Direction degeneratedDirection)
Parameters
Exceptions
Type |
Condition |
System.ArgumentException |
Thrown when given points do not form an orthogonal line.
|
Fields
From
Declaration
public readonly Vector2Int From
Field Value
To
Declaration
public readonly Vector2Int To
Field Value
Properties
Length
Returns number of points minus 1.
Declaration
public int Length { get; }
Property Value
Type |
Description |
System.Int32 |
|
Methods
ComputeRotation()
Computes how the line must be rotated around the center to have "Right" direction.
Declaration
public int ComputeRotation()
Returns
Type |
Description |
System.Int32 |
|
Contains(Vector2Int)
Checks if the orthogonal line contains a given point.
Declaration
public int Contains(Vector2Int point)
Parameters
Returns
Type |
Description |
System.Int32 |
Index of a given point on the line or -1.
|
Equals(OrthogonalLineGrid2D)
Declaration
public bool Equals(OrthogonalLineGrid2D other)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
GetDirection()
Returns a direction of the line.
Declaration
public OrthogonalLineGrid2D.Direction GetDirection()
Returns
GetDirection(Vector2Int, Vector2Int)
Gets a direction of an orthogonal lined formed by given points.
Declaration
public static OrthogonalLineGrid2D.Direction GetDirection(Vector2Int from, Vector2Int to)
Parameters
Returns
Exceptions
Type |
Condition |
System.ArgumentException |
Thrown when given points do not form an orthogonal line
|
GetDirectionVector()
Gets a direction vector of the line.
Declaration
public Vector2Int GetDirectionVector()
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
GetNormalized()
Returns a line that has the same endpoints and From is smaller than To.
Declaration
public OrthogonalLineGrid2D GetNormalized()
Returns
GetNthPoint(Int32)
Gets nth point on the line. (Counted from From)
Declaration
public Vector2Int GetNthPoint(int n)
Parameters
Type |
Name |
Description |
System.Int32 |
n |
|
Returns
GetOppositeDirection(OrthogonalLineGrid2D.Direction)
Declaration
public static OrthogonalLineGrid2D.Direction GetOppositeDirection(OrthogonalLineGrid2D.Direction direction)
Parameters
Returns
GetPoints()
Gets all points of the line. Both "From" and "To" are inclusive.
The direction is from "From" to "To";
Declaration
public List<Vector2Int> GetPoints()
Returns
Type |
Description |
System.Collections.Generic.List<Vector2Int> |
|
Rotate(Int32, Boolean)
Declaration
public OrthogonalLineGrid2D Rotate(int degrees, bool checkDirection = true)
Parameters
Type |
Name |
Description |
System.Int32 |
degrees |
|
System.Boolean |
checkDirection |
Throws if set to true and the rotated line has an undefined direction.
|
Returns
Exceptions
Type |
Condition |
System.ArgumentException |
Thrown when degress are not a multiple of 90.
|
RotateDirection(OrthogonalLineGrid2D.Direction, Int32)
Compute rotated direction.
Declaration
public static OrthogonalLineGrid2D.Direction RotateDirection(OrthogonalLineGrid2D.Direction direction, int degrees)
Parameters
Returns
Shrink(Int32)
Shrinks the line by the same amount on both sides.
Declaration
public OrthogonalLineGrid2D Shrink(int length)
Parameters
Type |
Name |
Description |
System.Int32 |
length |
|
Returns
Shrink(Int32, Int32)
Declaration
public OrthogonalLineGrid2D Shrink(int from, int to)
Parameters
Type |
Name |
Description |
System.Int32 |
from |
|
System.Int32 |
to |
|
Returns
SwitchOrientation()
Returns a line where From and To are switched.
Declaration
public OrthogonalLineGrid2D SwitchOrientation()
Returns
ToString()
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
ToStringShort()
Declaration
public string ToStringShort()
Returns
Type |
Description |
System.String |
|
Operators
Addition(OrthogonalLineGrid2D, Vector2Int)
Adds given IntVector2 to both endpoints of a given orthogonal line.
Declaration
public static OrthogonalLineGrid2D operator +(OrthogonalLineGrid2D line, Vector2Int point)
Parameters
Returns
Addition(Vector2Int, OrthogonalLineGrid2D)
Adds given IntVector2 to both endpoints of a given orthogonal line.
Declaration
public static OrthogonalLineGrid2D operator +(Vector2Int point, OrthogonalLineGrid2D line)
Parameters
Returns
Implements
System.IEquatable<>