## unity – How do I sort edge tiles for a hex grid in order to draw a border?

I am trying to sort the edge tiles of a region in my hexagon map. Once it is properly sorted, I can then try to walk through them and attempt at creating a Civ style border map, but I can’t seem to figure out the sorting.

Right now I just have a simple line renderer that represents my results. Red portion of the gradient represents the start of the line. It comes quite close at times. I tried playing around with checking the direction I was coming from to change the neighbor sort, but haven’t had any luck. I added a Stack so that I can walk back if I hit a dead end. Sometimes it works, but depends on the direction it was coming from.

Don’t necessarily pay too much attention to the coordinates themselves. I’ve gone through the entire https://www.redblobgames.com/ docs and can easily convert from a 2D grid, to Unity’s Offset, and to Cube coordinates. This particular code is initially the coordinates from a `int(,)` that was used in the procedural generation of the map.

``````public void CalculateEdgeTiles(ref int(,) regionMap)
{
EdgeTiles = new HashSet<MapCoord>();
if (Tiles == null)
throw new Exception();

MapCoord startingEdgeTile = null;

foreach (var tile in Tiles)
{
foreach(var neighbor in tile.Position.ToHexOffsetCoordinateRing(1, true))
{
if (regionMap(neighbor.x, neighbor.y) != tile.RegionId)
{
}
}
}

var sortedTiles = new List<MapCoord>();
var queue = new Queue<MapCoord>();
var stack = new Stack<MapCoord>();

queue.Enqueue(EdgeTiles.First());

var walkingBack = false;
MapCoord previousTile = null;
while (queue.Count > 0)
{
var currentTile = queue.Dequeue();
if (sortedTiles.Contains(currentTile))
continue;

if (!walkingBack)
{
stack.Push(currentTile);
}

var foundNeighbors = new List<MapCoord>();

foreach (var neighbor in currentTile.Position.ToHexOffsetCoordinateRing(1, true))
{
var tile = Tiles.FirstOrDefault(x => x.Position == neighbor);
if (tile == null || !EdgeTiles.Contains(tile) || sortedTiles.Contains(tile))
continue;

}

if (previousTile == null)
previousTile = currentTile;

var neighborQuery = previousTile.Position.y < currentTile.Position.y
? foundNeighbors.OrderByDescending(x => x.Position.x + x.Position.y)
: foundNeighbors.OrderBy(x => x.Position.x + x.Position.y);
foreach (var neighborTile in neighborQuery)
{
queue.Enqueue(neighborTile);
break;
}

walkingBack = false;
//If we added nothing, pop the stack and start walking back to check the next neighbor.
if (!addedNeighbor && EdgeTiles.Count != sortedTiles.Count)
{
walkingBack = true;
queue.Enqueue(stack.Pop());
}

previousTile = currentTile;
}

EdgeTiles = new HashSet<MapCoord>(sortedTiles);
}
``````

I’m hoping I am just missing a simple trick or I was just dumb on one section of the code. Any info is appreciated.

## In doubly connected edge list how to link halfedges properly

I’m working on doubly connected edge list. In the image below I need to add a new edge (consisting of halfedges $$g$$ and $$h$$). When adding a new edge we need to assign each half edge a previous and next half edges. In this example edge $$g$$ would have halfedge $$f$$ and $$h$$ as previous and next halfedges respectively. And edge $$h$$ would have halfedge $$g$$ and $$a$$ as previous and next halfedges respectively. If we ignore for a second them being linked to each other, $$g$$ and $$h$$ are linked to the pair $$f$$ and $$a$$. I hope this makes sense. My question is when adding a new edge, how do we know how to choose the correct pair to link to? In this example we could link our halfedges to the pair $$a, f$$ or $$c,b$$, or $$e,d$$. Do we have to resort to linear algebra, doing cross/dot product calculations to calculate what pair of halfedges to choose, based on the geometry of the edges? Am I possibly going in the completely wrong direction?

To get the potential canditates of pair of halfedges to link to, I iterate through all halfedges linked to vertex $$v$$, which here would be $$a,c,e$$ and for each I find the previous halfedge which would $$f, b,d$$ respectively. Posted on

## mathematical optimization – SemidefiniteProgramming for operator norms: Stuck at the edge of dual feasibility

I’m trying to calculate operator norms of linear transformations over space of matrices. For instance, find norm of $$f(A)=XA$$ by optimizing following:

$$max_{|A|=1} |XA|$$

This looks like a semidefinite programme, but I’m having trouble solving it with SemidefiniteOptimization. Simplest failing example is to find operator norm of $$f(A)=5A$$ in 1 dimension. It fails with `Stuck at the edge of dual feasibility`. Any suggestions?

Constraints
$$A succ 0\ Isucc A \ x I succ -5 A$$
Objective

$$text{min}_{A,x} x$$

