I'm currently learning swarm intelligence algorithms and I want write a C# app for testing those in the context of a vehicle routing problem.
I want to write an app that will show a graph that will be a representation of of cities (vertices) and roads (edges) and implement new algorithms as I learn more of them.
The problem is I don't know how I can draw such graph. I was thinking about using adjacency matrix to know if the vertices are connected and another to represent the distance between them if they are connected.
If You know any way to visualize such graph in a efficient way it will be much appreciated. I saw someone was able to do so using picture box which is mind blowing.
The simplest option is probably to create a winforms application and attach an event handler for your paint-event. This will give you a graphics object that can be used to draw squared, lines etc. Note that you probably need to translate your coordinates from your internal coordinate system to screen/image coordinates.
Related
Searching for advice: We are rewriting (in c#) the graphical user interface for the Watershed Risk Analysis Management Framework model, and are using the DotSpatial libraries for our map operations. We need to perform some simple tabulations on raster data, and I'm having trouble finding examples. We need to calculate land use (using national land cover dataset) percentages within polygons, calculate average slope and aspect within polygons. Pretty standard stuff for hydrologic analysis. Does anyone know of tutorials or available code sources for DotSpatial raster analysis? Thanks for your time.
did you find a way to do it? I am in the same position. For the moment, my current workaround is this. I have converted my raster into a List<GeoAPI.Geometries.IPoint> listPts using the center coordinates of the pixels, with the Z value as the corresponding raster pixel value. Then, with my PolygonShapefile, I loop over each feature, and use the feature.Geometry.Covers(listPts[i]) methode to build a list of the points failing in each polygons. After that, I simply cross the two lists together to calculates the corresponding statistics that I need.
I would like a better suggestion, but for the moment, it fits my needs.
As the question says, I am looking to use GPS coordinates (say from Google maps) to build a 3D model (a road).
So it should work as follows:
You go to Google maps and select a route (this can be between 2 points or a circuit). You then get the lat long coordinates for this route.
Using this data, you then feed it into a program that generates a height map of the coordinates as obtained from Google maps.
I am trying to make a demo in C# (XNA) that you can quickly generate a course of your neighbourhood for a driving sim (as long as I get the main road sections right its ok, wont be able to add detailed characteristics of the road e.g. a ditch next to the road or small bumps in the actual road surface).
Does anyone have any ideas on where I would even start with a problem like this (tried Google already but the best I could find was here)
GPS coordinates (latitude, longitude, altitude) uses a speherical 3D modell. What you want is a transformation to a cartesian 3D Model.
For this case you can convert them into ECEF coordinates, this then are a x,y,z coordinates
For ECEF overview see ECEF
A starting point could be to look at the Dotspatial libraries for .NET: http://dotspatial.codeplex.com/
I have used these libraries, but mainly to gather GPS coordinates from an external device. I haven't used these coordinates on a map for instance. The documentation is limited, but if you pry around you might be able to find some info.
I'm building a 2D robot simulator GUI for my autonomous robot vehicle.
I plan to keep the GUI simple. It consists of a vehicle (represented by a blue square picture), and some obstacles (cones, wall, etc, represented by yellow circle and red line respectively).
The vehicle must be able to move (as in the blue square must be able to move on the GUI) and be able to show its velocity and steering (float values) and its status (string) on the GUI.
I plan to use C# and Windows Forms to do this task, but I'm not sure if this is the right way to it. I remember using picture box a few years ago and I was not able to change the position of the picture box in real-time, or something weird like that.
Just wondering if you guys know a better way to do this. Is Windows Forms the way to go?
I've just moved from Ubuntu to Windows, so I am quite new at .Net stuff.
Here's what I've got so far http://imageshack.us/photo/my-images/708/guilo.png/
Future plans may dictate a change, but for what you describe Windows.Drawing should work fine. The only problem may be if you are using timers for updates, as it may not be fast enough for you.
So, how fast of an update rate do you need?
How much like a game framework will you actually need?
You may want to look at a tutorial like:
http://www.dreamincode.net/forums/topic/67275-the-wonders-of-systemdrawinggraphics/
as you can see i want to do senior project about soccer player tracking with gps to show the path that player was using or tracking in real time
i already study about basic gps function in c# but I Really Have problems on how to draw paths on the map or picture that i want to use after we got the data from gps.
the hardware part are already finish but i get stuck in and idea for how to get the data from gps to draw path of player
I appreciate with any help on me ( sorry for bad english) Thank you very much
Link of my designed project picture :
http://image.ohozaa.com/view2/weK9gVKBzGZqRxKC
Just think about what you're doing.
GPS data (from each player) is received as a sequence of points (Latitude/Longitude?).
Convert those points to X/Y coordinates for your football field image
Use a graphics API (such as GDI / System.Drawing ) to draw lines between subsequent points
If you're using C# you might save time and trouble by using WinForms and subclassing Control and painting directly to the control's surface. You'll need to store a list of all the recent points for each player (because you'll need to constantly repaint the control).
Note that the geolocation features in .NET won't help you here unless all of your football players are going to be carrying laptops strapped to their backs. You'd want small GPS trackers attached to each player along with a small radiotransmitter that sends the data. An easy way to do this is with a commodity Bluetooth GPS unit, but I don't know if Bluetooth can support that many transceivers in such a small space, or even if the signal will reach from one end of the field to another. The most expensive way is to write a phone app and have each player carry a smartphone that sends geolocation data via a 3G or Wifi connection.
Note that GPS units tend to have a usable accuracy of about 5m (maybe 2.5m on a good day), and are useless indoors. Then consider the 5 minutes it takes for them to secure a good lock in the first place (mobile phones have quick geolocation because they use assistance from mobile phone masts). Football fields aren't very big, and even with 2.5m accuracy the data isn't going to be very useful.
In real sports they don't use GPS for this reason. Instead they use higher-precision radio units and specialist transmitter/receiver units placed around the pitch. An alternative is visual tracking, but that's an immature science (Turing help you if two players or more wearing the same team colour collapse into each other).
Looking at the picture you provided I'd say something like this is feasible with a WPF application using the Canvas control and the Line class. You'd have to convert your GPS data to (x,y)-coordinates where the origin is located at the upper left corner of the soccer field. Then you could connect subsequent points using line segments.
image http://prod.triplesign.com/map.jpg
How can I produce a similar output in C# window forms in the easiest way?
Is there a good library for this purpose?
I just needs to be pointed in the direction of which graphic library is best for this.
You should just roll your own in a 3d graphics library. You could use directx. If using WPF it is built-in, you can lookup viewport3d. http://msdn.microsoft.com/en-us/magazine/cc163449.aspx
In graphics programming what you are building is a very simple version of a heightmap. I think building your own would give your greater flexibility in the long run.
So a best library doesn't exist. There are plenty of them and some are just for different purposes. Here a small list of possibilities:
Tao: Make anything yourself with OpenGL
OpenTK: The successor of the Tao framework
Dundas: One of the best but quite expensive (lacks in real time performance)
Nevron: Quite good, but much cheaper (also has problems with real time data)
National Instruments: Expensive, not the best looking ones, but damn good in real time data.
... Probably someone else made some other experiences.
Checkout Microsoft Chart Controls library.
Here's how I'd implement this using OpenGL.
First up, you will need a wrapper to import the OpenGL API into C#. A bit of Googling led me to this:
CsGL - OpenGL .NET
There a few example programs available to demonstrate how the OpenGL interface works. Play around with them to get an idea of how the system works.
To implement the 3D map:
Create an array of vectors (that's not the std::vector/List type but x,y,z triplets) where x and y are along the horizontal plane and z is the up amount.
Set the Z compare to less-than-or-equal (so the overlaid line segments are visible).
Create a list of quads where the vertices of the quads are taken from the array in (1)
Calculate the colour of the quad. Use a dot-product of the quad's normal and a light source direction to get a value to shade value, i.e. normal.light of 1 is black and -1 is white.
Create a list of line segments, again from the array in (1).
Calculate the screen position of the various projected axes points.
Set up your camera and world->view transform (use the example programs to get an idea of how to do this).
Render the quads and lines, OpenGL will do the transformation from world co-ordinates (the list in (1)) to screen space. Draw the labels, you might not want to do this using OpenGL as the labels shouldn't scale with distance from camera, otherwise they could get too small to read.
Since the above is quite a lot of stuff, there isn't really the space (and time on my part) to post working code (but someone else might add something if you're lucky). You could break the task down and ask questions on the parts you don't quite understand.
Have you tried this... gigasoft data visualization tools (Its not free)
And you can checkout the online wireframe demo here