|
Well, this might be a place to get started. Bresenham's algorithm[^] certainly picks pixels to draw straight lines and some other curves. You might also check some of the 3D drawing class libraries, like VRML or the library that originated at SGI, as they often implement a process they call "extrude" where they sweep a shape through space that follows a curve, a cylinder is an example of extruding a circle along a straight line. I don't think they use pixels generally but you might get some ideas.
If you don't have the data, you're just another a**hole with an opinion.
|
|
|
|
|
Thanks a bunch for your ideas the Bresenham should work perfectly i think
C++ where friends have access to your private members !
|
|
|
|
|
For example, used for video conference or video capture.
|
|
|
|
|
followait wrote: For example, used for video conference or video capture.
Oh, probably some DCT (discrete cosine transform) derivative like H.261. It's an ITU standard suited for two-way communication over ISDN. It supports fairly high data rates as well (i.e. multiples of 64Kbit/sec).
|
|
|
|
|
Currently h264. All HDs are in H264 for example.
Back then it was xvid.
|
|
|
|
|
Hi,
All of you must have herd of Best fit also, but i would give a brief , just in case.
Say i have slots of 50 KB, and there are some codes of different sizes say [10KB,11KB,23KB,34KB,2KB,28KB,31KB,9KB]
Now i have to fit all the elements in the different 50KB Slots such that i make the optimum use of the space. Like:
31+9+10 = 50KB --- 1st slot.
11+34 = 45KB --- 2nd slot...
I need an algo for the same in C#..
Thanks in advance...
|
|
|
|
|
The best fit is a rather lengthy algorithm to implement. I would try sorting in descending order before trying to assign bins. Then you'll have to loop through all the bins and assign as appropriate. You also have the possibility of increasing the numbers of bins. Assign elements to the bin that is most full that can accomodate your element. At this point you can increase the number of bins if you like. Continue in this manner....
|
|
|
|
|
This is a standard Multiple Knapsack[^] problem, there are lots of references on the web and a variety of solution trchniques with different ranges of applicability. One general code (fortran though, not c#) is TOMS ALgortihm 632[^]
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
You are probably going to have to live with an imperfect solution. This looks a lot like subset-sum, which iirc is an NP hard problem
|
|
|
|
|
Hello,
Best Fit problem as applies to computer science involves variable size storage blocks as well as variable size data to be put into the storage blocks notably without combining data chunks before storage (see Knuth, Vol. I).
What you have described is the timeworn knapsack problem, aka circus train problem. Simply stated: What is the packaging arrangement of a fixed set of variably sized objects into uniform size containers that fills the fewest containers?
Problem size will be a considerable obstacle here. Consider unfavorable size distributions in your set of variables that yield many size combinations to be generated, tested, and compared with the previous-best combination. And how many possible combinations of these combinations are possible?
Anyway, I think you should postulate some modest inputs and do some pencil scratch before hunting down code or algorithm.
Tadeusz Westawic
An ounce of Clever is worth a pound of Experience.
|
|
|
|
|
I want to implement an algorithm in which I need to put some nodes(points)in an environment and segments which connect theses nodes in some way to each other. The environment is occupied with some obstacles(simple shapes or polygons)! How can I determine when collision exists between nodes or segments and the environment's obstacles! Thanks so much in advance.
|
|
|
|
|
It depends on the accuracy that you want. For relatively inaccurate detection you can use the bounding box of your shapes.
There are some nice bounding box based algorithms in OpenGL that you can use: here[^].
There's also a nice CP article here[^].
EDIT: It helps to explain why you gave me a '1-vote'...
modified on Tuesday, June 10, 2008 3:30 AM
|
|
|
|
|
The solution requires the use of a spatial container. You place all your environment objects into the container, then as you process your dynamic objects you query them against the spatial container. The result should provide back the intersecting objects. Depending on the dimensionality of the objects you could either use a quad-tree or an oc-tree.
|
|
|
|
|
General process is that you perform a "broad phase" sweep to determine potential collision pairs based on something easy - bounding circles or boxes, and then move onto a "narrow phase" to check for exact collisions.
You might want to read up on minkowski sums - using these in an embedded system at the moment for mining machine anti-collision.
|
|
|
|
|
Non-Numerics R Us, use bitmaps and the GDI Bitblt() function.
Two congruent bitmaps A and B each contain some 'on' bits and some 'off' bits and we wish to determine if any 'on' bits occupy the same coord location in both maps.
1. A AND B yields a bitmap with 'on' bits only where the 'on' bits of A and B collided.
2. Row-wise OR the first half of C with its second half, then the first one fourth with the second one forth, etc. until all rows are ORed to a single row.
3. Repeat step 2, except column-wise for the first row only until ORed to a single bit.
If the upper-left bit is 'on', then a collision occurred.
This method always answers yes or no, but never how many or where. You might ask what use is that?
I have used blitter and bitmaps in (unsuccessful) attempt to simulate fluid flow through a maze by pumping bits into the entrance and sumping them out the exit. My bits just wouldn't flow and I need a better notion of 'boolean soup'.
I have also used this method to successfully determine if constrained random walks in integer 3-space cross one another.
This method boasts a strictly linear increase in execution time as number of objects to test increases. This feature makes it useful for very large numbers of objects like the hundreds of thousands of bits bouncing around in my mazes, keeping track of which are moving N, E, S, W and colliding with each other or with maze walls.
Tadeusz Westawic
An ounce of Clever is worth a pound of Experience.
|
|
|
|
|
Sorry, thats supposed to read....
That is, linear increase in execution time IF you are adding one bitmap per graphic object.
There is ZERO increase in execution time if you work things out to fixed number of bitmaps. Ten bits set or 500,000 bits set in a 1000x1000 bm wil execute in the same amount of time.
Tadeusz Westawic
An ounce of Clever is worth a pound of Experience.
|
|
|
|
|
This is one of those times when I'm not sure I understand the problem well enough to articulate an intelligeable question, so bear with me as I muddle my way through this.
In my application, I have a set of conditions. I need to test these conditions, and if a combination of them results in a true value, then I take one action; otherwise, I take another.
These conditions are really just integer values; the test in my code looks something like this:
flag1 = flag2 = flag3 = false;
for(int i = 0; i < OscillatorCount; i++)
{
for(int j = 0; j < TargetCount; j++)
{
if(oscillatorSource[i][j] == Envelope1)
{
flag1 = true;
}
else if(oscillatorSource[i][j] == Envelope2)
{
flag2 = true;
}
else if(oscillatorSource[i][j] == Envelope3)
{
flag3 = true;
}
}
}
In other words, I have a two-dimensional table. If any of the values in the table matches a certain value, I set a flag to true. So in the future when I need to take an action based on the values in the table, I can simply do this:
if(flag1)
{
}
if(flag2)
{
}
if(flag3)
{
}
What it seems like I'm doing is answering questions about a two-dimensional table and putting the answers into one-dimensional values, i.e. the boolean flags.
Are there algorithms for this sort of thing?
|
|
|
|
|
Seems OK, but I suggest using an enum with the Flags attribute rather than three boolean values.
|
|
|
|
|
Hi everybody,
is there any formula and algorithm to calculate the distance between two points
on the earth using mercator coordinates (x,y) instead of WGS coordinates (Lat, lon)?
Many thanks.
Michela
|
|
|
|
|
Because of uniform grid size, for coordinate pairs between C and U verticals you can use euclidean distance taking into account the correct vertical and horizontal offsets. Outside of those ranges you have to maintain a list of width/height to accurately calculate intersected distance over those grids. There is a paper about UTM by a guy called Redfern, has some interesting notes.
|
|
|
|
|
michela wrote: is there any formula and algorithm to calculate the distance between two points
on the earth using mercator coordinates (x,y) instead of WGS coordinates (Lat, lon)?
Why on earth (heh) would you want distances to be calculated in Mercator coordinates?
Since it's a conformal cylindrical projection, the metric (i.e. distance between two points) will be awfully messy to calculate. It's much simpler to convert the coords and do the calculation that way.
|
|
|
|
|
|
I know that converting it on lat lon would result in a much simpler
way to do this!!! Unfortunately I have my Mercator coordinates and
I cannot convert tham back to WGS (also due to computational speed
issues) so I was looking for a formula who allows calculating distance
using only Mercator coordinates...
|
|
|
|
|
michela wrote: I have my Mercator coordinates and
I cannot convert tham back to WGS
Besides speed issues (although I can't imagine why the conversion would cause a speed issue ) why can't you convert them? It's a trivial calculation that can't possibly be CPU intense. I'm sure the calculation time is on the order of milliseconds or less. See here[^].
Doing the calculation in Mercator coords will require a look-up table of ratios and certainly require more calculation time than converting the coords. Furthermore, the distance calculation in Mercator units will not be a simple computation...
EDIT: if you're going to vote me a '1', at least give some reason as to why my answer was no good.
modified on Sunday, June 8, 2008 2:48 PM
|
|
|
|
|
Also having a table of ratio would be better than converting to WGS
and then using Vincenty formula to calculate distance between two points.
Do you know if there is any way to calculate these ratio factors?
Thanks.
|
|
|
|