Forest Enrichment Enhancing Forest Region Definition
#71
Posted 22 February 2024 - 03:08 PM
Here's another forest idea. How about creating an orchard using a forest. You would have to set it up to space the trees evenly based on the size of trees. I just planted a few forests on a route and it would have been much quicker to be able to create an orchard whatever size I wanted instead of planting 400 individual apple trees.
Paul :-)
Paul :-)
#72
Posted 22 February 2024 - 03:26 PM
eolesen, on 22 February 2024 - 02:28 PM, said:
OK, folks, it's been a year. And now we can't use "TSRE is no longer in development" as an excuse.
For a developer..... How hard would it be to take the following boundary and populate a forest within it?
For a developer..... How hard would it be to take the following boundary and populate a forest within it?
PolyForest ( UiD ( 132 ) TreeGroup ( JP2AutoTree1.ace, JP2AutoTree2.ace, JP2AutoTree1.ace ) ScaleRange ( 0.9 1.1 ) Population ( 10 ) TreeSize ( 16 20 ) StaticFlags ( 00000000 ) Position ( -92.0677 0.87081 -118.481 ) QDirection ( 0 0 0 1 ) Points ( 6 Point ( -92.0677 0.87081 -118.481 ) Point ( -108.81 0.894868 -73.4293 ) Point ( -104.485 1.51015 -190.919 ) Point ( -78.2488 -1.51429 -122.839 ) Point ( -95.0944 0.857233 -144.572 ) Point ( -95.5375 0.855669 -147.224 ) )
Where would you put this.. In Forests.dat or OPEN RAILS/INCLUDE
#73
Posted 22 February 2024 - 04:22 PM
#74
Posted 15 March 2024 - 01:58 AM
I've had a look at the code. At the moment the single tree is placed at a random position located within a rectangle, so the boundaries are the center point +- half of the two dimensions of the forest. This is simple. If it is not a rectangle, the concept of "within" is not so straightforward. Moreover there is also a section of code that states whether a track or a road are within the forest area (and if needed to delete trees located above or too near to tracks or roads. Also this section makes the assumption that the forest is a rectangle to state if track or road are "within" or not.
So we have two tasks:
1) create a point within an unregular polygon
2) check whether a segment or an arc are within an unregular polygon.
So we have two tasks:
1) create a point within an unregular polygon
2) check whether a segment or an arc are within an unregular polygon.
#75
Posted 16 March 2024 - 04:46 PM
I'm half tempted to say that the avoid trees on track function shouldn't be necessary for a poly Forest.
At the very least, it's not a day One requirement.
At the very least, it's not a day One requirement.
#77
Posted 16 March 2024 - 09:16 PM
Csantucci, on 15 March 2024 - 01:58 AM, said:
I've had a look at the code. At the moment the single tree is placed at a random position located within a rectangle, so the boundaries are the center point +- half of the two dimensions of the forest. This is simple. If it is not a rectangle, the concept of "within" is not so straightforward.
Carlo, assume an editor makes use of several "standard" polygons for hte outline of a forest section -- square, rectangle, triangle hexagon, Octagon For the last two allow an even division and the use of one half, so HalfHexagon and HalfOctagon. Is possible the software can figure out location of the points knowing what kind of polygon it is and to what extent it has been rotated, plus the distance from treh center point to one point on the exterior?
If that information was known could OR correctly create the forest? If yes then might the effort to do this be better addressed working w/ Erik and his fiddling on TSRE so the data I described is recorded int he .w file?
#78
Posted 17 March 2024 - 04:51 AM
Irregular polygons are the initial goal.
As Carlo states, the existing code is calculating four cornerpoints based on:
center + (width/2)
center - (height/2)
center + (height/2)
center - (height/2)
If I clamp the polyforest points to 4, the specified points would replace those derived points, and the rest of the code should process to calculate the area and a coordinate within that area.
As Carlo states, the existing code is calculating four cornerpoints based on:
center + (width/2)
center - (height/2)
center + (height/2)
center - (height/2)
If I clamp the polyforest points to 4, the specified points would replace those derived points, and the rest of the code should process to calculate the area and a coordinate within that area.
#79
Posted 17 March 2024 - 05:03 AM
Google Gemini thanks its this easy:
Write c# code to create a set of 25 random x/y points that fall within the area of an irregular polygon defined by four x/y points
Write c# code to create a set of 25 random x/y points that fall within the area of an irregular polygon defined by four x/y points
public static List<Point> GeneratePointsInPolygon(Point[] polygonPoints, int numPoints) { // Check for valid input if (polygonPoints.Length != 4 || numPoints <= 0) { throw new ArgumentException("Invalid input parameters"); } List<Point> points = new List<Point>(); // Loop until we generate the desired number of points while (points.Count < numPoints) { // Generate random point within polygon bounding box double minX = Math.Min(polygonPoints.Min(p => p.X), polygonPoints.Max(p => p.X)); double maxX = Math.Max(polygonPoints.Min(p => p.X), polygonPoints.Max(p => p.X)); double minY = Math.Min(polygonPoints.Min(p => p.Y), polygonPoints.Max(p => p.Y)); double maxY = Math.Max(polygonPoints.Min(p => p.Y), polygonPoints.Max(p => p.Y)); Point randomPoint = new Point(Random.Shared.NextDouble() * (maxX - minX) + minX, Random.Shared.NextDouble() * (maxY - minY) + minY); // Check if point is inside polygon using Point In Polygon algorithm if (IsPointInPolygon(polygonPoints, randomPoint)) { points.Add(randomPoint); } } return points; } private static bool IsPointInPolygon(Point[] polygonPoints, Point point) { // Refer to any Point In Polygon algorithm implementation // (e.g., Ray Casting Algorithm) // ... } public struct Point { public double X { get; set; } public double Y { get; set; } public Point(double x, double y) { X = x; Y = y; } }
#80
Posted 17 March 2024 - 07:22 AM
The attached zip file contains a javascript program that generates random points in a polygon. It should run in any modern browser.
Doug
randinpoly.zip (1.37K)
Number of downloads: 13
Doug
randinpoly.zip (1.37K)
Number of downloads: 13