Struct LinePoint
Represents 1D grid points. These are auto-convertible to integers, making it possible to
write, for example, grid[6]
instead of grid[new LinePoint(6)]
.
[Version(1, 8, 0)]
public struct LinePoint : IGridPoint<LinePoint>, IEquatable<LinePoint>, IGridPoint, IVectorPoint<LinePoint>, ISplicedVectorPoint<LinePoint, LinePoint>
- Implements
- Inherited Members
- Extension Methods
Constructors
LinePoint(int)
public LinePoint(int n)
Parameters
n
int
Fields
Left
Add this to another LinePoint to get the point to the left (negative side) of the other point.
public static readonly LinePoint Left
Field Value
Right
Add this to another LinePoint to get the point to the right (positive side) of the other point.
public static readonly LinePoint Right
Field Value
Zero
public static readonly LinePoint Zero
Field Value
Properties
SpliceCount
For spliced grids, this is the number of slices for all points.
For Uniform grids, this is always 1.
public int SpliceCount { get; }
Property Value
SpliceIndex
For spliced grids, this is the index of the splice.
For Uniform grids, this is always 0.
public int SpliceIndex { get; }
Property Value
X
public int X { get; }
Property Value
Y
public int Y { get; }
Property Value
Methods
DistanceFrom(LinePoint)
The lattice distance between two points.
Two points should have a distance of 1 if and only if they are neighbors.
public int DistanceFrom(LinePoint other)
Parameters
other
LinePoint
Returns
Div(LinePoint)
Integer divides a point by another point component by component.
public LinePoint Div(LinePoint other)
Parameters
other
LinePoint
Returns
Examples
(-5, 5) Div(2, 2) == (-3, 2)
Remarks
Remainders are always positive.
Equals(LinePoint)
public bool Equals(LinePoint other)
Parameters
other
LinePoint
Returns
GetColor(int)
public int GetColor(int colorCount)
Parameters
colorCount
int
Returns
Magnitude()
public int Magnitude()
Returns
Mod(LinePoint)
Integer divides a point component by component and returns the remainder.
public LinePoint Mod(LinePoint other)
Parameters
other
LinePoint
Returns
Examples
(-5, 5) Mod (2, 2) == (1, 1)
Remarks
Remainders are always positive.
MoveBackBy(LinePoint)
If a spliced vectors u and v has base vector B and index I
public LinePoint MoveBackBy(LinePoint splicedVector)
Parameters
splicedVector
LinePoint
Returns
Remarks
new SplicedVector(u.B.Subtract(v.B), (SpliceCount + u.I - v.I) % SpliceCount))
MoveBy(LinePoint)
If a spliced vectors u and v has base vector B and index I,
public LinePoint MoveBy(LinePoint splicedVector)
Parameters
splicedVector
LinePoint
Returns
Remarks
This operation is the same as
new SplicedVector(u.B.Translate(v.B), (u.I + v.I) % SpliceCount))
Mul(LinePoint)
Multiplies two points component by component.
public LinePoint Mul(LinePoint other)
Parameters
other
LinePoint
Returns
Examples
(-5, 5) Mul (2, 2) == (-10, 10)
Negate()
Returns a new point with the vector component negated.
public LinePoint Negate()
Returns
ScaleDown(int)
Scales this vector by the given amount.
public LinePoint ScaleDown(int r)
Parameters
r
int
Returns
Examples
v.ScaleUp(1)
v.ScaleUp(n) == v.ScaleUp(n - 1).Translate(v)
ScaleUp(int)
public LinePoint ScaleUp(int r)
Parameters
r
int
Returns
Subtract(LinePoint)
Translates this point by the negation of the given vector.
public LinePoint Subtract(LinePoint vector)
Parameters
vector
LinePoint
Returns
ToString()
public override string ToString()
Returns
Translate(LinePoint)
Translate this point by the given vector.
public LinePoint Translate(LinePoint vector)
Parameters
vector
LinePoint
Returns
Operators
implicit operator int(LinePoint)
public static implicit operator int(LinePoint point)
Parameters
point
LinePoint
Returns
implicit operator LinePoint(int)
public static implicit operator LinePoint(int n)
Parameters
n
int