override public FlatHexPoint RawWorldToGrid(Vector2 point) { int x = GLMathf.FloorToInt((point.x + cellDimensions.x / 2) / cellDimensions.x); int y = GLMathf.FloorToInt((point.y - x * cellDimensions.y / 2 + cellDimensions.y / 2) / cellDimensions.y); return(new FlatHexPoint(x, y)); }
/** * Gives a new point that represents the * reminder when the first point is divided * by the second point component-wise. The * division is integer division. * * @since 1.6 (Rect) * @since 1.7 (other) */ public DiamondPoint Mod(DiamondPoint otherPoint) { var x = GLMathf.Mod(X, otherPoint.X); var y = GLMathf.Mod(Y, otherPoint.Y); return(new DiamondPoint(x, y)); }
public DiamondShapeInfo <TCell> FatRectangle(int width, int height) { int diamondSize = width + GLMathf.Div(height, 2); var storageBottomLeft = new DiamondPoint(0, 1 - width); return(Shape(diamondSize, diamondSize, p => IsInsideFatRectangle(p, width, height), storageBottomLeft)); }
public override IEnumerable <Vector3> GetVertices(IExplicitShape <int> shape, GridMap <int> map) { return(shape .Points .SelectMany(p => vertices[GLMathf.FloorMod((int)p, colorFunction.x0)] .Select(q => map.GridToWorld(q + map.DeRound(p))))); }
/// <summary> /// Gives a new point that represents the /// first point divided by the second point /// component-wise. The division is integer /// division. /// /// Since version 1.6 (Rect) /// Since version 1.7 (other) /// </summary> public DiamondPoint Div(DiamondPoint otherPoint) { var x = GLMathf.FloorDiv(X, otherPoint.X); var y = GLMathf.FloorDiv(Y, otherPoint.Y); return(new DiamondPoint(x, y)); }
public VectorPoint Div(VectorPoint other) { var newX = GLMathf.FloorDiv(x, other.X); var newY = GLMathf.FloorDiv(y, other.Y); return(new VectorPoint(newX, newY)); }
/// <summary> /// Gives a new point that represents the /// first point divided by the second point /// component-wise. The division is integer /// division. /// /// Since version 1.6 (Rect) /// Since version 1.7 (other) /// </summary> public FlatHexPoint Div(FlatHexPoint otherPoint) { var x = GLMathf.FloorDiv(X, otherPoint.X); var y = GLMathf.FloorDiv(Y, otherPoint.Y); return(new FlatHexPoint(x, y)); }
/// <summary> /// Gives a new point that represents the /// first point divided by the second point /// component-wise. The division is integer /// division. /// /// Since version 1.6 (Rect) /// Since version 1.7 (other) /// </summary> public RectPoint Div(RectPoint otherPoint) { var x = GLMathf.FloorDiv(X, otherPoint.X); var y = GLMathf.FloorDiv(Y, otherPoint.Y); return(new RectPoint(x, y)); }
/** * Gives a new point that represents the * reminder when the first point is divided * by the second point component-wise. The * division is integer division. * * @since 1.6 (Rect) * @since 1.7 (other) */ public RectPoint Mod(RectPoint otherPoint) { var x = GLMathf.Mod(X, otherPoint.X); var y = GLMathf.Mod(Y, otherPoint.Y); return(new RectPoint(x, y)); }
/// <summary> /// Gives a new point that represents the /// reminder when the first point is divided /// by the second point component-wise. The /// division is integer division. /// /// Since version 1.6 (Rect) /// Since version 1.7 (other) /// </summary> public PointyHexPoint Mod(PointyHexPoint otherPoint) { var x = GLMathf.FloorMod(X, otherPoint.X); var y = GLMathf.FloorMod(Y, otherPoint.Y); return(new PointyHexPoint(x, y)); }
public override IEnumerable <Vector3> GetNormals(IExplicitShape <int> shape, GridMap <int> map, bool flip) { return(shape .Points .SelectMany(p => vertices[GLMathf.FloorMod(p, colorFunction.x0)] .Select((q, i) => map.GridToWorld(q + map.DeRound(p) + (flip ? -normals[GLMathf.FloorMod(p, colorFunction.x0)][i] : normals[GLMathf.FloorMod(p, colorFunction.x0)][i])).normalized))); }
/** * Gives a new point that represents the * reminder when the first point is divided * by the second point component-wise. The * division is integer division. * * @since 1.6 (Rect) * @since 1.7 (other) */ public FlatHexPoint Mod(FlatHexPoint otherPoint) { var x = GLMathf.Mod(X, otherPoint.X); var y = GLMathf.Mod(Y, otherPoint.Y); return(new FlatHexPoint(x, y)); }
/** * Gives a new point that represents the * first point divided by the second point * component-wise. The division is integer * division. * * @since 1.6 (Rect) * @since 1.7 (other) */ public PointyHexPoint Div(PointyHexPoint otherPoint) { var x = GLMathf.Div(X, otherPoint.X); var y = GLMathf.Div(Y, otherPoint.Y); return(new PointyHexPoint(x, y)); }
public VectorPoint Mod(VectorPoint other) { var newX = GLMathf.Mod(x, other.X); var newY = GLMathf.Mod(y, other.Y); return(new VectorPoint(newX, newY)); }
public PointyHexShapeInfo <TCell> ThinRectangle(int width, int height) { int storageWidth = width + GLMathf.Div(height - 1, 2); int storageHeight = height; var storageBottomLeft = new PointyHexPoint(-GLMathf.Div(height - 1, 2), 0); return(Shape(storageWidth, storageHeight, x => IsInsideThinRectangle(x, width, height), storageBottomLeft)); }
public GridPoint3 FloorMod(GridPoint3 otherPoint) { var modX = GLMathf.FloorMod(X, otherPoint.X); var modY = GLMathf.FloorMod(Y, otherPoint.Y); var modZ = GLMathf.FloorMod(Z, otherPoint.Z); return(new GridPoint3(modX, modY, modZ)); }
private static IExplicitShape <GridPoint2> GetThinRectangle(GridPoint2 size) { int storageWidth = size.X + GLMathf.FloorDiv(size.Y - 1, 2); int storageHeight = size.Y; var storagePoint = new GridPoint2(-GLMathf.FloorDiv(size.Y - 1, 2), 0); return(ImplicitShape.HexThinRectangle(size).ToExplicit(new GridRect(storagePoint, new GridPoint2(storageWidth, storageHeight)))); }
public GridPoint3 FloorDiv(GridPoint3 otherPoint) { var divX = GLMathf.FloorDiv(X, otherPoint.X); var divY = GLMathf.FloorDiv(Y, otherPoint.Y); var divZ = GLMathf.FloorDiv(Z, otherPoint.Z); return(new GridPoint3(divX, divY, divZ)); }
public static IImplicitShape <GridPoint2> FlatHexThinRectangle(GridPoint2 dimensions) { return(new FunctionShape <GridPoint2>(point => point.Y >= -(GLMathf.FloorDiv(point.X, 2)) && point.Y + GLMathf.FloorMod(point.X, 2) < -(GLMathf.FloorDiv(point.X, 2)) + dimensions.Y && point.X >= 0 && point.X < dimensions.X)); }
public static IImplicitShape <GridPoint2> HexRectangle(GridPoint2 dimensions) { return(new FunctionShape <GridPoint2>(point => point.Y >= 0 && point.Y < dimensions.Y && point.X >= -GLMathf.FloorDiv(point.Y, 2) && point.X < -GLMathf.FloorDiv(point.Y, 2) + dimensions.X)); }
public FlatHexShapeInfo <TCell> ThinRectangle(int width, int height) { var storageWidth = width; var storageHeight = height + GLMathf.FloorDiv(width - 1, 2); var storageBottomLeft = new FlatHexPoint(0, -GLMathf.FloorDiv(width - 1, 2)); return(Shape(storageWidth, storageHeight, x => IsInsideThinRectangle(x, width, height), storageBottomLeft)); }
public static IImplicitShape <GridPoint2> PointyHexThinRectangle(GridPoint2 dimensions) { return(new FunctionShape <GridPoint2>(point => point.X >= -GLMathf.FloorDiv(point.Y, 2) && point.X + GLMathf.FloorMod(point.Y, 2) < -GLMathf.FloorDiv(point.Y, 2) + dimensions.X && point.Y >= 0 && point.Y < dimensions.Y)); }
public override LinePoint RawWorldToGrid(Vector2 worldPoint) { var point = (worldPoint + cellDimensions / 2); var m = GLMathf.FloorToInt(point.x / cellDimensions.x); return(m); }
public DiamondShapeInfo <TCell> Rectangle(int width, int height) { //Note: this fit is not the tightest possible. int diamondSize = width + GLMathf.Div(height, 2); var storageBottomLeft = new DiamondPoint(0, 1 - width); return(Shape(diamondSize, diamondSize, p => IsInsideRaggedRectangle(p, width, height), storageBottomLeft)); }
public IEnumerable <RectPoint> GetEdgeFaces() { var edgeAnchor = GetEdgeFaceAnchor(); int edgeIndex = GLMathf.Mod(X + Y, 2); return(from faceDirection in EdgeFaceDirections[edgeIndex] select faceDirection + edgeAnchor); }
private static bool IsInsideThinRectangle(PointyHexPoint point, int width, int height) { int startX = -(GLMathf.FloorDiv(point.Y, 2)); return (point.X >= startX && point.X + GLMathf.FloorMod(point.Y, 2) < startX + width && point.Y >= 0 && point.Y < height); }
private IExplicitShape <GridPoint2> GetFlatRectangle(GridPoint2 size) { var storageWidth = size.X; var storageHeight = size.Y + GLMathf.FloorDiv(size.X - 1, 2); var storageBottomLeft = new GridPoint2(0, -GLMathf.FloorDiv(size.X - 1, 2)); return (ImplicitShape.FlatHexRectangle(size) .ToExplicit(new GridRect(storageBottomLeft, new GridPoint2(storageWidth, storageHeight)))); }
private static bool IsInsideFatRectangle(PointyHexPoint point, int width, int height) { int startX = -(GLMathf.Div(point.Y, 2)); return (point.X >= startX - GLMathf.Mod(point.Y, 2) && point.X < startX + width && point.Y >= 0 && point.Y < height); }
private bool IsInsideThinRectangle(FlatHexPoint point, int width, int height) { int startY = -(GLMathf.FloorDiv(point.X, 2)); return (point.Y >= startY && point.Y + GLMathf.FloorMod(point.X, 2) < startY + height && point.X >= 0 && point.X < width); }
private static bool IsInsideFatRectangle(FlatHexPoint point, int width, int height) { int startY = -(GLMathf.FloorDiv(point.X, 2)); return (point.Y >= startY - GLMathf.FloorMod(point.X, 2) && point.Y < startY + height && point.X >= 0 && point.X < width); }