Elvas Tower: Forest Enrichment - Elvas Tower

Jump to content

Posting Rules

All new threads will be started by members of the Open Rails team, Staff, and/or Admins. Existing threads started in other forums may get moved here when it makes sense to do so.

Once a thread is started any member may post replies to it.
  • 9 Pages +
  • « First
  • 6
  • 7
  • 8
  • 9
  • You cannot start a new topic
  • You cannot reply to this topic

Forest Enrichment Enhancing Forest Region Definition Rate Topic: -----

#71 User is offline   charland 

  • Vice President
  • Group: Status: Elite Member
  • Posts: 2,531
  • Joined: 13-April 08
  • Gender:Male
  • Location:Brockville, ON, CA
  • Simulator:MSTS/OR
  • Country:

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 :-)

#72 User is offline   NZ_JOHN 

  • Fireman
  • Group: Status: Active Member
  • Posts: 183
  • Joined: 15-September 16
  • Gender:Male
  • Location:New Zealand
  • Simulator:OR
  • Country:

Posted 22 February 2024 - 03:26 PM

View Posteolesen, 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?

	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 User is offline   eric from trainsim 

  • Waste Disposal Engineer
  • Group: Private - Open Rails Developer
  • Posts: 1,582
  • Joined: 30-October 10
  • Gender:Male
  • Simulator:ORTS
  • Country:

Posted 22 February 2024 - 04:22 PM

View PostNZ_JOHN, on 22 February 2024 - 03:26 PM, said:

Where would you put this.. In Forests.dat or OPEN RAILS/INCLUDE


In the World file as a new object type. We -can- do that...

#74 User is online   Csantucci 

  • Member, Board of Directors
  • Group: Status: Elite Member
  • Posts: 7,016
  • Joined: 31-December 11
  • Gender:Male
  • Country:

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.

#75 User is offline   eric from trainsim 

  • Waste Disposal Engineer
  • Group: Private - Open Rails Developer
  • Posts: 1,582
  • Joined: 30-October 10
  • Gender:Male
  • Simulator:ORTS
  • Country:

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.

#76 User is offline   Weter 

  • Member, Board of Directors
  • PipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 7,039
  • Joined: 01-June 20
  • Gender:Not Telling
  • Simulator:ORTS
  • Country:

Posted 16 March 2024 - 04:57 PM

Indeed - forest's boundary then can follow ROW.

#77 User is offline   Genma Saotome 

  • Owner Emeritus and Admin
  • PipPipPipPipPipPipPipPipPipPipPipPipPip
  • Group: ET Admin
  • Posts: 15,361
  • Joined: 11-January 04
  • Gender:Male
  • Location:United States
  • Simulator:Open Rails
  • Country:

Posted 16 March 2024 - 09:16 PM

View PostCsantucci, 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 User is offline   eric from trainsim 

  • Waste Disposal Engineer
  • Group: Private - Open Rails Developer
  • Posts: 1,582
  • Joined: 30-October 10
  • Gender:Male
  • Simulator:ORTS
  • Country:

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.

#79 User is offline   eric from trainsim 

  • Waste Disposal Engineer
  • Group: Private - Open Rails Developer
  • Posts: 1,582
  • Joined: 30-October 10
  • Gender:Male
  • Simulator:ORTS
  • Country:

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


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 User is offline   dajones 

  • Open Rails Developer
  • Group: Status: Contributing Member
  • Posts: 413
  • Joined: 27-February 08
  • Gender:Male
  • Location:Durango, CO
  • Country:

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
Attached File  randinpoly.zip (1.37K)
Number of downloads: 13

  • 9 Pages +
  • « First
  • 6
  • 7
  • 8
  • 9
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users