Cartesian Coordinate Smoothing With C# - c#

we are trying to develop an application with RFID readers and using speedway readers so i'm using octane sdk. when we get coordinates from each tag, we need to calculate coordinates. But sometimes we get wrong coordinates and we have to recalculate.
For this calculation, i need an algorithm which is filtering and correcting the multiple points(array of x-y). it should calculate wrong coordiantes with correct coordinates.
I've searched lots of algorithm like kalman, least squares, levenberg-marquardt but i think the problem is i don't have any model for tags and i can't fit any value to it.
I know for this case i have to apply some mathematics but i can't find.

Related

What 3D rendering technic/algorithm is most effective to draw beams by edges?

I'm trying to construct a program in C# that generates a 3D model of a structure composed of beams, and then creates some views of the object (front, side, top and isometric).
As I don't need to draw surfaces (the edges are enough), I've been calculating each line to draw, and then do it with
GraphicObject.DrawLine(myPen, x1, y1, x2, y2)
This worked fine so far, but as I get adding parts to the structure, the refresh of GraphicObject takes too much time. So I'm getting into line visibility check to reduce the amount of lines to draw.
I've searched Wikipedia and some PDFs on the subject, but all I found is oriented by surfaces. So my question: Is there a simplified algorithm to check visibility of object edges, or should i go for a different approach, like considering surfaces?
Any suggestions would be appreciated, thanks for your help.
Additional notes/questions:
My current approach:
calculate every beam in a local axis (all vertices)
=> move them to their global position
=> create a list with pairs of points (projected and scaled to the view)
=> GraphicObject.DrawLine the list of point pairs)
would the whole thing be faster if I'd calculate the view by pixels rather than using the DrawLine method?
Screenshots follow with the type of structure it's going to do (not fully complete yet):
Structure view
Structure detail
There are 2 solutions to improve the performance.
a) switch the computation to the graphics card.
b) Use a kd-tree or some other similar data structure to quickly remove the non visible edges.
Here's more details:
For a), a lot of you computations are multiplying many vertices (vectors of length 3) by some matrix. The CPUs are slow because they only do a couple of these operations at a time. Switch to a GPU, for example using CUDA, which will allow you to do them more in parallel, with better memory access infrastructure. You can also use OpenGL/DirectX/Vulkan or whatever to render the lines themselves to skip having to get the results back from the graphics card and whatever other hiccups get introduced by windows code/libraries. This will help in almost all cases to improve performance.
For b), it only helps when you are not looking at the entire scene (in that case you really need to draw everything). In this cases you can store you scene in a kd-tree or some other data structure and use it to quickly remove things that are for sure outside of the view area. You usually need to intersect some cuboid with a pyramid/fustrum so there's more math involved.
As a compromise that should help in a large scenes where you want to see everything you can consider adjusting the level of detail. From your example, the read beans across are composed of 8 or so components. If you are far enough you are not going to be able to distinguish the 8, so just draw one. This will work great if you have a large number of rounded edges as you can simplify a lot of them.

pattern recognition inside a matrix

say I have these boxes, some of which are black and some white.
The image shows a U shape drawn with the black boxes. Now say I have a matrix of 1s and 0s (it can be a huge matrix) like this:
111111111111111111
111111111111111111
111111111111111111
111111111101111111
111111111101111111
111011111101111111
111011111101111111
111011111101111111
111011111101111111
111011111101111111
111011111101111111
111100000011111111
111111111111111111
which shows zeros forming roughly the shape shown in the image. The image and the matrix are just examples. The image is a screen shot of a software where we should draw patterns, which would then need to be located in given matrices (inside simple text files).
What I'm looking for is a guidance on how to get started on this, cuz I have never programmed anything related to pattern recognitions, which this problem clearly seems to be related to. This is all that I have to do, a pattern given, to be matched with matrix of 0s and 1s. I dont think I can write it on my own in a few days, I'm writing code in c# vs 2013, so hoping I can find some libraries that would let me achieve this with minimal dependencies. Thanks
I think you need to provide a bit more information on what exactly you're looking for. Are the shapes all letters or arbitrary shapes?
Whatever you're looking for I'd start with emguCV. It's a pretty comprehensive library that isn't too difficult to use.
EmguCV has a lot of OCR (optical character recognition) functions which should be able to pick out letters pretty well.
I don't have as much experience using it for arbitrary shape detection but I think SURF detection, something which emguCV also does, might be a good way to go. It attempts to match a given image with features in another image.
People never draw at the exact same place and scale as your stored data.
The things you want are often done with neural networks (its also in aforge).
But it might be hard to A understand it and B use it in your code.
So maybe you could try it like this, get the first position, then record the delta position.
Try to find long lines, and their next direction; store the general direction changes.
above sample would be "down right up", you might also store some length info.
Then there is some math to check how much different sets are, for example string comparisons distance of strings (like in php the levenshtein function); cant think of a levenshtein func in c# dough i dont think c# is that rich with string functions but once you see that i'm sure you can derive something for C#.

