Пример #1
0
        protected override void InternalFindNearest(IRow row)
        {
            var keyRow = EnsurePartialKeyRow(row);

            try
            {
                ClearBuffer();
                if (keyRow != null)
                {
                    // TODO: Expand this to work with multiple column searches
                    var rangeBound = new RangeBound {
                        Bound = keyRow[0], Inclusive = true
                    };
                    var range = CreateRange(Direction, rangeBound, null);
                    SourceFetch(false, Direction, range);
                }
            }
            finally
            {
                if (keyRow != null && !object.ReferenceEquals(row, keyRow))
                {
                    keyRow.Dispose();
                }
            }
        }
Пример #2
0
        protected override bool InternalFindKey(IRow row, bool forward)
        {
            var keyRow = EnsureKeyRow(row);

            try
            {
                // TODO: Expand this to work with multiple column searches
                var rangeBound = new RangeBound {
                    Bound = keyRow[0], Inclusive = true
                };
                var direction = (Direction == ScanDirection.Forward && forward || Direction == ScanDirection.Backward && !forward) ? ScanDirection.Forward : ScanDirection.Backward;
                var range     = CreateRange(direction, rangeBound, null);
                var set       = _db.GetRange(TableNodeColumns(), range, MaxLimit);
                if (set.Data.Count > 0)
                {
                    ProcessFetchData(set, false, direction);
                    return(true);
                }
                return(false);
            }
            finally
            {
                if (!object.ReferenceEquals(row, keyRow))
                {
                    keyRow.Dispose();
                }
            }
        }
Пример #3
0
    public List <Vector2> uniformDistance(RangeBound range, Vector2 center, float totalRotation = 0)
    {
        angles.Clear();
        List <Vector2> positions  = new List <Vector2>();
        int            n          = Random.Range(range.min, range.max);
        float          partAngles = (2 * Mathf.PI) / n;

        for (int i = 0; i < n; i++)
        {
            float rotation = Random.Range(-20 * Mathf.Deg2Rad, 20 * Mathf.Deg2Rad);
            float angle    = (partAngles * i) + rotation + totalRotation;
            angles.Add(angle);
            float   x   = Mathf.Cos(angle) * (radius_x);
            float   y   = Mathf.Sin(angle) * (radius_y);
            Vector2 pos = new Vector2(x, y) * Random.Range(minBound, maxBound);
            positions.Add(pos + center);
        }
        return(positions);
    }