So after reading this article Working effectively with coordinates in Entity Framework the author advices to use NetTopologySuites Point class for storing coordinates in the lat/lng SRID 4326 format. In that way you can request the database for spatial aware information. Cool.
But the NetTopologySuite also contains a Coordinate class. Why shouldn't I use the Coordinate class? Or better said, whats the difference between Point and Coordinate
Point is the full fledged Geometry as defined in the OGC Simple Feature Specification. It can interact with other Geometry classes like LineString, Polygon and their Multi variants.
Coordinate is a data type for storing or creating vertices that are used in Geometry classes.
Related
TL;DR
Given a 2-dimensional plane (say, 800x600 pixels or even 4000x4000) that can contain obstacles (static objects) or entities (like tanks, or vehicles), how can computer-controlled tanks navigate the map without colliding with static objects while pursuing other tanks? Please note that every static object or entity has the ability to freely rotate at 360 degrees and has an arbitrary size.
Context
What I am really trying to do is to develop a game with tanks. It initially started as a modern alternative to an old arcade game called "Battle City". At first, it might have been easy to develop an AI, considering the 13x13 grid, fixed sizes and no rotation. But now, with free rotation and arbitrary sizes, I am unable to find a way of replicating such behavior in these circumstances.
The computer-controlled tanks must be able to navigate a map full of obstacles and pursue the player. I think that the main problem is generating all the possibilities for a tank to go to; the collision system is already implemented and awaiting to be used. For example, tanks might be able to fit through tight spaces (which can be diagonal, for instance) just by adjusting its angle of rotation.
Although I have quite some experience in programming, this is way beyond my reach. Even though I would prefer a broader answer regarding the implementationn of tank's artificial intelligence, a method for generating the said paths might suffice.
I initially though about using graphs, but I do not know how to apply them considering different tanks have different sizes and the rotation thing gives me a headache. Then again, if I would be using graphs, what will a node represent? A pixel? 16,000,000 nodes would be quite a large number.
What I am using
C# as the main programming language;
MonoGame (XNA Framework alternative) for rendering;
RotatedRectangle class (http://www.xnadevelopment.com/tutorials/rotatedrectanglecollisions/rotatedrectanglecollisions.shtml).
I am looking forward for your guidelines. Thank you for your time!
I've been working on a project of crowd simulation that included path finding and obstacles/other people avoidance.
We've used the Recast Navigation, a all-in-one library which implements state-of-the-art navigation mesh algorithms.
You can get more info here : https://github.com/memononen/recastnavigation
In our project, it has proven to be reliable and very configurable. Even if it's written in C++, you can easily find/make a wrapper (in our case, we've been using it wrapped in Javascript on a Nodejs server!)
If you don't want to use this library, you can still take a look at Navigation Meshes, which is the underlying theory behind Recast.
I hope it will help!
Navigation Mesh, that's what ur looking for. To explain a bit, it's in theory really easy. U build ur World (2D/3D) and after creation u generate a new mesh, that tells entities where they are allowed to move, without colliding with the surroundings. They then move on this mesh. Next is the path generation algorithm which is basically nothing else then checking in any mathematically form how to get on this mesh to it's target. On an actual navigation mesh, this get's rather complicated but easy if u think of a grid where u check which fields to move to get the shortest way.
So short answered, u need any type of additional layer of ur world, that tells the AI where it is allowed to move, and any kind of algorithm that fits ur type of layer to calculate the path.
As a hint, for unity as an example, there are many free good build solutions. Also u will find a bunch of good libraries to achieve this without a game engine like unity.
I'd like to detect, on the server side using C# only, whether a Latitude/Longitude based coordinate is within an area (polygon) made up of Latitude/Longitude based points. I believe the right way to do this is raycasting, but maybe there is already a C# implementation out there as it's not trivial?
Also, I understand that SQL Server has some geometry function such as STIntersects but in order to use that I need both SQL Server 2008 running and every check would involve a database connection which is undesirable.
Since a sphere is a locally diffeomorphic to the plane, you can use any algorithm that works on the cartesian plane, e.g. this SO question. You'll only have to do work translating coordinates if your polygon includes a pole. Depending on your use case, maybe you can reject those inputs.
I putzed around on the internet for a bit and found this link.
The example is written in C, but looks like it could very easily be adapted to work with C# and Long/Lat coordinates. You would need to keep in mind the crossover lines though (NS/EW), and add code to compensate where necessary, either that or make a decimal conversion of the LatLong values before running the function (West and South are represented with values < 0).
Before you read anything else:
I'm aware that a derivative (integral, maybe?) of this question has been asked before (see here and here), but this question asks a little bit more than either of those. In addition, the two of those are a bit out of date.
The Important Stuff
So here's the question(s):
Is there a reliable Google Maps .NET wrapper that supports polygons and spatial searches (the containsLocation() method)?
If there isn't, can anybody point me in the right direction to get started writing my own? Specifically the polygon/searching stuff.
Additional Reading
There are a couple of reasons I want to do this. First off, I'm developing a mobile site, and I don't want to overload the client with a bunch of javascript. Second -- I don't actually need to display the map at all. All I really need to do is plot the polygons on the map and search for lat/long coordinates inside the shapes.
Here is one that I found: https://gmaps.codeplex.com/
It does not look like it has been touched in some time but should help you get started.
For Place Search (Places API), Google Maps API supports proximity search by specifying circular / rectangular range for a location bias parameter. Note that it is not supporting generic polygons and spatial searches as OP asked.
locationbias — Prefer results in a specified area, by specifying
either a radius plus lat/lng, or two lat/lng pairs representing the
points of a rectangle. If this parameter is not specified, the API
uses IP address biasing by default.
https://developers.google.com/places/web-service/search
Places are defined within this API as establishments, geographic
locations, or prominent points of interest.
The Places API lets you search for place information using a variety
of categories, including establishments, prominent points of interest,
and geographic locations. You can search for places either by
proximity or a text string. A Place Search returns a list of places
along with summary information about each place; additional
information is available via a Place Details query.
.NET wrapper libraries for the Google Maps API (including Places API):
GoogleApi
google-maps
https://stackoverflow.com/a/61531795
I'm wondering what way would be best to render a 2D map for a shooter (these will be static maps) similar to Soldat. Multiple options I've considered are a tile based map (stored in txt files), or just creating different classes for the different terrains I plan to use and creating a data structure to read/store them in a file. (I want to also be able to include things like jumping/running on walls, sliding down walls/slopes ect)
I feel like there must be a better way than either of these, but haven't been able to find definitive information :/
Thanks :)
Soldat used a polygon based format to render and represent it's levels. The editor would have allowed the user to plot points and connections between them to make walls and structures when were then given textures and properties (such as collide = death). Items and images where then overlayed over this.
The soldat rendering engine would then use these structures to perform collision detection and to build up the polygon (triangles that are drawn) representation of the world.
I was going to go with the "just use a tile map," but then I looked at Soldat and it's a bit more complex.
I don't know what they're using, but I suspect they're using polygons and probably colliding against polygons as well. The levels are likely generated with the same sort of primitives you'd see in 3D games, but all in a plane. E.g. texture mapped triangles and collision against the edges of the surfaces rather than against the surface itself.
In my experience, "terrain" is usually an object in itself and the collision and visual representations are data inside that object (aggregated into that object, typically). The different pieces of terrain don't necessarily need to be different types of thing, indeed in all of the games I've made the entire world was generally a single object of type "Terrain" or "World" or something and it managed the doings of the various visible pieces coming into and out of view.
This doesn't feel like a great answer, but I thought I'd try to give you something.
Examples of platform games doing what you want are Braid and Aquaria. You can get Aquaria for 2 pennies litteraly, with the Humble Indie Bundle.
Here's the Aquaria's editor in action. I could not find a decent video of the Braid editor.
I found this other video about IndieLib, and a level editor that they have created which is similar to Aquaria's (Disclaimer: I haven't tried it myself).
Appart from that, googling for "Braid and Aquaria platform engine" should give you more results.
I would recommend reading the book Building XNA 2.0 Games: A Practical Guide for Independent Game Development. It walks you through the development of a 2D side-scoller game named Zombie Smashers (based on the author's award-winning The Dishwasher: Dead Samurai).
Chapter 4: The Map Editor is what you are looking for.
It will help you even if you don't plan on developing in XNA.
I've been reading about using the winged-edge data structure for storing a boundary representation. However, the linked site says that this is one of the oldest data structres for storing b-reps, are there newer better ones?
Secondly, is there an implementation of this in C#?
The datastructure used for a B-rep is very similar to those used for polygonal modeling - you just replace the edges with curves and the faces with surfaces.
The wikipedia page on polygonal meshes has several types listed, including winged edge. Personally I like half-edge meshes. The only thing they can't do well is non-manifold topology, which you may or may not need. If you do, look for radial edge topology.
There's also a freely available B-rep datastructure from OpenNurbs (McNeel, the makers of Rhino). That also gets you file IO, which is nice.
Boundary Representation Modelling Techniques by Ian Stroud will give you a survey of ways people have approached B-reps, along with a plethora of diagrams with all the Euler operators, and concrete data structures and algorithms for implementing B-reps imperatively.
Whether you want to move a few characters forward into F# or not, you may glean quite a bit of info from the source code for Wings3d (written in Erlang). Just don't get lost making spaceships and forget you were supposed to be coding!
Also the GML will allow you to investigate interactively what you can do with your B-reps, and the data structure is the code.
Not sure if this will help or not but there are Geometry objects in the XNA library for dealing with 3D Structures and what not. There may be something in there. However my guess is that it will either be Point based or Triangle based vs edge based.
But it might be a place to look.