Unable to map coordinates on Google Maps

I have a list of coordinates that I want to plot on Google Maps, but I can't figure out how to do that. The coordinates, depending on how I plot them, appear to be all around the globe, while they should be placed in Trondheim, Norway. (And the application I have extracted them from successfully places them in Trondheim, so I know they are correct.)
A normal Google Maps coordinate from Trondheim looks like this:
63.4304, 10.395069
My coordinates, however, look like this:
long, lat
1154262, 9182277
1143762, 9184473
1157168, 9194133
1157375, 9200167
1164505, 9209786
I believe that these are in some kind of WGS84 format, but as I am a complete novice on this field, I am not completely sure. I think so because of the headers in the XML I have extracted them from:
<rss version="2.0"
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"
xmlns:mappoint="http://virtualearth.msn.com/apis/annotate#">
When I try to use this coordinate converter, it returns coordinates in Kazakhstan. I am utterly confused. All other converters I have tried either returns locations in strange countries or in the middle of the oceans, or they fail to convert my data at all.
Does anybody here know what kind of coordinates I have, and how I can convert them to normal latitude and longitude degrees?
A formula is enough, but if there exists any libraries for this, I am using C# as development language. Any other languages would suffice, however, as I am probably able to convert them to my own anyway.
WGS-84 is Spherical Mercator, the projection system used by Google, so the coordinates you have provided are obviously not. Unfortunately for any formula to work you will need to find out the projection that your points are in.
Some more detailed information on projection is available here: http://courses.washington.edu/gis250/lessons/projection/
And a library to convert between common coordinate systems in .net is available at: http://www.doogal.co.uk/dotnetcoords.php.
Would it be possible for you to open the map layer in an GIS program such as: http://www.qgis.org/en/site/ and use the options available to determine the projection of the layer?
Some tips for identifying the coordinate system (written for ARCGIS but the programs are similar): http://resources.arcgis.com/en/help/main/10.1/index.html#//003r00000004000000 https://gis.stackexchange.com/questions/7839/best-practices-for-identifying-the-unknown-coordinate-system-of-a-shapefile

How to getting dimensions from STL file?

I have an binary format STL (STereoLithography) file, I have successfully read the file from c#.net and got the facets, I also got the count of triangles, volume of the part and surface area of the part. But now the problem is that I am not able to find the dimensions of the 3D object(Length,breadth,height). Please help.
I think you will probably have to calculate this yourself, but the algorithm should be fairly simple, assuming you want the dimensions in x,y,z rather than some rotation. Loop through the facets to find the max and min x,y and z coordinate values. Then the dimensions are simply the differences between max and min.
Edit: you could keep track of the max/min values while reading in the points from the file for a minor performance boost.

Check if coordinate is within area

I got a real-estate facing problem.
I've got a real-world address that I'm converting to earth coordinates (such as "London Eye" to "-0.119543;51.503324").
I also got a perimeter or area within I'm going to search (for example "10" is "10 km").
Now I got a bunch of coordinates (totally random around the earth) and I want to check if the current coordinate is within 10km of the coordinates of the london eye.
Is there any solution to this or maybe am I even facing a x-y-problem?
You could use the Haversine Formula to calculate the distance between two points:
http://www.stormconsultancy.co.uk/blog/development/code-snippets/the-haversine-formula-in-c-and-sql/
Nearest GPS coordinate based on distance from a given point
However for speed I think you need to calculate max/min longitude and latitude values (i.e a square around the London Eye) as this will be a lot quicker to calculate if there are lots of points to check. Then use the Haversine formula on this small subset of points (within your square) to find those within 10km.
It seems like this could help you:
http://www.doogal.co.uk/dotnetcoords.php
It is based on http://www.jstott.me.uk/jcoord, which allows distance calculation between points. Don't take my word for it though, haven't used either.
There is a well known solution to the problem. Haversine_formula
I think you can also search for C# code for the same. Hope it helps.

Categories

Resources