``````d = 1;
ii = IdentityMatrix(d);
(* Symbolic symmetric d-by-d matrix *)
ClearAll(a);
X = 5*ii;
A = Array(a(Min(#1, #2), Max(#1, #2)) &, {d, d});
vars = DeleteDuplicates(Flatten(A));

cons0 = VectorGreaterEqual({A, 0}, {"SemidefiniteCone", d});
cons1 = VectorGreaterEqual({ii, A}, {"SemidefiniteCone", d});
cons2 = VectorGreaterEqual({x ii, -X.A}, {"SemidefiniteCone", d});
SemidefiniteOptimization(x, cons0 && cons1 && cons2, {x}~Join~vars)
$$```$$
``````

Posted on

## Resellerclub Interface does not work on Firefox, Edge, IE

Hello to everyone. Resellerclub Interface is not working properly on Firefox, Edge, IE browsers(except Chrome). For example; I cannot give a… | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1819860&goto=newpost
Posted on

## Line Render Neon effect in unity : how to over LineRender edge overlapping

I have follow this tutorial how to make 2d neon using linerender post and get neon effect nicely but when i draw a line with small circle even overlap a line with small edge its going worst shade is not my working part so im not expert in it… see the problem is . im stuck to find any solution there is nothing much about linerender or neon line effect in unity on internet..

im using this alpha image and apply this shader on linerender

{
Properties
{
(PerRendererData) _MainTex(“Sprite Texture”, 2D) = “white” {}
_Color(“Tint”, Color) = (1,1,1,1)
_MainTexture(“Sprite”, 2D) = “white” {}
(MaterialToggle) PixelSnap(“Pixel snap”, Float) = 0
}

``````    SubShader
{
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
"PreviewType" = "Plane"
"CanUseSpriteAtlas" = "True"
}

Cull Off
Lighting Off
ZWrite Off
Blend One OneMinusSrcAlpha

Pass
{
CGPROGRAM
``````

#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile _ PIXELSNAP_ON
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
#include “UnityCG.cginc”

``````    struct appdata_t
{
float4 vertex   : POSITION;
float4 color    : COLOR;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct v2f
{
float4 vertex   : SV_POSITION;
fixed4 color : COLOR;
float2 texcoord  : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};

fixed4 _Color;

v2f vert(appdata_t IN)
{
v2f OUT;
UNITY_SETUP_INSTANCE_ID(IN);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
OUT.vertex = UnityObjectToClipPos(IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color;
``````

#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap(OUT.vertex);
#endif

``````    return OUT;
}

sampler2D _MainTexture;
sampler2D _AlphaTex;

fixed4 SampleSpriteTexture(float2 uv)
{
fixed4 color = tex2D(_MainTexture, uv);
``````

#if ETC1_EXTERNAL_ALPHA
// get the color from an external texture (usecase: Alpha support for ETC1 on android)
color.a = tex2D(_AlphaTex, uv).r;
#endif //ETC1_EXTERNAL_ALPHA

``````    return color;
}

fixed4 frag(v2f IN) : SV_Target
{
//standard sprite shader, only this part is different.
//takes the sprite in
fixed4 s = SampleSpriteTexture(IN.texcoord);

//makes a colored version of the sprite
fixed4 c = s * IN.color;

//makes the grayscale version
fixed n = (s.g + s.r + s.b) / 3;

//So, I've scrapped the previous calculation in favor of this I'll leave the previous one in too, just for reference
c = (c*3 + n*c.a)*c.a;
//Adds the grayscale version on top of the colored version
//The alpha multiplications give the neon effect feeling
//c.g = (c.g + n * c.a) * c.a;
//c.r = (c.r + n * c.a) * c.a;
//c.b = (c.b + n * c.a) * c.a;
// You can add c.a multiplications of colors
//(i.e. turn  c.g to c.g*c.a) for less color in your effect
//this saturates the insides a bit too much for my liking

return c;
}
ENDCG
}
}
``````

}`

anyone help me to find out the solution thanks in advance and its very appreciated .
special thanks to how to make 2d neon using linerender

Posted on

## reference request – Conjecture about minimal number of edge crossings in complete bipartite graphs

I am interested in the status of the conjecture about the minimum number of edge crossings $$cr(K_{m,n})$$ in a drawing of the complete bipartite graph $$K_{m,n}$$.

The Wikipedia article https://en.wikipedia.org/wiki/Tur%C3%A1n%27s_brick_factory_problem led me to study the original papers of Zarankiewicz (On a problem of P. Turan concerning graphs) from 1954 and of Urbanik (Solution du problème posé par P. Turán) from 1955.

I wondered whether someone could tell me whether an asymptotic approach has been successfully attempted (letting $$ntoinfty$$). If so, I would be very interested in any references for that.

Posted on

## code quality – Accounting for all types of edge cases within application

Is it necessary to account for rare edge cases within an application? For example, I am debating on two types UX when closing a modal when changes have been made to fields:

1. When a user taps to close a modal, I check if any fields were updated (setting a new value). If any text fields were updated, an alert pops up asking if they would like to leave before saving.

2. I check if the field value when the modal opened matches the value when tapping to close. For example, the user could have opened the modal with the value of “test” in the field, updated the field value to something else and then decided to undo the text by adding “test” back into the field. Should the user still be prompted with an alert asking if they would like to leave before saving their changes, even though this is the same text the user saw when opening the modal and made an update to the field, but deleted it?

It seems like #2 would be more of a rare edge case, but I feel like the user could be slightly confused of the alert because to them, the field never changed. With that said, is necessary to code this part of the application like #2 or #1?

Posted on

## search algorithms – Is there a function to, given a set of co-ordinates, return a list of co-ordinates on the edge

For example, return the coordinates (-1, 1) (0,0) (1,1) and (1,2) from the following cartesian plane Posted on

## windows – How to Disable Microsoft Edge Guest Browsing on

I would like to disable Guest Browsing on Windows 10 PC (home edition, so no group policy editor- do have registry edit) on Microsoft Edge (new).
I have found tutorials on how to disable incognito mode (which I have done) and how to disable guest browsing on other browsers but not Edge. How could I do this? I would like to disable all anonymous browsing- potentially applying this across multiple computers- that is provided by guest mode (only users with Microsoft log ins will be able to use the browser).

Posted on