Search Results

Search found 1014 results on 41 pages for 'collision'.

Page 24/41 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Tracking unique versions of files with hashes

    - by rwmnau
    I'm going to be tracking different versions of potentially millions of different files, and my intent is to hash them to determine I've already seen that particular version of the file. Currently, I'm only using MD5 (the product is still in development, so it's never dealt with millions of files yet), which is clearly not long enough to avoid collisions. However, here's my question - Am I more likely to avoid collisions if I hash the file using two different methods and store both hashes (say, SHA1 and MD5), or if I pick a single, longer hash (like SHA256) and rely on that alone? I know option 1 has 288 hash bits and option 2 has only 256, but assume my two choices are the same total hash length. Since I'm dealing with potentially millions of files (and multiple versions of those files over time), I'd like to do what I can to avoid collisions. However, CPU time isn't (completely) free, so I'm interested in how the community feels about the tradeoff - is adding more bits to my hash proportionally more expensive to compute, and are there any advantages to multiple different hashes as opposed to a single, longer hash, given an equal number of bits in both solutions?

    Read the article

  • Moving from Linear Probing to Quadratic Probing (hash collisons)

    - by Nazgulled
    Hi, My current implementation of an Hash Table is using Linear Probing and now I want to move to Quadratic Probing (and later to chaining and maybe double hashing too). I've read a few articles, tutorials, wikipedia, etc... But I still don't know exactly what I should do. Linear Probing, basically, has a step of 1 and that's easy to do. When searching, inserting or removing an element from the Hash Table, I need to calculate an hash and for that I do this: index = hash_function(key) % table_size; Then, while searching, inserting or removing I loop through the table until I find a free bucket, like this: do { if(/* CHECK IF IT'S THE ELEMENT WE WANT */) { // FOUND ELEMENT return; } else { index = (index + 1) % table_size; } while(/* LOOP UNTIL IT'S NECESSARY */); As for Quadratic Probing, I think what I need to do is change how the "index" step size is calculated but that's what I don't understand how I should do it. I've seen various pieces of code, and all of them are somewhat different. Also, I've seen some implementations of Quadratic Probing where the hash function is changed to accommodated that (but not all of them). Is that change really needed or can I avoid modifying the hash function and still use Quadratic Probing? EDIT: After reading everything pointed out by Eli Bendersky below I think I got the general idea. Here's part of the code at http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_hashtable.aspx: 15 for ( step = 1; table->table[h] != EMPTY; step++ ) { 16 if ( compare ( key, table->table[h] ) == 0 ) 17 return 1; 18 19 /* Move forward by quadratically, wrap if necessary */ 20 h = ( h + ( step * step - step ) / 2 ) % table->size; 21 } There's 2 things I don't get... They say that quadratic probing is usually done using c(i)=i^2. However, in the code above, it's doing something more like c(i)=(i^2-i)/2 I was ready to implement this on my code but I would simply do: index = (index + (index^index)) % table_size; ...and not: index = (index + (index^index - index)/2) % table_size; If anything, I would do: index = (index + (index^index)/2) % table_size; ...cause I've seen other code examples diving by two. Although I don't understand why... 1) Why is it subtracting the step? 2) Why is it diving it by 2?

    Read the article

  • What do the ddx and ddy values do in this AABB ray intersect algorithm?

    - by Paz
    Does anyone know what the ddx and ddy values do in the AABB ray intersect algorithm? Taken from the following site http://www.blitzbasic.com/codearcs/codearcs.php?code=1029 (show below). Local txmin#,txmax#,tymin#,tymax# // rox, rdx are the ray origin on the x axis, and ray delta on the x axis ... y-axis is roy and rdy Local ddx# =1.0/(rox-rdx) Local ddy# =1.0/(roy-rdy) If ddx >= 0 txmin = (bminx - rox) * ddx txmax = (bmaxx - rox) * ddx Else txmin = (bmaxx - rox) * ddx txmax = (bminx - rox) * ddx EndIf If ddy >= 0 tymin = (bminy - roy) * ddy tymax = (bmaxy - roy) * ddy Else tymin = (bmaxy - roy) * ddy tymax = (bminy - roy) * ddy EndIf If ( (txmin > tymax) Or (tymin > txmax) ) Return 0 If (tymin > txmin) txmin = tymin If (tymax < txmax) txmax = tymax Local tzmin#,tzmax# Local ddz# =1.0/(roz-rdz) If ddz >= 0 tzmin = (bminz - roz) * ddz tzmax = (bmaxz - roz) * ddz Else tzmin = (bmaxz - roz) * ddz tzmax = (bminz - roz) * ddz EndIf If (txmin > tzmax) Or (tzmin > txmax) Return 0 Return 1

    Read the article

  • Problem trying to move a CCSprite circle in Cocos2d

    - by thyrgle
    Hi, So I am trying to move a CCSprite (which has the picture of a circle and is 32 by 32 pixels) with ccTouchesBegan. I have tried the following: -(void) ccTouchesBegan:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint location = [touch locationInView:touch.view]; if ((location.x <= L1Circle1.position.x + 32 && location.x >= L1Circle2.position.x - 32) && (location.y <= L1Circle1.position.y + 32 || location.y >= L1Circle2.position.y - 32)) { L1Circle1.position = ccp(location.x, location.y); } } But, when I touch the screen in the simulator nothing happens... What am I doing wrong?

    Read the article

  • Objective-C function dispatch collisions; Or, how to achieve "namespaces"?

    - by fbrereto
    I have an application for Mac OS X that supports plugins that are intended to be loaded at the same time. Some of these plugins are built on top of a Cocoa framework that may receive updates in one plugin but not another. Given Objective-C's current method for function dispatching, any call from any plugin to a given Objective-C routine will go to the same routine every time. That means plugin A can find itself inside plugin B with a trivial Objective-C call! Obviously what we're looking for is for each plugin to interact with its own version of the framework upon which it was built. I have been reading some on Objective-C and this particular need, but haven't found a definitive solution for it yet. Update: My use of the word "framework" above is misleading: the framework is a statically-linked library, built into the plugin(s) that need it. The way Objective-C handles dispatching, however, even these statically linked pieces of disparate code will co-mingle in the Objective-C dispatcher, leading to unintended consequences. Update 2: I'm still a bit fuzzy on the answer provided here, as it doesn't seem to propose a solution as much as an unproven hypothesis.

    Read the article

  • Support-function in the GJK-algorithm.

    - by Marcus Johansson
    I am trying to implement the GJK-algorithm but I got stuck instantly. The problem is to implement the Support-function that isn't O(n^2). As it is now I'm computing the complete Minkowski difference, and then there is really no point in doing the GJK-algorithm. (or is it?) What I mean by Support-function is the function that returns the point in the Minkowski difference that is furthest away in a specified direction. I assume this shouldn't be O(n^2) as it is in my current implementation.

    Read the article

  • How to create a level with curved lines with cocos2d + Box2d on the iphone?

    - by Steven
    I'd like to create a game that has levels such as this: http://img169.imageshack.us/img169/7294/picdq.png The Player moves "flies" through the level and mustn't collide with the walls. How can I create such levels? I found that piece of software: http://www.sapusmedia.com/levelsvg/ It's not that cheap, so I wonder whether there is another way to create such a level as shown in the picture above...?

    Read the article

  • Cone-Line Segment Intersection 2D

    - by nophnoph
    Hi everyone, I would like to know is there any way to determine if a cone is intersecting with a (finite)line segment. The cone actually a circle located at P(x,y) with theta degree field of view and radius r. The simple visualization can be found here (sorry i can't post the picture here) I'm trying to do it in C# but I don't have any idea how to that, so for now this is what I'm doing : Check if the line segment is intersecting with the circle If the line segment is intersecting with the circle then I check every single point in the line segment using a function I found here. But I don't think this is the best way to do it. Does anyone have an idea? For additional info, I need this function to make some kind of simple vision simulator. Thanks in advance :)

    Read the article

  • Bouncing a ball off a surface

    - by Sagekilla
    Hi all, I'm currently in the middle of writing a game like Breakout, and I was wondering how I could properly bounce a ball off a surface. I went with the naive way of rotating the velocity by 180 degrees, which was: [vx, vy] -> [-vy, vx] Which (unsurprisingly) didn't work so well. If I know the position and veocity of the ball, as well as the point the ball would hit (but is going to instead bounce off of) how can I bounce it off that point? I don't need any language specific code. If anyone could provide a small, mathematical formula on how to properly do this that would work fine for me. I also need this to work with integer positions and velocity (I can't use floating point anywhere). Thanks!

    Read the article

  • Compiler error while compiling the RAPID library on VS2008

    - by Demi
    I've downloaded the RAPID library and tried to compile it on Microsoft Visual Studio 2008. However, I'm getting the following compiler error: C4430 missing type specifier - int assumed. Note: C++ does not support default-int at this code segment (the exact line that produces the error is int flag): class RAPID_model { public: box *b; int num_boxes_alloced; tri *tris; int num_tris; int num_tris_alloced; int build_state; int build_hierarchy(); friend RAPID_Collide(double R1[3][3], double T1[3], double s1, RAPID_model *RAPID_model1, double R2[3][3], double T2[3], double s2, RAPID_model *RAPID_model2, int flag); Can anyone please help me with this? Thank you

    Read the article

  • how to access a different movieclip within the flash in AS3

    - by Pieter888
    I've been trying to learn Action Script 3 the past few weeks, making tiny interactive games to learn the basics. I stumble upon a problem every now and then but most of the times google helps me out. But this problem has got me stuck so please help: The main stage contains two objects(movieclips), the player and a wall. The player has got his own code so when I drag in the player object I don't have to write any code into the main stage to be able to move the player. This all worked pretty well and I now wanted to add the wall so the player actually has something to bounce into. Now here is the problem, I want to check if the player touches the wall, I've done this before but that was when I used the main stage as my coding playground instead of putting the code in movieclips. How can I check if the player hits the wall within the movement code of the player object?

    Read the article

  • How to render a terrain using height maps and getting basic collision detection on top of the terrain and camera (moving on the terrain)

    - by M1kstur
    I have loaded a .RAW file into a 2x2 array in my class. The way I am rendering it works fine but I am struggling to get the camera to move on top of the terrain. The terrain renders from 0,0,0 (x,y,z) as that is where I put my camera. My camera class allows to the "camera" to move through the scene. I want to be able to "walk" on top of the terrain with some basic collision detection (if possible). Any tips on where to go for this or any tips?

    Read the article

  • Per-pixel collision detection - why does XNA transform matrix return NaN when adding scaling?

    - by JasperS
    I looked at the TransformCollision sample on MSDN and added the Matrix.CreateTranslation part to a property in my collision detection code but I wanted to add scaling. The code works fine when I leave scaling commented out but when I add it and then do a Matrix.Invert() on the created translation matrix the result is NaN ({NaN,NaN,NaN},{NaN,NaN,NaN},...) Can anyone tell me why this is happening please? Here's the code from the sample: // Build the block's transform Matrix blockTransform = Matrix.CreateTranslation(new Vector3(-blockOrigin, 0.0f)) * // Matrix.CreateScale(block.Scale) * would go here Matrix.CreateRotationZ(blocks[i].Rotation) * Matrix.CreateTranslation(new Vector3(blocks[i].Position, 0.0f)); public static bool IntersectPixels( Matrix transformA, int widthA, int heightA, Color[] dataA, Matrix transformB, int widthB, int heightB, Color[] dataB) { // Calculate a matrix which transforms from A's local space into // world space and then into B's local space Matrix transformAToB = transformA * Matrix.Invert(transformB); // When a point moves in A's local space, it moves in B's local space with a // fixed direction and distance proportional to the movement in A. // This algorithm steps through A one pixel at a time along A's X and Y axes // Calculate the analogous steps in B: Vector2 stepX = Vector2.TransformNormal(Vector2.UnitX, transformAToB); Vector2 stepY = Vector2.TransformNormal(Vector2.UnitY, transformAToB); // Calculate the top left corner of A in B's local space // This variable will be reused to keep track of the start of each row Vector2 yPosInB = Vector2.Transform(Vector2.Zero, transformAToB); // For each row of pixels in A for (int yA = 0; yA < heightA; yA++) { // Start at the beginning of the row Vector2 posInB = yPosInB; // For each pixel in this row for (int xA = 0; xA < widthA; xA++) { // Round to the nearest pixel int xB = (int)Math.Round(posInB.X); int yB = (int)Math.Round(posInB.Y); // If the pixel lies within the bounds of B if (0 <= xB && xB < widthB && 0 <= yB && yB < heightB) { // Get the colors of the overlapping pixels Color colorA = dataA[xA + yA * widthA]; Color colorB = dataB[xB + yB * widthB]; // If both pixels are not completely transparent, if (colorA.A != 0 && colorB.A != 0) { // then an intersection has been found return true; } } // Move to the next pixel in the row posInB += stepX; } // Move to the next row yPosInB += stepY; } // No intersection found return false; }

    Read the article

  • How can I implement collision detection for these tiles?

    - by Fiona
    I am wondering how this would be possible, if at all. In the image below: http://i.stack.imgur.com/d8cO3.png The light brows tiles are ground, while the dark brown is background, so the player can pass over those tiles. Here's the for loops that draws the level: float scale = 1f; for (row = 0; row < currentLevel.Rows; row++) { for (column = 0; column < currentLevel.Columns; column++) { Tile tile = (Tile)currentLevel.GetTile(row, column); if (tile == null) { continue; } Texture2D texture = tile.Texture; spriteBatch.Draw(texture, new Microsoft.Xna.Framework.Rectangle( (int)(column * currentLevel.CellSize.X * scale), (int)(row * currentLevel.CellSize.Y * scale), (int)(currentLevel.CellSize.X * scale), (int)(currentLevel.CellSize.Y * scale)), Microsoft.Xna.Framework.Color.White); } } Here's what I have so far to determine where to create a Rectangle: Microsoft.Xna.Framework.Rectangle[,,,] groundBounds = new Microsoft.Xna.Framework.Rectangle[?, ?, ?, ?]; int tileSize = 20; int screenSizeInTiles = 30; var tilePositions = new System.Drawing.Point[screenSizeInTiles, screenSizeInTiles]; for (int x = 0; x < screenSizeInTiles; x++) { for (int y = 0; y < screenSizeInTiles; y++) { tilePositions[x, y] = new System.Drawing.Point(x * tileSize, y * tileSize); groundBounds[x, y, tileSize, tileSize] = new Microsoft.Xna.Framework.Rectangle(x, y, 20, 20); } } First off, I'm not sure how to initialize the array groundBounds (I don't know how big to make it). Also, I'm not entirely sure how to go about adding information to groundBounds. I want to add a Rectangle for each tile in the level. Preferably I'd only make a Rectangle for those tiles accessible by the player, and not background tiles, but that's for a different day. FYI, the map was made with a freeware program called Realm Factory.

    Read the article

  • vector collision on polygon in 3d space detection/testing?

    - by LRFLEW
    In the 3d fps in java I'm working on, I need a bullet to be fired and to tell if it hit someone. All visual objects in the game are defined through OpenGL, so the object it can be colliding with can be any drawable polygon (although they will most likely be triangles and rectangles anyways). The bullet is not an object, but will be treated as a vector that instantaneously moves all the way across the map (like the snipper riffle in Halo). What's the best way to detect/test collisions with the polygon and the vector. I have access to OpenCL, however I have absolutely no experience with it. I am very early in the developmental stage, so if you think there's a better way of going about this, feel free to tell me (I barley have a player model to collide with anyways, so I'm flexible with it). Thanks

    Read the article

  • How to find collision detection side between two objects?

    - by user2362369
    I am using box2D and I have two objects, one is bouncy ball and the other one is block. I'd like to find which side of the block is collided with, so I can only make the ball bounce when it hits the top. I tried to implement many things like fixture data and by detecting position, using manifold but not get the accurate result. I also tried to calculate distance between two object but all went wrong.

    Read the article

  • Only Integrating Box2D collision detection in my 2d engine?

    - by Mr.Gando
    I have integrated box2d in my engine, ( Debug Draw, etc. ) and with a world I can throw in some 2d squares/rectangles etc. I saw this post, where the user is basically not using a world for collision detection, however the user doesn't explain anything about how he's using the manifold (b2Manifold), etc. Another post, is in the cocos2d forum, ( scroll down to the user Lam in the third reply ) Could anyone help me a bit with this?, basically want to add collision detection without the need of using b2World ,etc etc. Thanks a lot!

    Read the article

  • Calculate angle of moving ball after collision with angled or sloped wall that is a 2D line segment

    - by Ben Mc
    If you have a "ball" inside a 2D polygon, made up of say, 4 line segments that act as bounding walls, how do you calculate the angle of the ball after the collision with the irregularly sloped wall? I know how to make the ball bounce if the wall is horizontal, vertical, or at a 45 degree angle. I also have my code setup to detect a collision with the wall. I've read about dot products and normals, but I cannot figure out how to implement these in Java / Android. I'm completely stumped and feel like I've looked up everything 10 pages deep in Google 10 times now. I'm burned out trying to figure this out, I hope someone can help.

    Read the article

  • Collision detection on sub views contained in 2 separate parent UIViews?

    - by Chris
    Hi All, I originally setup some conditions using CGRectIntersectsRect for some collision detection which worked fine. In the greater scale of things I only need part of the view to be detected. So originally within the ViewController it was comparing 2 UIviews. Now what I need to do is collision detection of subViews within 2 different UIViews that are contained in a view in which the view controller does the logic. My script is no longer working as I suspect CGRectIntersectsRect only compares frames within the same view? I'll keep digging to confirm this. Any ways around this? Is it possible for example to get the x and y pos of the sub view in relation to the main view that's performing the logic?

    Read the article

  • Optimizing multiple dispatch notification algorithm in C#?

    - by Robert Fraser
    Sorry about the title, I couldn't think of a better way to describe the problem. Basically, I'm trying to implement a collision system in a game. I want to be able to register a "collision handler" that handles any collision of two objects (given in either order) that can be cast to particular types. So if Player : Ship : Entity and Laser : Particle : Entity, and handlers for (Ship, Particle) and (Laser, Entity) are registered than for a collision of (Laser, Player), both handlers should be notified, with the arguments in the correct order, and a collision of (Laser, Laser) should notify only the second handler. A code snippet says a thousand words, so here's what I'm doing right now (naieve method): public IObservable<Collision<T1, T2>> onCollisionsOf<T1, T2>() where T1 : Entity where T2 : Entity { Type t1 = typeof(T1); Type t2 = typeof(T2); Subject<Collision<T1, T2>> obs = new Subject<Collision<T1, T2>>(); _onCollisionInternal += delegate(Entity obj1, Entity obj2) { if (t1.IsAssignableFrom(obj1.GetType()) && t2.IsAssignableFrom(obj2.GetType())) obs.OnNext(new Collision<T1, T2>((T1) obj1, (T2) obj2)); else if (t1.IsAssignableFrom(obj2.GetType()) && t2.IsAssignableFrom(obj1.GetType())) obs.OnNext(new Collision<T1, T2>((T1) obj2, (T2) obj1)); }; return obs; } However, this method is quite slow (measurable; I lost ~2 FPS after implementing this), so I'm looking for a way to shave a couple cycles/allocation off this. I thought about (as in, spent an hour implementing then slammed my head against a wall for being such an idiot) a method that put the types in an order based on their hash code, then put them into a dictionary, with each entry being a linked list of handlers for pairs of that type with a boolean indication whether the handler wanted the order of arguments reversed. Unfortunately, this doesn't work for derived types, since if a derived type is passed in, it won't notify a subscriber for the base type. Can anyone think of a way better than checking every type pair (twice) to see if it matches? Thanks, Robert

    Read the article

  • What is the best way to solve an Objective-C namespace collision?

    - by Mecki
    Objective-C has no namespaces; it's much like C, everything is within one global namespace. Common practice is to prefix classes with initials, e.g. if you are working at IBM, you could prefix them with "IBM"; if you work for Microsoft, you could use "MS"; and so on. Sometimes the initials refer to the project, e.g. Adium prefixes classes with "AI" (as there is no company behind it of that you could take the initials). Apple prefixes classes with NS and says this prefix is reserved for Apple only. So far so well. But appending 2 to 4 letters to a class name in front is a very, very limited namespace. E.g. MS or AI could have an entirely different meanings (AI could be Artificial Intelligence for example) and some other developer might decide to use them and create an equally named class. Bang, namespace collision. Okay, if this is a collision between one of your own classes and one of an external framework you are using, you can easily change the naming of your class, no big deal. But what if you use two external frameworks, both frameworks that you don't have the source to and that you can't change? Your application links with both of them and you get name conflicts. How would you go about solving these? What is the best way to work around them in such a way that you can still use both classes? In C you can work around these by not linking directly to the library, instead you load the library at runtime, using dlopen(), then find the symbol you are looking for using dlsym() and assign it to a global symbol (that you can name any way you like) and then access it through this global symbol. E.g. if you have a conflict because some C library has a function named open(), you could define a variable named myOpen and have it point to the open() function of the library, thus when you want to use the system open(), you just use open() and when you want to use the other one, you access it via the myOpen identifier. Is something similar possible in Objective-C and if not, is there any other clever, tricky solution you can use resolve namespace conflicts? Any ideas? Update: Just to clarify this: answers that suggest how to avoid namespace collisions in advance or how to create a better namespace are certainly welcome; however, I will not accept them as the answer since they don't solve my problem. I have two libraries and their class names collide. I can't change them; I don't have the source of either one. The collision is already there and tips on how it could have been avoided in advance won't help anymore. I can forward them to the developers of these frameworks and hope they choose a better namespace in the future, but for the time being I'm searching a solution to work with the frameworks right now within a single application. Any solutions to make this possible?

    Read the article

  • How do you resolve the common naming collision between type and object?

    - by Catskul
    Since the standard c# convention is to capitalize the first letter of public properties, the old c++ convention of initial capital for type names, and initial lowercase for non-type names does not prevent the classic name collision where the most obvious object name matches the type name: class FooManager { public BarManager BarManager { get; set; } // Feels very wrong. // Recommended naming convention? public int DoIt() { // 1st and 2nd Bar Manager are different symbols return BarManager.Blarb + BarManager.StaticBlarb; } } class BarManager { public int Blarb { get; set; } public static int StaticBlarb { get; set; } } It seems to compile, but feels so wrong. Is there a recommend naming convention to avoid this?

    Read the article

  • Entity Type specific updates in entity component system

    - by Nathan
    I am currently familiarizing myself with the entity component paradigm. For an example, take a collision system, that detects if entities collide and if they do let them explode. So the collision system has to test collision based on the position component and then set the state of those entities to exploding. But what if the "effect" (setting the state to exploding) is different for different entities? For example, a ship fades out while for an asteroid a particle system must be created. Since entities and components are only data, this must happen in some system. The collision system could do it, but then it must switch over the entity type, which in my opinion is a cumbersome and difficult to extend solution. So how do I trigger "entity type dependend" updates on an entity?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >