Tag Info

Hot answers tagged

31

You can use the fact that colors make up a (three dimensional) color space and calculate a distance in this color space. You then need to define a metric in this color space to find the distance between two colors. E.g. the distance in a euclidean space between two points x = (x1, x2, x3) and y = (y1, y2, y3) is given by d(x,y) = sqrt( (y1-x1) * (y1-x1) + ...


12

Yay I found a research paper! In terms of computational cost Shadow Mapping seems pretty clear winner. Algorithm used can be found here and a C# implementation can be found here, relevant bit below. #region FOV algorithm // Octant data // // \ 1 | 2 / // 8 \ | / 3 // -----+----- // 7 / | \ 4 // / 6 | 5 \ ...


8

The United Nations web accessibility standards page (http://www.un.org/webaccessibility/1_visual/13_colourcontrast.shtml) does indicate a standard for ensuring proper text contrast on websites, keeping in mind that some users are colorblind. This might be particularly important for you since some of your users may be colorblind as well (would be hard to tell ...


3

Blue's idea is good, but the implementation is a bit clumsy. In fact, you can easily do it without sqrt. Let's assume for the moment that you exclude degenerate cases (BeginX==EndX || BeginY==EndY) and focus only on line directions in the first quadrant, so BeginX < EndX && BeginY < EndY. You'll have to implement a version for at least one ...


2

Using RGB values by generating a random 0-255 value for each component might not only create colors that are similar to the background, you can also end up with very similar colors for the balls. I'd probably choose a less random approach and create colors that are guaranteed to be different instead. You could create a color for each ~32 degrees in the hue ...


2

Your assumption isn't necessarily to find the cells but the lines it cross on this grid. For example taking your image we can highlight not the cells, but lines of the grid it crosses: This then shows that if it crosses a grid line that the cells either side of this line are those that are filled. You can use an intersection algorithm to find if your ...


2

You are looking for a grid traversal algorithm. This paper gives a good implementation; use the 2D version. There's also a 3D ray-casting version on the paper. In case the link rots, you can find many mirrors with its name: A faster voxel traversal algorithm for raytracing.


1

How about: (width/amountPartitions) * partitionNo + (width/amountPartitions/2) + posFirstPartition So for your example for the first partition (counting from 0) this would be: (6/3) * 0 + (6/3/2) - 2 1 - 2 -1 Which should be what you indicated in your picture. This is assuming all partitions are the same size.


1

Actually, the negative vector of the most recently added point will not always be a good search direction. I can understand if your intuition brought you to this conclusion, but it's wrong. Search directions are about finding support points that are furthest along a Voronoi region, away from the current simplex. Search directions are not only about ...


1

I guess you want some ant like behavior (at least as far as comic ants are concerned)? http://www.youtube.com/watch?v=HccgCeVo-4c If so, I'd try the following: Pick the entity closest to the target as the "head" and mark it so it won't look for another entity to follow. For each remaining entity, find the next closest entity that doesn't have a follower ...


1

For a RGB format, this seems to work well enough and is trivial: diversity_score = (abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2)) / 765.0 This will give you a score between 0.0 and 1.0. The lower, the harder it is to distinguish two colors. It should be obvious, but for the sake of completeness: the r, g, b values must be cast to a floating point number ...


1

I'd like to expand upon @ashes999's idea of creating an outline. My code is going to be as python-like as I can off the top of my head (I've never written a line of python in my life, but I've glanced over a book once or twice). def lerp(a,b,value): # assuming your library was not kind enough to give you this for free return a + ((b - a) * value); def ...


1

Since you din mentioned you got a stationary background, the color of the balls can still be a random but they have to fall at certain ranges that still compliments the background. Basics. Before we do that you need to know the basics. Consider the following colors: Black #000000 rgb(0,0,0) Red #FF0000 rgb(255,0,0) Green #00FF00 rgb(0,255,0) Blue ...


1

I'll refer to map nodes as tiles for the purpose of explanation, but the principles are the same. If you have more than one node in an area, then your "tile" would contain an array or list of nodes. For all of these, graph theoretic applications can be applied, though the method of application becomes more or less complex depending on what specific algorithm ...



Only top voted, non community-wiki answers of a minimum length are eligible