|
Richard,
I hate to double post, but there is a simplification. Sort the points for each polygon manually for lowest Y and lowest X, draw a line between lowest x lowest X and highest y highest Y, then draw a line between the other two points. Calculate the intersection of the lines to form the center point. Put the polygon points and center point into an array as a structure and repeat for all polygons. Sort on the center point Y and X values. Now just look for the closest center to the point. You do not need to divide the building into squares, just look for the closest center to the point. If the list is short enough, don't sort, just scan for the smallest distance between the center and the point (smallest sum of squares).
Dave.
|
|
|
|
|
Using this[^](PDF warning! googledocs version here[^]) paper as reference, I have so far (after a couple of days of being annoyed and rewriting the code from scratch every few hours) only been able to get half of it right.
The problem is mainly that this article is written in weird mathematical language with single-letter names all over the place, with the upper case S being an other variable than the lower case s. Add to that all the "obvious" steps for which the implementation is left as an exercise for the reader. The code in the appendix isn't any better, and may even be worse because it uses variables named n02 etc.
I've searched for implementations, but the best I found was a highly obfuscated Java implementation which passed values to methods by putting them in fields of the class rather than as arguments.
Could anyone please explain step 3 of this algorithm? (or more than that, I don't mind, but step 3 is the only part I don't understand)
|
|
|
|
|
Hi Harold,
I'm not familiar with the matter, however I glanced through the PDF; looks like a decent but though article indeed. The source code at the end doesn't seem that awful; why not just feed it to the C# compiler and fix the remarks it will throw at you?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
That's possible, but I really prefer understanding it first - and also, all that pointer magic doesn't make me too happy (it can't easily be removed, either, because it's used to change the start of an array several times)
|
|
|
|
|
harold aptroot wrote: I really prefer understanding it first
for a big article and a small snippet I'm often willing to reverse the order, so run it first, observe and understand it later.
harold aptroot wrote: pointer magic ... can't easily be removed
I noticed that; however, adding start parameters solves that, like so:
public bool sleq(int[] s1, int[] s2, int start1, int start2) {
for(int i=0; ; i++) {
if (s1[start1+i]<s2[start2+i]) return true;
if (s1[start1+i]>s2[start2+i]) return false;
}
}
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Ok well it can be removed of course, it just takes.. effort.
Are you sure you couldn't just explain step 3 quickly?
Otherwise I guess I'll work on converting that code..
|
|
|
|
|
harold aptroot wrote: Are you sure you couldn't just explain step 3 quickly?
No, not really. I am sure I could convert the code faster than you could make me understand it though. Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Fair enough, I'll convert it.
|
|
|
|
|
In the mean time, I have a TryAll.cs that compiles (and looks like it will generate a lot of output). I could mail it to you.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Yes please, my email is just my name @gmail.com (without underscores)
|
|
|
|
|
mail sent
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
changing the first line to
#define WITH_DEBUG_OUTPUT1 // WITH_xxx or WITHOUT_xxx
seems to generate decent results, assuming the command line holds two numbers, such as 3 5
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
|
|
|
|
|
Hi,
in a directed graph with positive edge weighs, how can I computed all pathes from A to B with length less than a certain bound?
I could use a k-shortest path algorithm, but I don't know k in advance..
I want something like
while (l < bound) {
path p = graph.GiveMeNextPathInAscendingOrder(A,B);
l = p.length;
do something with p..
}
Best regards
-->Andreas
|
|
|
|
|
Easy; just do a depth-first search, backing up when you hit a dead end or exceed the bound.
|
|
|
|
|
I have a huge database (3 million records) that I need to de-duplicate by street address every month. With non-conforming addresses like (123 S. Ventnor Blvd, 123 South Ventnor Boulevard NW, etc.), de-duping is a pain. I'd like to find an algorithm with whatever lookup tables are necessary to convert all of the addresses to USPS format like you find in CASS certified addresses, so they can be compared. Anybody ever done that and have some clues?
|
|
|
|
|
hi,
I am to develop a 2d self assembler as my college project... I searched a lot and found some many papers on this subject. But all of them are full of theory and none of them said anything about the implementation part...
Could someone help me with these or atleast direct me to some specific place where I can more info on 2d self assemblers.
Thank you
|
|
|
|
|
Sai Yasodharan wrote: I am to develop a 2d self assembler as my college project
You do understand that this means YOU are expected to do the work?
MVP 2010 - are they mad?
|
|
|
|
|
Are you kidding? It means he has to find a way to get it done. For sure self does not refer to him?
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
I know I must do the work... I m just here to get some help or guide from the experts, who already played with 2D SELF ASSEMBLERS, if any. Also help in the sense not the program, just some info on how to start and which way to proceed
|
|
|
|
|
Sai Yasodharan wrote: I know I must do the work.
Well you could start by doing some research; remember Google is your friend and also the best starting place. It is almost impossible for anyone to respond to your question, these forums are for technical questions rather than teaching. The tutorials can be found in the published articles which you should also take a look at.
MVP 2010 - are they mad?
|
|
|
|
|
|
Hello Sirs,
How to find the compression type of jpeg, when we give one sample input jpeg file the output result is this image contains (ex.) xxxx compression type. How to identify it .?
please replay
Failure is Success If we learn from it!!
|
|
|
|
|
Well it looks like you have to look up the Huffman table for the image it's marked at:
DHT 0xFFC4 variable size Define Huffman Table(s) - Specifies one or more Huffman tables.
A bit more can be found about this at this site:
JPEG Huffman Coding Tutorial[^]
The wiki explains it a little also:
JPEG Wiki[^]
|
|
|
|
|
Hi
I am planning to implement a custom version control system.
Is there anyway to represent physical directory structure in database?
Or should I represent them using 'tree' data structure?
If using tree data structure, how can I save the contents of tree to an external file??
thanks
fadi
|
|
|
|
|
Yes,
I have done this quite often there are several ways of doing this, it mostly depends on how you plan on searching the db or how you want to maintain the data. The obvious approach is to use a column file directory:
c:\mydir\thisdir\nextdir\and-so-on
This can make it a head ache if you need indexing.
The approach I used for indexing is to use a treemap where I had two colums a and b; a is the parent and b the child. you can build a directory structure this way easily. The problem with this approach is using SQL with it. You have to load the whole tree in memory in a tree map in the application then modify it and post it back or update the 'dirty' sections after you make changes to the tree.
|
|
|
|