예제 #1
0
        internal Feature Evaluate(Vector2 point)
        {
            float top = 0;
            float bottom = 0;
            float left = 0;
            float right = 0;
            Feature feature = new Feature(point);
            //validate point is in boundry

            ComputeTopBottom(point,ref top,ref bottom);
            ComputeLeftRight(point, ref left, ref right);

            //interpolate to find distance
            feature.Distance = GetBilinearInterpolatedDistance(point,top, bottom);

            //calc gradient to find normal
            feature.Normal = new Vector2(right - left, bottom - top);
            feature.Normal.Normalize();
            return feature;
        }
예제 #2
0
        internal Feature GetNearestFeature(Vector2 point)
        {
            Feature nearestFeature = new Feature();
            nearestFeature.Distance = float.MaxValue;

            for (int i = 0; i < _localVertices.Count; i++) {
                Feature feature = GetNearestFeature(point, i);
                if (feature.Distance < nearestFeature.Distance) {
                    nearestFeature = feature;
                }
            }
            return nearestFeature;
        }
예제 #3
0
        internal Feature Evaluate(Vector2 point)
        {
            Feature feature = new Feature(point);
            if(!Contains(point)){
                return feature;
            }

            //find the cell
            GridCell gridCell = FindContainingCell(point);

            //if grid is outide the geometry, return feature with default values (distance=float.MaxValue)
            if (gridCell.IsOutside) {
                return feature;
            }

            //point is known to be inside the geometry so some work is needed to get the 'Feature' details.
            feature = gridCell.Evaluate(point);
            return feature;
        }