|
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.
|
|
|
|
|
michela wrote: Also having a table of ratio would be better than converting to WGS
Not only would the calculation be slower, it would also be difficult to implement and would produce inaccurate results.
michela wrote: Do you know if there is any way to calculate these ratio factors?
I am sure there is, but it is more difficult and less accurate than just converting to x,y...
|
|
|
|
|
How would I measure the 'entropic value'1 of a salt token added to a password before hashing with SHA-256? Should I be more concerned with the length of the salt, or its composition?
1 I just made up that term. Please feel free to enlighten me regarding the correct term.
Semicolons: The number one seller of ostomy bags world wide. - dan neely
|
|
|
|
|
Information entropy in a very general and oversimplified definition relates to compressibility of a sequence when the source is unknown.
When generating salt one assumes the source is random, hence the salt should have an entropy of 1. The length is not taken into account. If the salt is the result of a pattern or other known means then it will have a low entropy, something limiting to 0.
The end result is the entropy of the salt is of very little relevance when using a "decent" MD such as the one you have suggested, when hashing passwords.
|
|
|
|
|
Fascinating, thanks. I'd actually like to know more about this, so could you please suggest some online resources for a noob like me?
So am I correct in guessing that if the entropy is 1, a sequence cannot be decompressed at all, and at 0, it can always be decompressed?
Semicolons: The number one seller of ostomy bags world wide. - dan neely
|
|
|
|
|
Does anyone know the algorithm behind Windows Update, and other auto-update mechanisms?
Does the client browse a list of available updates on the server, or does the server receive an inventory from the client, and then the server decides what updates are to be applied?
“Cannot find REALITY.SYS...Universe Halted.”
~ God on phone with Microsoft Customer Support
|
|
|
|
|
I don't know about the windows update, but an online game server that I know checks a file in game folder, where some paramters are written by the update. If the parameters don't pass the test, the launcher ask you to make an update, and gives a shortcut to the updater. But it is not "auto", it requieres user confirmation. But if it is not updated, it may avoid the server connection (depending on what the new update changes)
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I'm looking for some code that determines from a series of
2D points, whether the points draw a:
- ellipse
- line
- rect
- polygon
if none of the above then just a assume a free form polyline. If the
function determines a ellipse, line or rect, then return a rect for
the bounds. Doesn't have to be super accurate, as it's for a demo program.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Assuming the ellipse, rectangle and line will be made from points ordered uniformly around their 'perimeter'...
If they represent...
1) An ellipse: the distances from the geometric centre to each point will be linearly distributed... ie: the average distance from the centre should be within an epsilon amount to half way between the maximum and minimum distances.
2) A line: take any two points and calculate the 'linear line equation' y=mx+c... then see if all other points fit the equation.
3) A rectangle: the points would fit into four 'linear line equations', one for each side; find a pair of points that at least one other points fits into, repeat with the remaining points until four sides have been found and there are no points left. (This is the hardest of the three... there may be a better way).
4) A polygon... if none of the other conditions apply.
Calculating the bounding rectangle is simple... look for maximum/minimum points in both the vertical/horizontal directions.
I believe I've done something like this before... I'll see if I can find some code.
Hope this helps.
Matthew Butler
|
|
|
|
|
Matthew Butler wrote: points ordered uniformly
I don't think you could assume this. The points would be collected while the user drags the mouse with the main button help down. So some of the points will be "closer" to each other than others because the speed at which the user moves the mouse will probably not be very even.
Thanks for the other suggestions though!
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
To solve the 'random mouse speed' you could only draw the next point when it is a pre-determined distance from the last... however that may not fit in with your design.
However a better way may be to look at the angles between successive points...
(This is how I did it)...
For a line, the angles would be around 180 degrees.
For a rectangle, there will be (over a few points), 3 x 90 degree turns, with the rest 180 degrees. (The end point will be in proximity to the first).
For an ellipse, the angles will always be either below or above 180 degrees... depending on whether it is drawn clockwise or not.
And a polygon will not follow any of the previous patterns.
... self explanitory.
I stored each shape's pattern and iterated through them looking for a match... similar to a regex... but geometrically, with an 'accuracy' value.
If not accurate enough (<75%), I assumed it to be random.
Hope this helps.
Matthew Butler
|
|
|
|
|
Matthew Butler wrote: For an ellipse, the angles will always be either below or above 180 degrees... depending on whether it is drawn clockwise or not
All it takes is a well drawn spiral, and BOOM!
Semicolons: The number one seller of ostomy bags world wide. - dan neely
|
|
|
|
|
Oops. So much for testing... I missed that one.
-one quick copy and paste later-
if (CalcLength(points[0], points[points.Length - 1]) > maxDev) return false;
Checkmate.
Matthew Butler
|
|
|
|
|
The maximum and minimum X Y coordinates will not do for an ellipse, you need to determine the equation for the ellipse and then take the end points of the axes.
|
|
|
|
|
I was refurring to the maximum and minimum distances between the points and the geometric centre... not the bounds of the ellipse.
......ooooooooooo......
...ooo.....|.....ooo...
..o........m........o..
.o.........|.........o.
.o.........X----M----o.
.o...................o.
..o.................o..
...ooo...........ooo...
......ooooooooooo...... m is the 'minimum' radius of the ellipse.
M is the 'maximum' radius of the ellipse.
If it was an ellipse, the average distance between each point and the centre, X, would be approximately equal to the (M + m) / 2;
This was my original idea... I posted my alternative method (my prefured way and the method I actually got running - in a past program) as a different reply.
I believe I saw this method a while ago, but I can't remember where.
Matthew Butler
|
|
|
|
|
In your definition wouldn't an ellipse or a rect be a polygon? so all you want to really know is if a set of points represent a line or a polygon.
Hence the simple solution is if the points aren't all collinear then they represent a polygon, otherwise they represent a line or line-segment.
|
|
|
|