Search Results

Search found 2776 results on 112 pages for 'overlapping matches'.

Page 1/112 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Merging and splitting overlapping rectangles to produce non-overlapping ones

    - by uj
    I am looking for an algorithm as follows: Given a set of possibly overlapping rectangles (All of which are "not rotated", can be uniformly represented as (left,top,right,bottom) tuplets, etc...), it returns a minimal set of (non-rotated) non-overlapping rectangles, that occupy the same area. It seems simple enough at first glance, but prooves to be tricky (at least to be done efficiently). Are there some known methods for this/ideas/pointers? Methods for not necessarily minimal, but heuristicly small, sets, are interesting as well, so are methods that produce any valid output set at all.

    Read the article

  • Mysql - Join matches and non-matches

    - by jwzk
    This is related to my other question: http://stackoverflow.com/questions/2579249/managing-foreign-keys I am trying to join the table of matches and non-matches. So I have a list of interests, a list of users, and a list of user interests. I want the query to return all interests, whether the user has the interest or not (should be null in that case), only where the user = x. Every time I get the query working its only matching interests that the user specifically has, instead of all interests whether they have it or not.

    Read the article

  • Overlapping matches with finditer() in Python

    - by Raphink
    Hi there, I'm using a regex to match Bible verse references in a text. The current regex is REF_REGEX = re.compile(r'(?<!\w)((?i)q(?:uote)?\s+)?((?:(?:[1-3]|I{1,3})\s*)?[A-Za-z]+)\.?(?:\s*(\d+)(?:[:.](\d+)(?:-(\d+))?)?)(?:\s+(?:(?i)(?:from\s+)|(?:in\s+)|(?P<lbrace>\())\s*(\w+)(?(lbrace)\)))?', re.UNICODE) This matches the following expressions fine: "jn 3:16": (None, 'jn', '3', '16', None, None, None), "matt. 18:21-22": (None, 'matt', '18', '21', '22', None, None), "q matt. 18:21-22": ('q ', 'matt', '18', '21', '22', None, None), "QuOTe jn 3:16": ('QuOTe ', 'jn', '3', '16', None, None, None), "q 1co13:1": ('q ', '1co', '13', '1', None, None, None), "q 1 co 13:1": ('q ', '1 co', '13', '1', None, None, None), "quote 1 co 13:1": ('quote ', '1 co', '13', '1', None, None, None), "quote 1co13:1": ('quote ', '1co', '13', '1', None, None, None), "jean 3:18 (PDV)": (None, 'jean', '3', '18', None, '(', 'PDV'), "quote malachie 1.1-2 fRom Colombe": ('quote ', 'malachie', '1', '1', '2', None, 'Colombe'), "quote malachie 1.1-2 In Colombe": ('quote ', 'malachie', '1', '1', '2', None, 'Colombe'), "cinq jn 3:16 (test)": (None, 'jn', '3', '16', None, '(', 'test'), "Q IIKings5.13-58 from wolof": ('Q ', 'IIKings', '5', '13', '58', None, 'wolof'), "This text is about lv5.4-6 in KJV only": (None, 'lv', '5', '4', '6', None, 'KJV'), but it fails to parse: "Found in 2 Cor. 5:18-21 ( Ministers": (None, '2 Cor', '5', '18', '21', None, None), because it returns (None, 'in', '2', None, None, None, None) instead. Is there a way to get finditer() to return all matches, even if they overlap, or is there a way to improve my regex so it matches this last bit properly? Thanks.

    Read the article

  • Overlapping elements stop overlapping in IE7 on class change

    - by Gazzer
    On this page http://zenchan.com/program/ When I rollover the right box 2nd from the top suddenly the overlapping (negative margin disappears). What's happening is that a 'hover' class is being added to shift the background sprite. The two yellow boxes are debugging: if the hover class is put their in advance there is no problem. So fundamentally the CSS is not a problem for IE7 but adding the class is. Any ideas what's causing this. I've tried adding haslayout to various elements but to little effect.

    Read the article

  • Returning partial address matches and mismatch position using L2S or SQL

    - by peter3
    I need to implement a method that takes an address split up into individual parts and returns any matching items from an address table. If no matches are found, I want to be able to return a value indicating where it failed. Each input param has a corresponding field in the table. The signature would look something like this: List<Address> MatchAddress(string zipCode, string streetName, string houseNumber, string houseLetter, string floor, string appartmentNo, out int mismatchPosition) { // return matching addresses // if none found, return the position where it stopped matching // zipCode is position 0, appartmentNo is position 5 // // an empty param value indicates "don't check" } I know I can construct the method such that I start with all the parameters, execute the query and then remove param by param (from the right side) until either a match is found or I run out of parameters, but can I construct a query that is more effective than that, i.e minimizing the number of calls to the db, maybe even as a single call?

    Read the article

  • How to give weight to full matches over partial matches (PostgreSQL)

    - by kagaku
    I've got a query that takes an input searches for the closet match in zipcode/region/city/metrocode in a location table containing a few tens of thousands of entries (should be nearly every city in the US). The query I'm using is: select metrocode, region, postalcode, region_full, city from dv_location where ( region ilike '%Chicago%' or postalcode ilike '%Chicago%' or city ilike '%Chicago%' or region_full ilike'%Chicago%' ) and metrocode is not null Odd thing is, the results set I'm getting back looks like this: metrocode;region;postalcode;region_full;city 862;CA;95712;California;Chicago Park 862;CA;95712;California;Chicago Park 602;IL;60611;Illinois;Chicago 602;IL;60610;Illinois;Chicago What am I doing wrong? My thinking is that Chicago would have greater weight than Chicago Park since Chicago is an exact match to the term (even though I'm asking for a wildcard match on the term).

    Read the article

  • Regex split into overlapping strings

    - by polygenelubricants
    I'm exploring the power of regular expressions, so I'm just wondering if something like this is possible: public class StringSplit { public static void main(String args[]) { System.out.println( java.util.Arrays.deepToString( "12345".split(INSERT_REGEX_HERE) ) ); // prints "[12, 23, 34, 45]" } } If possible, then simply provide the regex (and preemptively some explanation on how it works). If it's only possible in some regex flavors other than Java, then feel free to provide those as well. If it's not possible, then please explain why.

    Read the article

  • Algorithm for flattening overlapping ranges

    - by Joseph
    I am looking for a nice way of flattening (splitting) a list of potentially-overlapping numeric ranges. The problem is very similar to that of this question: Fastest way to split overlapping date ranges, and many others. However, the ranges are not only integers, and I am looking for a decent algorithm that can be easily implemented in Javascript or Python, etc. Example Data: Example Solution: Apologies if this is a duplicate, but I am yet to find a solution.

    Read the article

  • Fix overlapping partitions

    - by Alex
    I have problem with overlapping partitions. GParted shows me all my disk as unallocated area, output of fdisk below: alex@alex-ThinkPad-SL510:~$ sudo fdisk -l /dev/sda Disk /dev/sda: 320.1 GB, 320072933376 bytes 255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xfb4b9b90 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2457599 1227776 7 HPFS/NTFS/exFAT /dev/sda2 2457600 571351724 284447062+ 7 HPFS/NTFS/exFAT /dev/sda3 571342846 604661759 16659457 5 Extended /dev/sda4 604661760 625137663 10237952 7 HPFS/NTFS/exFAT /dev/sda5 598650880 604661759 3005440 82 Linux swap / Solaris /dev/sda6 571342848 598650879 13654016 83 Linux Partition table entries are not in disk order Do I understand correctly that overlapping partitions are sda2 and sda3 (sda2 and sda6 overlaps too, because sda6 is the first chunk of sda3, sda3 has type "extended")? Are sda2 and sda3 the cause of problem? How can i fix it without deleting partitions? My OS is Ubuntu 12.04, 64 bit. Thanks in advance.

    Read the article

  • bash terminal/console strange overlapping behavior

    - by UpKey
    I am using gnome-terminal in Ubuntu 11.10 and seem to get long lines overlapping in the terminal window. When I copy a long command line and paste it into the terminal, the text gets overlapped to the start of the line and often covers the user prompt. If I resize the terminal window, making it wider the overlapping gets undone and everything looks normal. In previous versions of Ubuntu, if a line was too long it would continue on the next line below. Another problem I have noticed that may be related, is when using the up arrow key to show previously typed commands, sometimes instead of the output command line being replaced by the previous command each time the key is pressed, the lines get partially merged. A portion of the old line remains, and the next command gets joined onto the end. This leftover part of a command is persistent and does not get replaced next time the key is pressed, although the insertion point or blinking cursor is at the end of the latest recalled command, and the leftover has no effect if I press enter. Is this problem a bug or some setting that needs fixing? Where do I look for the cause? keyboard? gnome-terminal? bash? Thank you for any help or suggestions offered

    Read the article

  • Adding VFACE semantic causes overlapping output semantics error

    - by user1423893
    My pixel shader input is a follows struct VertexShaderOut { float4 Position : POSITION0; float2 TextureCoordinates : TEXCOORD0; float4 PositionClone : TEXCOORD1; // Final position values must be cloned to be used in PS calculations float3 Normal : TEXCOORD2; //float3x3 TBN : TEXCOORD3; float CullFace : VFACE; // A negative value faces backwards (-1), while a positive value (+1) faces the camera (requires ps_3_0) }; I'm using ps_3_0 and I wish to utilise the VFACE semantic for correct lighting of normals depending on the cull mode. If I add the VFACE semantic then I get the following errors: error X5639: dcl usage+index: position,0 has already been specified for an output register error X4504: overlapping output semantics Why would this occur? I can't see why there would be too much data.

    Read the article

  • Operations on multiple overlapping layers not working

    - by Arun
    Hi I am developing a game in android just like Farmville by Zinga. In that game we have to place elements in the diamond shaped field so the don't overlap each other. Now I did coding for placing the field inside the farm field but I cannot stop the problem of overlapping of the farm field. I Am attaching the code that I have down for all this someone please help me.... try{ if(bm1.getPixel((int)initX,(int)initY)!=0){ if(bm1.getPixel((int)initX,(int)initY+20)!=0){ if(bm1.getPixel((int)initX-20,(int)initY)!=0){ if(bm1.getPixel((int)initX+20,(int)initY)!=0){ if(bm1.getPixel((int)initX,(int)initY-20)!=0){ c.drawBitmap(bm,initX-30,initY-20, paint); } } } } } }catch(Exception e) { Toast.makeText(getContext(), e.toString(), Toast.LENGTH_SHORT); }

    Read the article

  • Resizing partition using Gparted gives "can't have overlapping partitions" error

    - by Marcus
    I just decided to install Ubuntu 12.04 alongside Windows 7 on my Dell laptop. However I didn't do this manually but instead used the "Run Ubuntu alongside Windows 7" option upon installation, and now the partition that Ubuntu runs on has very little space (It's giving me warnings). I'm trying to use Gparted 0.12.1-5 (via a live CD) to give Windows less space and give Ubuntu more. I've managed to remove 100GB from the Windows partition so I now have some unallocated space between Windows and Ubuntu. This is what it looks like inside Ubuntu (not using the live CD, since it won't let me mount a USB to save a screenshot): http://i.stack.imgur.com/0keQq.png So first I take sda4 (extended?) and resize it to the left so it takes up all the unallocated space. Then I resize sda5 (ext4) as well so it takes up all the new space. However, when I hit apply, it fails on the first action (resizing sd4), saying "can't have overlapping partitions". Any ideas as to why this happens? I also tried resizing sda4 by just a few MB so that it definitely didn't overlap anything, but I still got the same error message. To clarify, I am doing it using the CD, I just took the screenshot from Ubuntu. Any help would be greatly appreciated! And again, I can't mount any USB (I'm following the guide on the gparted website but it says "Invalid argument" or something like that) so I couldn't attach the details file from Gparted. If this is needed, I may need some hints on how to solve the USB issue as well. :) Thanks

    Read the article

  • fdisk shows overlapping partitions

    - by Campa
    At every boot to start Ubuntu, a partition gets re-mounted more than 1 times, sometimes causing very long boots. Example below: > dmesg ... [ 21.472020] EXT4-fs (sda5): re-mounted. Opts: errors=remount-ro ... [ 42.021537] EXT4-fs (sda5): re-mounted. Opts: errors=remount-ro,commit=0 ... I suspect there is a problem of overlapping partitions here, regarding sda4 and sda5: > sudo fdisk -l Device Boot Start End Blocks Id System /dev/sda1 63 610469 305203+ de Dell Utility /dev/sda2 612352 32069631 15728640 7 HPFS/NTFS/exFAT /dev/sda3 * 32069632 238979788 103455078+ 7 HPFS/NTFS/exFAT /dev/sda4 238983166 625141759 193079297 5 Extended /dev/sda5 238983168 612630527 186823680 83 Linux /dev/sda6 612632576 625141759 6254592 82 Linux swap / Solaris Further details: > more /etc/fstab ... # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc nodev,noexec,nosuid 0 0 # / was on /dev/sda6 during installation UUID=b33be99b-5c9e-449e-ad48-be608aeff001 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda7 during installation UUID=7c9071cc-b77b-40da-9f80-6b8a9a220cb1 none swap sw and > mount /dev/sda5 on / type ext4 (rw,errors=remount-ro,commit=0) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) fusectl on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) gvfs-fuse-daemon on /home/piero/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=piero) I am Running Ubuntu Oneiric + LXDE on Dell Studio XPS machine 64-bit, dual booting with Windows 7. A months ago, I resized the Ubuntu partition and maybe I messed up something by doing that. Do you have any idea, why this long booting is happening?

    Read the article

  • Removing the "Cannot find a skin that matches family portal and version v1.1" message

    - by Maiko Rocha
    Do you get annoyed by the following message on your weblogic log output? <SkinFactoryImpl> <getSkin> Cannot find a skin that matches family portal and version v1.1. We will use the skin portal.desktop. Yes? Well, me too :-). To get rid of it just open your portal application's trinidad-config.xml file and remove the <skin-version> element from it. Before: <?xml version="1.0" encoding="UTF-8"?> <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">   <skin-family>#{preferenceBean.defaultTrinidadSkin}</skin-family> <skin-version>v1.1</skin-version> </trinidad-config> After: <?xml version="1.0" encoding="UTF-8"?> <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">   <skin-family>#{preferenceBean.defaultTrinidadSkin}</skin-family> </trinidad-config>

    Read the article

  • AndEngine; Box2D - high speed body overlapping, prismatic joints

    - by Visher
    I'm trying to make good suspension for my car game, but I'm getting nervous of some problems with it. At the beginning, I've tried to make it out of one prismatic joint/revolute joint per one wheel only, but surprisingly prismatic joint that should only move in Y asix moves also in X axis, if car travels very fast, or even on low speeds if there's setContinuousPhysics = true. This causes wheels to "shift back", moving them away from axle. Now I've tried to add some bodies that will keep it in place: Suspension helper collides with spring only, wheel doesn't collide with spring&helper&vehicle body This is how I create those elements: rect = new Rectangle(1100, 1350, 200, 50, getVertexBufferObjectManager()); rect.setColor(Color.RED); scene.attachChild(rect); //rect.setRotation(90); Rectangle miniRect1 = new Rectangle(1102, 1355, 30, 50, getVertexBufferObjectManager()); miniRect1.setColor(0, 0, 1, 0.5f); miniRect1.setVisible(true); scene.attachChild(miniRect1); Rectangle miniRect2 = new Rectangle(1268, 1355, 30, 50, getVertexBufferObjectManager()); miniRect2.setColor(0, 0, 1, 0.5f); miniRect1.setVisible(true); scene.attachChild(miniRect2); rectBody = PhysicsFactory.createBoxBody( physicsWorld, rect, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 10.0f)); rectBody.setUserData("car"); Body miniRect1Body = PhysicsFactory.createBoxBody( physicsWorld, miniRect1, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 10.0f)); miniRect1Body.setUserData("suspension"); Body miniRect2Body = PhysicsFactory.createBoxBody( physicsWorld, miniRect2, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 10.0f)); miniRect2Body.setUserData("suspension"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(rect, rectBody, true, true)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(miniRect1, miniRect1Body, true, true)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(miniRect2, miniRect2Body, true, true)); PrismaticJointDef miniRect1JointDef = new PrismaticJointDef(); miniRect1JointDef.initialize(rectBody, miniRect1Body, miniRect1Body.getWorldCenter(), new Vector2(0.0f, 0.3f)); miniRect1JointDef.collideConnected = false; miniRect1JointDef.enableMotor= true; miniRect1JointDef.maxMotorForce = 15; miniRect1JointDef.motorSpeed = 5; miniRect1JointDef.enableLimit = true; physicsWorld.createJoint(miniRect1JointDef); PrismaticJointDef miniRect2JointDef = new PrismaticJointDef(); miniRect2JointDef.initialize(rectBody, miniRect2Body, miniRect2Body.getWorldCenter(), new Vector2(0.0f, 0.3f)); miniRect2JointDef.collideConnected = false; miniRect2JointDef.enableMotor= true; miniRect2JointDef.maxMotorForce = 15; miniRect2JointDef.motorSpeed = 5; miniRect2JointDef.enableLimit = true; physicsWorld.createJoint(miniRect2JointDef); scene.attachChild(karoseriaSprite); Rectangle r1 = new Rectangle(1050, 1300, 52, 150, getVertexBufferObjectManager()); r1.setColor(0, 1, 0, 0.5f); r1.setVisible(true); scene.attachChild(r1); Body r1body = PhysicsFactory.createBoxBody(physicsWorld, r1, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.001f, 0.01f)); r1body.setUserData("suspensionHelper"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(r1, r1body, true, true)); WeldJointDef r1jointDef = new WeldJointDef(); r1jointDef.initialize(r1body, rectBody, r1body.getWorldCenter()); physicsWorld.createJoint(r1jointDef); Rectangle r2 = new Rectangle(1132, 1300, 136, 150, getVertexBufferObjectManager()); r2.setColor(0, 1, 0, 0.5f); r2.setVisible(true); scene.attachChild(r2); Body r2body = PhysicsFactory.createBoxBody(physicsWorld, r2, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.001f, 0.01f)); r2body.setUserData("suspensionHelper"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(r2, r2body, true, true)); WeldJointDef r2jointDef = new WeldJointDef(); r2jointDef.initialize(r2body, rectBody, r2body.getWorldCenter()); physicsWorld.createJoint(r2jointDef); Rectangle r3 = new Rectangle(1298, 1300, 50, 150, getVertexBufferObjectManager()); r3.setColor(0, 1, 0, 0.5f); r3.setVisible(true); scene.attachChild(r3); Body r3body = PhysicsFactory.createBoxBody(physicsWorld, r3, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(1f, 0.01f, 0.01f)); r3body.setUserData("suspensionHelper"); physicsWorld.registerPhysicsConnector(new PhysicsConnector(r3, r3body, true, true)); WeldJointDef r3jointDef = new WeldJointDef(); r3jointDef.initialize(r3body, rectBody, r3body.getWorldCenter()); physicsWorld.createJoint(r3jointDef); MouseJointDef md = new MouseJointDef(); Sprite wheel1 = new Sprite( miniRect1.getX()+miniRect1.getWidth()/2-wheelTexture.getWidth()/2, miniRect1.getY()+miniRect1.getHeight()-wheelTexture.getHeight()/2, wheelTexture, engine.getVertexBufferObjectManager()); scene.attachChild(wheel1); Body wheel1body = PhysicsFactory.createCircleBody( physicsWorld, wheel1, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 5.0f)); wheel1body.setUserData("wheel"); Shape wheel1shape = wheel1body.getFixtureList().get(0).getShape(); wheel1shape.setRadius(wheel1shape.getRadius()*(3.0f/4.0f)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(wheel1, wheel1body, true, true)); Sprite wheel2 = new Sprite( miniRect2.getX()+miniRect2.getWidth()/2-wheelTexture.getWidth()/2, miniRect2.getY()+miniRect2.getHeight()-wheelTexture.getHeight()/2, wheelTexture, engine.getVertexBufferObjectManager()); scene.attachChild(wheel2); Body wheel2body = PhysicsFactory.createCircleBody( physicsWorld, wheel2, BodyDef.BodyType.DynamicBody, PhysicsFactory.createFixtureDef(10.0f, 0.01f, 5.0f)); wheel2body.setUserData("wheel"); Shape wheel2shape = wheel2body.getFixtureList().get(0).getShape(); wheel2shape.setRadius(wheel2shape.getRadius()*(3.0f/4.0f)); physicsWorld.registerPhysicsConnector(new PhysicsConnector(wheel2, wheel2body, true, true)); RevoluteJointDef frontWheelRevoluteJointDef = new RevoluteJointDef(); frontWheelRevoluteJointDef.initialize(wheel1body, miniRect1Body, wheel1body.getWorldCenter()); frontWheelRevoluteJointDef.collideConnected = false; RevoluteJointDef rearWheelRevoluteJointDef = new RevoluteJointDef(); rearWheelRevoluteJointDef.initialize(wheel2body, miniRect2Body, wheel2body.getWorldCenter()); rearWheelRevoluteJointDef.collideConnected = false; rearWheelRevoluteJointDef.motorSpeed = 2050; rearWheelRevoluteJointDef.maxMotorTorque= 3580; physicsWorld.createJoint(frontWheelRevoluteJointDef); Joint j = physicsWorld.createJoint(rearWheelRevoluteJointDef); rearWheelRevoluteJoint = (RevoluteJoint)j; r1body.setBullet(true); r2body.setBullet(true); r3body.setBullet(true); miniRect1Body.setBullet(true); miniRect2Body.setBullet(true); rectBody.setBullet(true); at low speeds, it's OK, but on high speed vehicle can even flip around on flat ground.. Is there a way to make this work better?

    Read the article

  • 2D Collision in Canvas - Balls Overlapping When Velocity is High

    - by kushsolitary
    I am doing a simple experiment in canvas using Javascript in which some balls will be thrown on the screen with some initial velocity and then they will bounce on colliding with each other or with the walls. I managed to do the collision with walls perfectly but now the problem is with the collision with other balls. I am using the following code for it: //Check collision between two bodies function collides(b1, b2) { //Find the distance between their mid-points var dx = b1.x - b2.x, dy = b1.y - b2.y, dist = Math.round(Math.sqrt(dx*dx + dy*dy)); //Check if it is a collision if(dist <= (b1.r + b2.r)) { //Calculate the angles var angle = Math.atan2(dy, dx), sin = Math.sin(angle), cos = Math.cos(angle); //Calculate the old velocity components var v1x = b1.vx * cos, v2x = b2.vx * cos, v1y = b1.vy * sin, v2y = b2.vy * sin; //Calculate the new velocity components var vel1x = ((b1.m - b2.m) / (b1.m + b2.m)) * v1x + (2 * b2.m / (b1.m + b2.m)) * v2x, vel2x = (2 * b1.m / (b1.m + b2.m)) * v1x + ((b2.m - b1.m) / (b2.m + b1.m)) * v2x, vel1y = v1y, vel2y = v2y; //Set the new velocities b1.vx = vel1x; b2.vx = vel2x; b1.vy = vel1y; b2.vy = vel2y; } } You can see the experiment here. The problem is, some balls overlap each other and stick together while some of them rebound perfectly. I don't know what is causing this issue. Here's my balls object if that matters: function Ball() { //Random Positions this.x = 50 + Math.random() * W; this.y = 50 + Math.random() * H; //Random radii this.r = 15 + Math.random() * 30; this.m = this.r; //Random velocity components this.vx = 1 + Math.random() * 4; this.vy = 1 + Math.random() * 4; //Random shade of grey color this.c = Math.round(Math.random() * 200); this.draw = function() { ctx.beginPath(); ctx.fillStyle = "rgb(" + this.c + ", " + this.c + ", " + this.c + ")"; ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false); ctx.fill(); ctx.closePath(); } }

    Read the article

  • 3D models overlapping each other

    - by Auren
    I have a problem at the moment when I draw some models to teach me more about 3D game programming. The models at the moment overlaps each other from some angles witch makes sense since the game at the moment draws from left to right, line after line. However my question is: Is there any easy escape from this issue or is there any way that you could draw the in-game world from the players position? I would really appreciate if someone could give me some answers on this.

    Read the article

  • TSQL Challenge 31 - Managing multiple overlapping date intervals.

    This challenge is adapted from a budgeting system used in a large company to perform quarterly analysis of what kind of work will be done and where it will be done. Project Managers make plans and the estimated hours of work required from each employee each month end up in a central database. Top managers want to see a synthesis of this by department and profession

    Read the article

  • How to prevent overlapping of gunshot sounds when using fast-firing weapons

    - by G3tinmybelly
    So I am now trying to find sounds for my guns but when I grab a gun sound effect and play it in my game a lot of the sounds are either terrible sounding or have this horrible echoing effect because as a gun shoots sometimes the previous sound is playing still. public void shoot(float x, float y, float direction){ if(empty){ PlayHUD.message = "No more bullets!"; return; } if(reloading){ return; } if(System.currentTimeMillis() - lastShot < fireRate){ //AssetsLoader.lmgSound.stop(); return; } float dx = (float) (-13 * Math.cos(direction) + 75 * Math.sin(direction)); float dy = (float) (-14 * -Math.sin(direction) + 75 * Math.cos(direction)); float dx1 = (float) (-13 * Math.cos(direction) + 75 * Math.sin(direction)); float dy1 = (float) (-14 * -Math.sin(direction) + 75 * Math.cos(direction)); PlayState.effects.add(new MuzzleFlashEffect(x + dx1, y + dy1, (float) Math.toDegrees(-direction))); PlayState.projectiles.add(new Bullet(this, x + dx, y + dy, (float) (direction + (Math.toRadians(MathUtils.random(-accuracy, accuracy)))))); if(OptionState.soundOn){ AssetsLoader.lmgSound.play(OptionState.volume); } bulletsInClip--; lastShot = System.currentTimeMillis(); } Here is the code for where the sound plays. Every time this method is called the sound is called but it happens so often in this case that there is this terrible echoing. Any idea on how to fix this?

    Read the article

  • What programming language matches this description? [on hold]

    - by Benubird
    I am looking for a functional language that is basically dynamic programming - i.e. one where functions are first-class objects - but where all function calls are asynchronous by default; i.e. you define function X(a,b) = (Y(a)+Z(b)), and when X() is called, it sees it is waiting for the return from two functions, runs one in the current thread, and spawns a new thread to run the other. The future is very much parallel processing; multiple cores, multiple machines, the internet of things, etc. and I was wondering if there was a language specifically designed to make this kind of parallelization easy. I currently have only used imperative languages (c, php, java, ruby, etc), so I don't know anything about what kind of functional languages are available.

    Read the article

  • Overlapping text on top menu in Unity 12.04

    - by mercury
    So I'm new to Linux but am basically blown away by Ubuntu 12.04 and could definitely see this becoming my main desktop over time One small annoyance for me is a tendency for the global menu on the top bar to partially over-write the text description of the active window in the top panel. e.g. I focus on the "Ubuntu Software Centre" window which writes out that label in the leftmost corner of the top menu bar. If I then move the cursor up to the top menu bar to access the "file menu", this will partially overwrite the window name leaving just "Ubuntu" visible. This is a little slice of ugliness I don't want to see every day! Much easier on the eye for me would be to display the active window name at the centre of the top panel, using some of that free space and then have the global menu stay where it is, just to the right of the app launcher. I've found a solution to disable the global menu but I would prefer to keep it and instead move (or disable) the active window name in the top panel. Any way to do this?

    Read the article

  • regex matches with intersection in C#

    - by StuffHappens
    Hello. I wonder if it is possible to get MatchCollection with all matches even if there's intersection among them. string input = "a a a"; Regex regex = new Regex("a a"); MatchCollection matches = regex.Matches(input); Console.WriteLine(matches.Count); This code return 1, but I want it to return 2. How do achive it? Thank you for your help.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >