/// <returns>typeof Direction</returns> public int GetFromAndFillType(Direction to, Basin3 toBasin, HealpixManager man) { if (Ring == toBasin.Ring) { Type = to; } var vert = NeighborManager.GetVert(to); if (Ring == 1 && vert == NeighborVert.North || Ring == man.RingsCount && vert == NeighborVert.South || Type == to) { return((int)NeighborManager.GetOppositeHor(to)); } return((int)NeighborManager.GetOpposite(to)); }
protected override void CalcDeltasH() { foreach (var basin in PixMan.Pixels) { if (basin.HasWater() // && basin.P==62 ) { // -.5Pi .. 1.5Pi var alphas = new double[4]; // Pi .. .5Pi var gammas = new double[4]; var lengths = new double[4]; var normLengths = new double[4]; foreach (Direction to in Enum.GetValues(typeof(Direction))) { var toBasin = basin.Neibors[to]; var deltaBeta = (basin.Beta - toBasin.Beta).Value; var deltaLambda = (basin.Lambda - toBasin.Lambda).Value * basin.BetaSin ; //*2; var length = Math.Sqrt(deltaBeta * deltaBeta + deltaLambda * deltaLambda); lengths[(int)to] = length; //var asin = Math.Asin(deltaBeta / length); //alphas[(int) to] = deltaLambda > 0 ? asin : Math.PI - asin; gammas[(int)to] = Math.Atan(Math.Abs(deltaBeta / deltaLambda)); } /*foreach (int to in Enum.GetValues(typeof(Direction))) * { * lengths[to] = lengths.Max() - lengths[to]; * }*/ foreach (int to in Enum.GetValues(typeof(Direction))) { normLengths[to] = lengths[to] / lengths.Sum(); } //todo exclude second calculaton of the same pair, set and look on basin.Volumes foreach (Direction to in Enum.GetValues(typeof(Direction))) { var toBasin = basin.Neibors[to]; double HtoVer; var hor = NeighborManager.GetHor(to); var HtoHor = basin.Hto[2 + hor] - toBasin.Hto[2 + 1 - hor]; //(basin.hOQ - toBasin.hOQ) //not r because of bottom relief * 1; //hack if (Math.Abs(HtoHor) > 10) { } var vert = NeighborManager.GetVert(to); if (basin.Ring == 1 && vert == NeighborVert.North || basin.Ring == HealpixManager.RingsCount && vert == NeighborVert.South || basin.Type == to) { basin.froms[(int)to] = (int)NeighborManager.GetOppositeHor(to); HtoVer = 0; } else { var from = NeighborManager.GetOpposite(to); basin.froms[(int)to] = (int)from; HtoVer = basin.Hto[(int)vert] - toBasin.Hto[1 - (int)vert]; //if (basin.Type == from && HtoVer < 0) HtoVer = -HtoVer * .5;//hack } var deltaHfull = Math.Sin(gammas[(int)to]) * HtoVer + Math.Cos(gammas[(int)to]) * HtoHor; basin.deltasH[(int)to] = deltaHfull * normLengths[(int)to]; if (Math.Abs(basin.deltasH[(int)to]) > 100 || basin.P == 17) { } } } } }