private static int[] GetFieldCircle(Point point, double radiusX, double radiusY, FluidField2D field) { // Get the box that contains the return circle var center = GetFieldPoint_XY(point, field); var min = GetFieldPoint_XY(new Point(point.X - radiusX, point.Y - radiusY), field); var max = GetFieldPoint_XY(new Point(point.X + radiusX, point.Y + radiusY), field); // Get points that are inside the circle List<int> retVal = new List<int>(); double maxDistance = ((radiusX * field.XSize) + (radiusY * field.YSize)) * .5d; // just take the average. TODO: see if inside the ellipse double maxDistanceSquared = maxDistance * maxDistance; for (int x = min.Item1; x <= max.Item1; x++) { for (int y = min.Item2; y <= max.Item2; y++) { double dx = x - center.Item1; double dy = y - center.Item2; double distanceSquared = (dx * dx) + (dy * dy); if (distanceSquared <= maxDistanceSquared) { retVal.Add(field.GetK(x, y)); } } } // Exit Function return retVal.ToArray(); }
private static Tuple<int, double>[] GetFieldCircle(Point point, double radiusX, double radiusY, double valueCenter, double valueEdge, FluidField2D field) { // Get the box that contains the return circle var center = GetFieldPoint_XY(new Point(point.X, point.Y), field); var min = GetFieldPoint_XY(new Point(point.X - radiusX, point.Y - radiusY), field); var max = GetFieldPoint_XY(new Point(point.X + radiusX, point.Y + radiusY), field); // Get points that are inside the circle List<Tuple<int, double>> retVal = new List<Tuple<int, double>>(); Vector radius = new Vector(radiusX * field.XSize, radiusY * field.YSize); double maxDistance = ((radiusX * field.XSize) + (radiusY * field.YSize)) * .5d; // just take the average. TODO: see if inside the ellipse double maxDistanceSquared = maxDistance * maxDistance; for (int x = min.Item1; x <= max.Item1; x++) { for (int y = min.Item2; y <= max.Item2; y++) { double dx = x - center.Item1; double dy = y - center.Item2; double distanceSquared = (dx * dx) + (dy * dy); if (distanceSquared <= maxDistanceSquared) { double distance = Math.Sqrt(distanceSquared); retVal.Add(Tuple.Create( field.GetK(x, y), // coordinates that the field wants UtilityCore.GetScaledValue(valueCenter, valueEdge, 0, maxDistance, distance) // LERP )); } } } // Exit Function return retVal.ToArray(); }
/// <summary> /// This takes a point from 0 to 1, and returns the corresponding position in the field (what the field calls k) /// </summary> private static int GetFieldPoint(Point point, FluidField2D field) { var xy = GetFieldPoint_XY(point, field); return field.GetK(xy.Item1, xy.Item2); }