Search Results

Search found 787 results on 32 pages for 'floor planner'.

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

  • Recursive code Sorting in VB

    - by Peter
    Ages old question: You have 2 hypothetical eggs, and a 100 story building to drop them from. The goal is to have the least number of guaranteed drops that will ensure you can find what floor the eggs break from the fall. You can only break 2 eggs. Using a 14 drop minimum method, I need help writing code that will allow me to calculate the following: Start with first drop attempt on 14th floor. If egg breaks then drop floors 1-13 to find the floor that causes break. ElseIf egg does not break then move up 13 floors to floor number 27 and drop again. If egg breaks then drop floors 15-26 starting on 15 working up to find the floor egg breaks on. ElseIf egg does not break then move up 12 floors to floor number 39 and drop again. etc. etc. The way this increases is as follows 14+13+12+11+10+9+8+7+6+5+4+3+2+1 So always adding to the previous value, by one less. I have never written a sorting algorithm before, and was curious how I might go about setting this up in a much more efficient way than a mile long of if then statements. My original idea was to store values for the floors in an array, and pull from that, using the index to move up or down and subtract or add to the variables. The most elegant solution would be a recursive function that handled this for any selected floor, 1-100, and ran the math, with an output that shows how many drops were needed in order to find that floor. Maximum is always 14, but some can be done in less.

    Read the article

  • How to query on table returned by Stored procedure within a procedure.

    - by Shantanu Gupta
    I have a stored procedure that is performing some ddl dml operations. It retrieves a data after processing data from CTE and cross apply and other such complex things. Now this returns me a 4 tables which gets binded to various sources at frontend. Now I want to use one of the table to further processing so as to get more usefull information from it. eg. This table would be containing approx 2000 records at most of which i want to get records that belongs to lodging only. PK_CATEGORY_ID DESCRIPTION FK_CATEGORY_ID IMMEDIATE_PARENT Department_ID Department_Name DESCRIPTION_HIERARCHY DEPTH IS_ACTIVE ID_PATH DESC_PATH -------------------- -------------------------------------------------- -------------------- -------------------------------------------------- -------------------- -------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------- ----------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 Food NULL NULL 1 Food (Food) Food 0 1 0 Food 5 Chinese 1 Food 1 Food (Food) ----Chinese 1 1 1 Food->Chinese 14 X 5 Chinese 1 Food (Food) --------X 2 1 1->5 Food->Chinese->X 15 Y 5 Chinese 1 Food (Food) --------Y 2 1 1->5 Food->Chinese->Y 65 asdasd 5 Chinese 1 Food (Food) --------asdasd 2 1 1->5 Food->Chinese->asdasd 66 asdas 5 Chinese 1 Food (Food) --------asdas 2 1 1->5 Food->Chinese->asdas 8 Italian 1 Food 1 Food (Food) ----Italian 1 1 1 Food->Italian 48 hfghfgh 1 Food 1 Food (Food) ----hfghfgh 1 1 1 Food->hfghfgh 55 Asd 1 Food 1 Food (Food) ----Asd 1 1 1 Food->Asd 2 Lodging NULL NULL 2 Lodging (Lodging) Lodging 0 1 0 Lodging 3 Room 2 Lodging 2 Lodging (Lodging) ----Room 1 1 2 Lodging->Room 4 Floor 3 Room 2 Lodging (Lodging) --------Floor 2 1 2->3 Lodging->Room->Floor 9 First 4 Floor 2 Lodging (Lodging) ------------First 3 1 2->3->4 Lodging->Room->Floor->First 10 Second 4 Floor 2 Lodging (Lodging) ------------Second 3 1 2->3->4 Lodging->Room->Floor->Second 11 Third 4 Floor 2 Lodging (Lodging) ------------Third 3 1 2->3->4 Lodging->Room->Floor->Third 29 Fourth 4 Floor 2 Lodging (Lodging) ------------Fourth 3 1 2->3->4 Lodging->Room->Floor->Fourth 12 Air Conditioned 3 Room 2 Lodging (Lodging) --------Air Conditioned 2 1 2->3 Lodging->Room->Air Conditioned 20 With Balcony 12 Air Conditioned 2 Lodging (Lodging) ------------With Balcony 3 1 2->3->12 Lodging->Room->Air Conditioned->With Balcony 24 Mountain View 20 With Balcony 2 Lodging (Lodging) ----------------Mountain View 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Mountain View 25 Ocean View 20 With Balcony 2 Lodging (Lodging) ----------------Ocean View 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Ocean View 26 Garden View 20 With Balcony 2 Lodging (Lodging) ----------------Garden View 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Garden View 52 Smoking 20 With Balcony 2 Lodging (Lodging) ----------------Smoking 4 1 2->3->12->20 Lodging->Room->Air Conditioned->With Balcony->Smoking 21 Without Balcony 12 Air Conditioned 2 Lodging (Lodging) ------------Without Balcony 3 1 2->3->12 Lodging->Room->Air Conditioned->Without Balcony 13 Non Air Conditioned 3 Room 2 Lodging (Lodging) --------Non Air Conditioned 2 1 2->3 Lodging->Room->Non Air Conditioned 22 With Balcony 13 Non Air Conditioned 2 Lodging (Lodging) ------------With Balcony 3 1 2->3->13 Lodging->Room->Non Air Conditioned->With Balcony 71 EA 3 Room 2 Lodging (Lodging) --------EA 2 1 2->3 Lodging->Room->EA 50 Casabellas 2 Lodging 2 Lodging (Lodging) ----Casabellas 1 1 2 Lodging->Casabellas 51 North Beach 50 Casabellas 2 Lodging (Lodging) --------North Beach 2 1 2->50 Lodging->Casabellas->North Beach 40 Fooding NULL NULL 40 Fooding (Fooding) Fooding 0 1 0 Fooding 41 Pizza 40 Fooding 40 Fooding (Fooding) ----Pizza 1 1 40 Fooding->Pizza 45 Onion 41 Pizza 40 Fooding (Fooding) --------Onion 2 1 40->41 Fooding->Pizza->Onion 47 Extra Cheeze 41 Pizza 40 Fooding (Fooding) --------Extra Cheeze 2 1 40->41 Fooding->Pizza->Extra Cheeze 77 Burger 40 Fooding 40 Fooding (Fooding) ----Burger 1 1 40 Fooding->Burger This result is being obtained to me using some stored procedure which contains some DML operations as well. i want something like this select description from exec spName where fk_category_id=5 Remember that this spName is returning me 4 tables of which i want to perform some query on one of the table whose index will be known to me. I dont have to send it to UI before querying further. I am using Sql Server 2008 but would like a compatible solution for 2005 also.

    Read the article

  • Throwing cats out of windows

    - by AndrewF
    Imagine you're in a tall building with a cat. The cat can survive a fall out of a low story window, but will die if thrown from a high floor. How can you figure out the longest drop that the cat can survive, using the least number of attempts? Obviously, if you only have one cat, then you can only search linearly. First throw the cat from the first floor. If it survives, throw it from the second. Eventually, after being thrown from floor f, the cat will die. You then know that floor f-1 was the maximal safe floor. But what if you have more than one cat? You can now try some sort of logarithmic search. Let's say that the build has 100 floors and you have two identical cats. If you throw the first cat out of the 50th floor and it dies, then you only have to search 50 floors linearly. You can do even better if you choose a lower floor for your first attempt. Let's say that you choose to tackle the problem 20 floors at a time and that the first fatal floor is #50. In that case, your first cat will survive flights from floors 20 and 40 before dying from floor 60. You just have to check floors 41 through 49 individually. That's a total of 12 attempts, which is much better than the 50 you would need had you attempted to use binary elimination. In general, what's the best strategy and it's worst-case complexity for an n-storied building with 2 cats? What about for n floors and m cats? Assume that all cats are equivalent: they will all survive or die from a fall from a given window. Also, every attempt is independent: if a cat survives a fall, it is completely unharmed. This isn't homework, although I may have solved it for school assignment once. It's just a whimsical problem that popped into my head today and I don't remember the solution. Bonus points if anyone knows the name of this problem or of the solution algorithm.

    Read the article

  • Tile-based 2D collision detection problems

    - by Vee
    I'm trying to follow this tutorial http://www.tonypa.pri.ee/tbw/tut05.html to implement real-time collisions in a tile-based world. I find the center coordinates of my entities thanks to these properties: public float CenterX { get { return X + Width / 2f; } set { X = value - Width / 2f; } } public float CenterY { get { return Y + Height / 2f; } set { Y = value - Height / 2f; } } Then in my update method, in the player class, which is called every frame, I have this code: public override void Update() { base.Update(); int downY = (int)Math.Floor((CenterY + Height / 2f - 1) / 16f); int upY = (int)Math.Floor((CenterY - Height / 2f) / 16f); int leftX = (int)Math.Floor((CenterX + Speed * NextX - Width / 2f) / 16f); int rightX = (int)Math.Floor((CenterX + Speed * NextX + Width / 2f - 1) / 16f); bool upleft = Game.CurrentMap[leftX, upY] != 1; bool downleft = Game.CurrentMap[leftX, downY] != 1; bool upright = Game.CurrentMap[rightX, upY] != 1; bool downright = Game.CurrentMap[rightX, downY] != 1; if(NextX == 1) { if (upright && downright) CenterX += Speed; else CenterX = (Game.GetCellX(CenterX) + 1)*16 - Width / 2f; } } downY, upY, leftX and rightX should respectively find the lowest Y position, the highest Y position, the leftmost X position and the rightmost X position. I add + Speed * NextX because in the tutorial the getMyCorners function is called with these parameters: getMyCorners (ob.x+ob.speed*dirx, ob.y, ob); The GetCellX and GetCellY methods: public int GetCellX(float mX) { return (int)Math.Floor(mX / SGame.Camera.TileSize); } public int GetCellY(float mY) { return (int)Math.Floor(mY / SGame.Camera.TileSize); } The problem is that the player "flickers" while hitting a wall, and the corner detection doesn't even work correctly since it can overlap walls that only hit one of the corners. I do not understand what is wrong. In the tutorial the ob.x and ob.y fields should be the same as my CenterX and CenterY properties, and the ob.width and ob.height should be the same as Width / 2f and Height / 2f. However it still doesn't work. Thanks for your help.

    Read the article

  • Drawing shapes dynamically on an image through web browser

    - by Tom Beech
    We have a scenario where we create floor plans of locations when we visit. The floor plan is finally shown on the web. It's come to the point now where we want to show floor plans but have a key with various items on them, when an item on the key is clicked, the image should highlight all the areas of the floorplan that have that specific item. I guess we're looking for some sort of open standard javascript lib to deal with SVG (has to work pre IE9 so pure SVG wont cut it) and the floor plans have to be able to be created through a .net application to be deployed on the web. I'd rather stay away from flash if at all possible to be honest. Below are a few conceptual images of what we're trying to achieve.

    Read the article

  • Multiple SSIDs better or worse

    - by swiss196
    I'm just setting up a network in a student house with 10 rooms, 3 floors. Configuration at the moment is as follows: Virgin Media 100mb Cable Virgin SuperHub on ground floor broadcasting on SSID1 Second AP(Edimax) wired on middle floor broadcasting on SSID2 These two networks server all 3 floors fairly well but I was wondering whether it would be better to setup an individual SSID for each floor (both the routers allow me to configure up to 3 ssids on each!). Would this help with speed issues, i.e if someone on the top floor is downloading/streaming etc, this wouldn't affect someone on the middle floor on a different SSID Or, will it have no effect? Thanks, Dave

    Read the article

  • A Christmas Query

    - by Gilles Haro
    Let’s celebrate Christmas with this absolutely useless query ! with Mx as (select 60 as MaxWidth from dual) select decode          ( sign(floor(MaxWidth /2)-rownum)          , 1          , lpad( ' ', floor(MaxWidth /2)-(rownum-1)) || rpad( '*', 2*(rownum-1)+1, ' *')          , lpad( '* * *', floor(MaxWidth/2)+3)         )    from all_tables, Mx  where rownum < floor(MaxWidth /2) + 6; Merry Christmas !   Gilles Haro Technical Expert - Core Technology, Oracle Consulting

    Read the article

  • How does sprite customization in 2D games work?

    - by Alouette
    I´m working on the design of a new game concept at the moment and I would like to know how to handle a customization of sprites. (In 2D that is, hence the topic.) This is my scenario: The player will have a tower containing 3 floors (or more). Each floor can be replaced by another "piece", i.e. a blue floor, a fire floor, a stone floor. With the little knowledge of game development I have, creating a sprite for each possible combination is probably not a good idea, since the size of the game file will be HUGE. So, how does developers solve this? Do you put a standard position and just replace the sprite itself? Any advice or information about this would be great. Regards.

    Read the article

  • Oracle Enterprise Manager 12c(EM12c):????????? ~??????~

    - by Kumiko Fujita
    ?????? = ?????????????????? Oracle Enterprise Manager 12c?????????????????????????????????????????????????????????????????????????????·????????????Infrastructure as a Service(IaaS)???Database as a Service(DBaaS)????????????????? ?????? ??????? 1. Consolidation Planner -??????????????????????!- Consolidation Planner?????????????????·??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Consolidation Planner???????????????????????????????????????????????????????????? 2. Cloud Management(Oracle VM??) -???????????????????????!- ??????·???????????????????????????????????????????????????????????????/???????????????????????????????????Cloud Management??????????????????????????Oracle VM 3.0????????????????????????????·?????????????????????????????????????????????????????????????????????????·?????????????????????? 3. Chargeback and Trending -?????????????????????????!- ??????·????????????????????????????????????????????????????????????Chargeback and Trending???????????????????????????Oracle WebLogic Server???????????????????????????????????????????????????????????????????????CPU????/?????????????????????????????????????????????????????????????????????????????????????????????????? ??????! ?????Cloud Management?(PDF) ?????????(????????????????) WMV(??) WMV(??) MP4(??) MP4(??)

    Read the article

  • PHP Form checkbox question

    - by Sef
    Hello, I have a form that takes the following inputs: Name: IBM Surface(in m^2): 9 Floor: (Checkbox1) Phone: (Checkbox2) Network: (Checkbox3) Button to send to a next php page. All those values above are represented in a table when i press the submit button. The first two (name and surname) are properly displayed in the table. The problem is with the checkboxes. If i select the first checkbox the value in the table should be presented with 1. If its not selected the value in the table should be empty. echo "<td>$Name</td>"; // works properly echo "<td>$Surface</td>"; // works properly echo "<td>....no idea for the checkboxes</td>; Some part of my php code with the variables: <?php if (!empty($_POST)) { $standnaam = $_POST["name"]; $oppervlakte = $_POST["surface"]; $verdieping = $_POST["floor"]; $telefoon = $_POST["telefoon"]; $netwerk = $_POST["netwerk"]; if (is_numeric($surface)) { $_SESSION["name"]=$name; $_SESSION["surface"]=$surface; header("Location:ExpoOverzicht.php"); } else { echo "<h1>Wrong input, Pleasee fill in again</h1>"; } if(!empty($floor) && ($phone) && ($network)) { $_SESSION["floor"]=$floor; $_SESSION["phone"]=$phone; $_SESSION["network"]=$network; header("Location:ExpoOverzicht.php"); } } ?> Second page with table: <?php $name= $_SESSION["name"]; $surface= $_SESSION["surface"]; $floor= $_SESSION["floor"]; $phone= $_SESSION["phone"]; $network= $_SESSION["network"]; echo "<table class=\"tableExpo\">"; echo "<th>name</th>"; echo "<th>surface</th>"; echo "<th>floor</th>"; echo "<th>phone</th>"; echo "<th>network</th>"; echo "<th>total price</th>"; for($i=0; $i <= $_SESSION["name"]; $i++) { echo "<tr>"; echo "<td>$name</td>"; // gives right output echo "<td>$surface</td>"; // gives right output echo "<td>...</td>"; //wrong output (ment for checkbox 1) echo "<td>...</td>"; //wrong output (ment for checkbox 2) echo "<td>...</td>"; //wrong output (ment for checkbox 3) echo "<td>....</td>"; echo "</tr>;"; } echo "</table>"; <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" id="form1"> <h1>Vul de gegevens in</h1> <table> <tr> <td>Name:</td> <td><input type="text" name="name" size="18"/></td> </tr> <tr> <td>Surface(in m^2):</td> <td><input type="text" name="surface" size="6"/></td> </tr> <tr> <td>Floor:</td> <td><input type="checkbox" name="floor" value="floor"/></td> </tr> <tr> <td>Phone:</td> <td><input type="checkbox" name="phone" value="phone"/></td> </tr> <tr> <td>Network:</td> <td><input type="checkbox" name="network" value="network"/></td> </tr> <tr> <td><input type="submit" name="verzenden" value="Verzenden"/></td> </tr> </table> There might be a few spelling mistakes since i had to translate it. Best regards.

    Read the article

  • postgreSQL - pg_class question

    - by Sachin Chourasiya
    PostgreSQL stores statistics about tables in the system table called pg_class. The query planner accesses this table for every query. These statistics may only be updated using the analyze command. If the analyze command is not run often, the statistics in this table may not be accurate and the query planner may make poor decisions which can degrade system performance. Another strategy is for the query planner to generate these statistics for each query (including selects, inserts, updates, and deletes). This approach would allow the query planner to have the most up-to-date statistics possible. Why postgres always rely on pg_class instead?

    Read the article

  • postgres SQL - pg_class question

    - by Sachin Chourasiya
    PostgreSQL stores statistics about tables in the system table called pg_class. The query planner accesses this table for every query. These statistics may only be updated using the analyze command. If the analyze command is not run often, the statistics in this table may not be accurate and the query planner may make poor decisions which can degrade system performance. Another strategy is for the query planner to generate these statistics for each query (including selects, inserts, updates, and deletes). This approach would allow the query planner to have the most up-to-date statistics possible. Why postgres always rely on pg_class instead?

    Read the article

  • Movement and Collision with AABB

    - by Jeremy Giberson
    I'm having a little difficulty figuring out the following scenarios. http://i.stack.imgur.com/8lM6i.png In scenario A, the moving entity has fallen to (and slightly into the floor). The current position represents the projected position that will occur if I apply the acceleration & velocity as usual without worrying about collision. The Next position, represents the corrected projection position after collision check. The resulting end position is the falling entity now rests ON the floor--that is, in a consistent state of collision by sharing it's bottom X axis with the floor's top X axis. My current update loop looks like the following: // figure out forces & accelerations and project an objects next position // check collision occurrence from current position -> projected position // if a collision occurs, adjust projection position Which seems to be working for the scenario of my object falling to the floor. However, the situation becomes sticky when trying to figure out scenario's B & C. In scenario B, I'm attempt to move along the floor on the X axis (player is pressing right direction button) additionally, gravity is pulling the object into the floor. The problem is, when the object attempts to move the collision detection code is going to recognize that the object is already colliding with the floor to begin with, and auto correct any movement back to where it was before. In scenario C, I'm attempting to jump off the floor. Again, because the object is already in a constant collision with the floor, when the collision routine checks to make sure moving from current position to projected position doesn't result in a collision, it will fail because at the beginning of the motion, the object is already colliding. How do you allow movement along the edge of an object? How do you allow movement away from an object you are already colliding with. Extra Info My collision routine is based on AABB sweeping test from an old gamasutra article, http://www.gamasutra.com/view/feature/3383/simple_intersection_tests_for_games.php?page=3 My bounding box implementation is based on top left/bottom right instead of midpoint/extents, so my min/max functions are adjusted. Otherwise, here is my bounding box class with collision routines: public class BoundingBox { public XYZ topLeft; public XYZ bottomRight; public BoundingBox(float x, float y, float z, float w, float h, float d) { topLeft = new XYZ(); bottomRight = new XYZ(); topLeft.x = x; topLeft.y = y; topLeft.z = z; bottomRight.x = x+w; bottomRight.y = y+h; bottomRight.z = z+d; } public BoundingBox(XYZ position, XYZ dimensions, boolean centered) { topLeft = new XYZ(); bottomRight = new XYZ(); topLeft.x = position.x; topLeft.y = position.y; topLeft.z = position.z; bottomRight.x = position.x + (centered ? dimensions.x/2 : dimensions.x); bottomRight.y = position.y + (centered ? dimensions.y/2 : dimensions.y); bottomRight.z = position.z + (centered ? dimensions.z/2 : dimensions.z); } /** * Check if a point lies inside a bounding box * @param box * @param point * @return */ public static boolean isPointInside(BoundingBox box, XYZ point) { if(box.topLeft.x <= point.x && point.x <= box.bottomRight.x && box.topLeft.y <= point.y && point.y <= box.bottomRight.y && box.topLeft.z <= point.z && point.z <= box.bottomRight.z) return true; return false; } /** * Check for overlap between two bounding boxes using separating axis theorem * if two boxes are separated on any axis, they cannot be overlapping * @param a * @param b * @return */ public static boolean isOverlapping(BoundingBox a, BoundingBox b) { XYZ dxyz = new XYZ(b.topLeft.x - a.topLeft.x, b.topLeft.y - a.topLeft.y, b.topLeft.z - a.topLeft.z); // if b - a is positive, a is first on the axis and we should use its extent // if b -a is negative, b is first on the axis and we should use its extent // check for x axis separation if ((dxyz.x >= 0 && a.bottomRight.x-a.topLeft.x < dxyz.x) // negative scale, reverse extent sum, flip equality ||(dxyz.x < 0 && b.topLeft.x-b.bottomRight.x > dxyz.x)) return false; // check for y axis separation if ((dxyz.y >= 0 && a.bottomRight.y-a.topLeft.y < dxyz.y) // negative scale, reverse extent sum, flip equality ||(dxyz.y < 0 && b.topLeft.y-b.bottomRight.y > dxyz.y)) return false; // check for z axis separation if ((dxyz.z >= 0 && a.bottomRight.z-a.topLeft.z < dxyz.z) // negative scale, reverse extent sum, flip equality ||(dxyz.z < 0 && b.topLeft.z-b.bottomRight.z > dxyz.z)) return false; // not separated on any axis, overlapping return true; } public static boolean isContactEdge(int xyzAxis, BoundingBox a, BoundingBox b) { switch(xyzAxis) { case XYZ.XCOORD: if(a.topLeft.x == b.bottomRight.x || a.bottomRight.x == b.topLeft.x) return true; return false; case XYZ.YCOORD: if(a.topLeft.y == b.bottomRight.y || a.bottomRight.y == b.topLeft.y) return true; return false; case XYZ.ZCOORD: if(a.topLeft.z == b.bottomRight.z || a.bottomRight.z == b.topLeft.z) return true; return false; } return false; } /** * Sweep test min extent value * @param box * @param xyzCoord * @return */ public static float min(BoundingBox box, int xyzCoord) { switch(xyzCoord) { case XYZ.XCOORD: return box.topLeft.x; case XYZ.YCOORD: return box.topLeft.y; case XYZ.ZCOORD: return box.topLeft.z; default: return 0f; } } /** * Sweep test max extent value * @param box * @param xyzCoord * @return */ public static float max(BoundingBox box, int xyzCoord) { switch(xyzCoord) { case XYZ.XCOORD: return box.bottomRight.x; case XYZ.YCOORD: return box.bottomRight.y; case XYZ.ZCOORD: return box.bottomRight.z; default: return 0f; } } /** * Test if bounding box A will overlap bounding box B at any point * when box A moves from position 0 to position 1 and box B moves from position 0 to position 1 * Note, sweep test assumes bounding boxes A and B's dimensions do not change * * @param a0 box a starting position * @param a1 box a ending position * @param b0 box b starting position * @param b1 box b ending position * @param aCollisionOut xyz of box a's position when/if a collision occurs * @param bCollisionOut xyz of box b's position when/if a collision occurs * @return */ public static boolean sweepTest(BoundingBox a0, BoundingBox a1, BoundingBox b0, BoundingBox b1, XYZ aCollisionOut, XYZ bCollisionOut) { // solve in reference to A XYZ va = new XYZ(a1.topLeft.x-a0.topLeft.x, a1.topLeft.y-a0.topLeft.y, a1.topLeft.z-a0.topLeft.z); XYZ vb = new XYZ(b1.topLeft.x-b0.topLeft.x, b1.topLeft.y-b0.topLeft.y, b1.topLeft.z-b0.topLeft.z); XYZ v = new XYZ(vb.x-va.x, vb.y-va.y, vb.z-va.z); // check for initial overlap if(BoundingBox.isOverlapping(a0, b0)) { // java pass by ref/value gotcha, have to modify value can't reassign it aCollisionOut.x = a0.topLeft.x; aCollisionOut.y = a0.topLeft.y; aCollisionOut.z = a0.topLeft.z; bCollisionOut.x = b0.topLeft.x; bCollisionOut.y = b0.topLeft.y; bCollisionOut.z = b0.topLeft.z; return true; } // overlap min/maxs XYZ u0 = new XYZ(); XYZ u1 = new XYZ(1,1,1); float t0, t1; // iterate axis and find overlaps times (x=0, y=1, z=2) for(int i = 0; i < 3; i++) { float aMax = max(a0, i); float aMin = min(a0, i); float bMax = max(b0, i); float bMin = min(b0, i); float vi = XYZ.getCoord(v, i); if(aMax < bMax && vi < 0) XYZ.setCoord(u0, i, (aMax-bMin)/vi); else if(bMax < aMin && vi > 0) XYZ.setCoord(u0, i, (aMin-bMax)/vi); if(bMax > aMin && vi < 0) XYZ.setCoord(u1, i, (aMin-bMax)/vi); else if(aMax > bMin && vi > 0) XYZ.setCoord(u1, i, (aMax-bMin)/vi); } // get times of collision t0 = Math.max(u0.x, Math.max(u0.y, u0.z)); t1 = Math.min(u1.x, Math.min(u1.y, u1.z)); // collision only occurs if t0 < t1 if(t0 <= t1 && t0 != 0) // not t0 because we already tested it! { // t0 is the normalized time of the collision // then the position of the bounding boxes would // be their original position + velocity*time aCollisionOut.x = a0.topLeft.x + va.x*t0; aCollisionOut.y = a0.topLeft.y + va.y*t0; aCollisionOut.z = a0.topLeft.z + va.z*t0; bCollisionOut.x = b0.topLeft.x + vb.x*t0; bCollisionOut.y = b0.topLeft.y + vb.y*t0; bCollisionOut.z = b0.topLeft.z + vb.z*t0; return true; } else return false; } }

    Read the article

  • PHP: Strange Date Problem

    - by Me-and-Coding
    Hi, I have two users in my database whose birth date is set to: 1985-01-26 And then i have function which when provided the users' date, tells how many days are left in the birthday. Here is the function: function retage($iy,$im,$id) { if(!empty($iy)>0 && intval($im)>0 && intval($id)>0) { $tdo=$iy.'-'.$im.'-'.$id; $tdc=date('Y').'-'.$im.'-'.$id; /*echo "<br/>";*/ $cd=date('Y-n-j'); /*echo "<br/>";*/ if(strtotime($tdc)>strtotime($cd))//coming { $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365)); $td=floor((strtotime($tdc)-strtotime($cd))/(24*3600)); if($td==1) { $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' day to go'; } else { $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' days to go'; } $ty='<font color="#C7C5C5">is turning '.$ty.' on <br>'.date('M jS Y',strtotime($tdc)).'</font>'; //return 'is turning '.$ty.' on '.$tdc; } elseif(strtotime($tdc)<strtotime($cd))//past { $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365)); if($ty>0) { //$td='gone '.floor((strtotime($cd)-strtotime($tdc))/(24*3600)).' days ago'; $ndays=floor((strtotime($cd)-strtotime($tdc))/(24*3600)); if($ndays==1) $td=' gone '.round((strtotime($cd)-strtotime($tdc))/(24*3600)).' day ago'; else $td=' gone '.round((strtotime($cd)-strtotime($tdc))/(24*3600)).' days ago'; $ty='<font color="#C7C5C5">had turned '.$ty.' on <br>'.date('M jS Y',strtotime($tdc)).'</font>'; //return 'had turned '.$ty.' on '.$tdc; } else { $tdc=(date('Y')+1).'-'.$im.'-'.$id; $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365)); //$td=floor((strtotime($tdc)-strtotime($cd))/(24*3600)).' days to go'; $td=floor((strtotime($tdc)-strtotime($cd))/(24*3600)); if($td==1) { $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' day to go'; } else { $td=round((strtotime($tdc)-strtotime($cd))/(24*3600)).' days to go'; } $ty='<font color="#C7C5C5">is turning '.$ty.' on <br>'.date('M jS Y',strtotime($tdc)).'</font>'; //return 'is turning '.$ty.' on '.$tdc; } } else//today { $ty=floor((strtotime($tdc)-strtotime($tdo))/(3600*24*365)); if($ty>0) { $td='today'; $ty='<font color="#C7C5C5">has turned <br>'.$ty.' on today </font>'; //return 'has turned '.$ty.' on today'; } else { $ty='<font color="#C7C5C5">today</font>';$td=''; //return ''; } } } else { $ty='';$td=''; //return ''; } $ta[0]=$ty; $ta[1]=$td ; return $ta; } I use below code to show the days remaining: while($rs=mysql_fetch_array($result)) { if (isset($rs['byear'],$rs['bmonth'],$rs['bdate'])) { $tmptxt = retage($rs['byear'],$rs['bmonth'],$rs['bdate']); echo $tmptxt[1]; } } The strange thing is that for one user, the days remaining is shown correctly eg: gone 120 days ago And for other user having same birth date, this is shown: Jan 1st 1970 -14755 days to go Strange: When I use the same function outside of the loop and test with date 1985-01-26, the correct result is shown. Note: You can check out the function for yourself. Could you please tell what could be wrong there, your help will be highly appreciated. Thanks.

    Read the article

  • Home networking problem between power line communication and Ethernet

    - by pixeline
    My network runs through the electrical wiring of the house and is organised as such: Groundfloor: an ADSL+network switch, using DHCP (address : 172.19.3.1) (Mac) PCs connected via an electrical adapter (model: D-Link DHP-200) (1 per PC) First Floor: 1 switch (8 ports) connected via an electrical adapter (model: D-Link DHP-200) (address unknown) 2 Mac PCs connected (via RJ45 network wires) to that router using DHCP The Problem On the first floor, file tranfers between PCs are fast and perfect. But if I try to transfer files from or to a computer on the ground floor, the speed is slow and eventually the transfer dies out. The Question So I suspect the 1st floor switch is creating some kind of barrier (firewall?) preventing external PCs from accessing the PCs it is connected to? Am I right and if so, how could I disable that barrier?

    Read the article

  • Networking - intermittent, slow speeds

    - by jack
    Hi all I'm a novice when it comes to networking. I live in a large two storey building that used to be a school and we have an internet connection with BT (british telecoms provider), the connection speed is 12Mb.. Basically our connection is slow and very intermittent and I was wondering if anybody here could provide some help or ideas. There are about 11 people in the building who could be online at any time. We have a router on the ground floor which is bog standard supplied by BT. To provide Broadband access to the 1st and 2nd floors, we used an old switch that the school left, we have a cable running from the router on the first floor to the switch which connects to a wireless router which is configured as a bridge on the 2nd floor supplying broadband access to the 1st and 2nd floors. Additionally we have 3 computers that are connected via the switch through the ethernet sockets left by the school on the ground floor. The router we use on the 2nd floor came in a pack of 2 and cost about £15 (bought by another person). Sometimes the connection is perfectly fine, i.e. early hours of the morning or when everybody is out, we have rang BT who say that the connection cannot cope with the numbers of people online, plus I'm not sure whether each person is streaming etc. Can anybody offer any advice?

    Read the article

  • Java Slick2d - Mouse picking how to take into account camera

    - by Corey
    When I move it it obviously changes the viewport so my mouse picking is off. My camera is just a float x and y and I use g.translate(-cam.cameraX+400, -cam.cameraY+300); to translate the graphics. I have the numbers hard coded just for testing purposes. How would I take into account the camera so my mouse picking works correctly. double mousetileX = Math.floor((double)mouseX/tiles.tileWidth); double mousetileY = Math.floor((double)mouseY/tiles.tileHeight); double playertileX = Math.floor(playerX/tiles.tileWidth); double playertileY = Math.floor(playerY/tiles.tileHeight); double lengthX = Math.abs((float)playertileX - mousetileX); double lengthY = Math.abs((float)playertileY - mousetileY); double distance = Math.sqrt((lengthX*lengthX)+(lengthY*lengthY)); if(input.isMousePressed(Input.MOUSE_LEFT_BUTTON) && distance < 4) { if(tiles.map[(int)mousetileX][(int)mousetileY] == 1) { tiles.map[(int)mousetileX][(int)mousetileY] = 0; } } That is my mouse picking code

    Read the article

  • Extracting useful information from free text

    - by insta
    We filter and analyse seats for events. Apparently writing a domain query language for the floor people isn't an option. I'm using C# 4.0 & .NET 4.0, and have relatively free reign to use whatever open-source tools are available. </background-info> If a request comes in for "FLOOR B", the sales people want it to show up if they've entered "FLOOR A-FLOOR F" in a filter. The only problem I have is that there's absolutely no structure to the parsed parameters. I get the string already concatenated (it actually uses a tilde instead of dash). Examples I've seen so far with matches after each: 101WC-199WC (needs to match 150WC) AAA-ZZZ (needs to match AAA, BBB, ABC but not BB) LOGE15-LOGE20 (needs to match LOGE15 but not LOGE150) At first I wanted to try just stripping off the numeric part of the lower and upper, and then incrementing through that. The problem I have is that only some entries have numbers, sometimes the numbers AND letters increment, sometimes its all letters that increment. Since I can't impose any kind of grammar to use (I really wanted [..] expansion syntax), I'm stuck using these entries. Are there any suggestions for how to approach this parsing problem?

    Read the article

  • Vacation scheduler/viewer

    - by Norfeldt
    I'm looking for a solution that allows multiple persons to put plan and notify their vacation by putting it in their electronic calendar and invite a dedicated "robot" email. On the other side I should be able to get a quick overview of the vacation for each person and do a print out that allows me to put it on a board. Example: John puts his winter vacation for week 7 into his calendar and invite [email protected]. Ben does the same thing for week 4 and 5 and invites [email protected]. Dilbert host the [email protected] and prints out and overview for the next 3 months. Each person's vacation is either stated by name or/and color on the print out. I would like to do the thing with standard business software like Outlook 2010 without installing too many softwares. But at the same time it should be easy and quick to make the print outs without too much fiddling Am I dreaming ?

    Read the article

  • Detect collision from a particular side

    - by Fabián
    I'm making a platform sidescrolling game. All I want to do is to detect if my character is on the floor: function OnCollisionStay (col : Collision){ if(col.gameObject.tag == "Floor"){ onFloor = true; } else {onFloor = false;} } function OnCollisionExit (col : Collision){ onFloor = false; } But I know this isn't the accurate way. If I hit a cube with a "floor" tag, in the air (no matter if with the character's feet or head) I would be able to jump. Is there a way to use the same box collision to detect if I'm touching something from a specific side?

    Read the article

  • Is JQuery or Javascript are capable for image processing?

    - by adietan63
    My plan is to develop a web based application in the future. I think, i can named it "Booth Reservation System" for the Events companies here in our country. One of the main functionality of the system and the most tricky part/ difficult part is the user can upload a "floor plan"(the design of the area were the booth is located in any image format) then the user can select on the specific location on the floor plan to reserve the booth. Also, the user can create floor plan on the system as another functionality of the system. What do you think? What programming language that i can use to accomplished the system? thanks!

    Read the article

  • Sunrise / set calculations

    - by dassouki
    I'm trying to calculate the sunset / rise times using python based on the link provided below. My results done through excel and python do not match the real values. Any ideas on what I could be doing wrong? My Excel sheet can be found under .. http://transpotools.com/sun_time.xls # Created on 2010-03-28 # @author: dassouki # @source: [http://williams.best.vwh.net/sunrise_sunset_algorithm.htm][2] # @summary: this is based on the Nautical Almanac Office, United States Naval # Observatory. import math, sys class TimeOfDay(object): def calculate_time(self, in_day, in_month, in_year, lat, long, is_rise, utc_time_zone): # is_rise is a bool when it's true it indicates rise, # and if it's false it indicates setting time #set Zenith zenith = 96 # offical = 90 degrees 50' # civil = 96 degrees # nautical = 102 degrees # astronomical = 108 degrees #1- calculate the day of year n1 = math.floor( 275 * in_month / 9 ) n2 = math.floor( ( in_month + 9 ) / 12 ) n3 = ( 1 + math.floor( in_year - 4 * math.floor( in_year / 4 ) + 2 ) / 3 ) new_day = n1 - ( n2 * n3 ) + in_day - 30 print "new_day ", new_day #2- calculate rising / setting time if is_rise: rise_or_set_time = new_day + ( ( 6 - ( long / 15 ) ) / 24 ) else: rise_or_set_time = new_day + ( ( 18 - ( long/ 15 ) ) / 24 ) print "rise / set", rise_or_set_time #3- calculate sun mean anamoly sun_mean_anomaly = ( 0.9856 * rise_or_set_time ) - 3.289 print "sun mean anomaly", sun_mean_anomaly #4 calculate true longitude true_long = ( sun_mean_anomaly + ( 1.916 * math.sin( math.radians( sun_mean_anomaly ) ) ) + ( 0.020 * math.sin( 2 * math.radians( sun_mean_anomaly ) ) ) + 282.634 ) print "true long ", true_long # make sure true_long is within 0, 360 if true_long < 0: true_long = true_long + 360 elif true_long > 360: true_long = true_long - 360 else: true_long print "true long (360 if) ", true_long #5 calculate s_r_a (sun_right_ascenstion) s_r_a = math.degrees( math.atan( 0.91764 * math.tan( math.radians( true_long ) ) ) ) print "s_r_a is ", s_r_a #make sure it's between 0 and 360 if s_r_a < 0: s_r_a = s_r_a + 360 elif true_long > 360: s_r_a = s_r_a - 360 else: s_r_a print "s_r_a (modified) is ", s_r_a # s_r_a has to be in the same Quadrant as true_long true_long_quad = ( math.floor( true_long / 90 ) ) * 90 s_r_a_quad = ( math.floor( s_r_a / 90 ) ) * 90 s_r_a = s_r_a + ( true_long_quad - s_r_a_quad ) print "s_r_a (quadrant) is ", s_r_a # convert s_r_a to hours s_r_a = s_r_a / 15 print "s_r_a (to hours) is ", s_r_a #6- calculate sun diclanation in terms of cos and sin sin_declanation = 0.39782 * math.sin( math.radians ( true_long ) ) cos_declanation = math.cos( math.asin( sin_declanation ) ) print " sin/cos declanations ", sin_declanation, ", ", cos_declanation # sun local hour cos_hour = ( math.cos( math.radians( zenith ) ) - ( sin_declanation * math.sin( math.radians ( lat ) ) ) / ( cos_declanation * math.cos( math.radians ( lat ) ) ) ) print "cos_hour ", cos_hour # extreme north / south if cos_hour > 1: print "Sun Never Rises at this location on this date, exiting" # sys.exit() elif cos_hour < -1: print "Sun Never Sets at this location on this date, exiting" # sys.exit() print "cos_hour (2)", cos_hour #7- sun/set local time calculations if is_rise: sun_local_hour = ( 360 - math.degrees(math.acos( cos_hour ) ) ) / 15 else: sun_local_hour = math.degrees( math.acos( cos_hour ) ) / 15 print "sun local hour ", sun_local_hour sun_event_time = sun_local_hour + s_r_a - ( 0.06571 * rise_or_set_time ) - 6.622 print "sun event time ", sun_event_time #final result time_in_utc = sun_event_time - ( long / 15 ) + utc_time_zone return time_in_utc #test through main def main(): print "Time of day App " # test: fredericton, NB # answer: 7:34 am long = 66.6 lat = -45.9 utc_time = -4 d = 3 m = 3 y = 2010 is_rise = True tod = TimeOfDay() print "TOD is ", tod.calculate_time(d, m, y, lat, long, is_rise, utc_time) if __name__ == "__main__": main()

    Read the article

  • For commands to check duped/multiple mc's.

    - by Desmond
    Currently I'm working on a platform type game. I have a for loop in place to check weather or not the players feet are touching the ground. I had this; for (i=0; i<5; i++) { //There are 5 floors if (this.feet.hitTest(_root["g"+i])) { _root.mc.groundTouch = true; //triggers the mc falling } } This works fine only if one of the floors exist(IE if floor1 is on the stage, but floor2-5 aren't); So to try and counter it I tried using; for (i=0; i<5; i++) { if (this.feet.hitTest(_root["floor"+i])) { _root.mc.groundTouch = true; //triggers the mc falling } if (!this.feet.hitTest(_root["floor"+i])) { _root.mc.groundTouch = false; } } This obviously doesn't work because in order for it to function properly, _root.mc.feet would have to be touching all 5 instances of "floor". So my question is; How do I get the code to make _root.mc.groundTouch = true if _root.mc.feet is touching any of the floor instances, but make _root.mc.groundTouch = false only if its touching none of the floor instances? I know that if I really wanted to I could do something like if (_root.mc.feet.hitTest(_root.floor1) && !_root.mc.feet.hitTest(_root.floor2) && etc) But to save myself time, and to give myself the ability to add floors without altering more then i<5 to the amount of floors I have, I would prefer a easier method hopefully something to do with for loops. Thank you ahead of time and your help is very much appreciated

    Read the article

  • How to TDD Asynchronous Events?

    - by Padu Merloti
    The fundamental question is how do I create a unit test that needs to call a method, wait for an event to happen on the tested class and then call another method (the one that we actually want to test)? Here's the scenario if you have time to read further: I'm developing an application that has to control a piece of hardware. In order to avoid dependency from hardware availability, when I create my object I specify that we are running in test mode. When that happens, the class that is being tested creates the appropriate driver hierarchy (in this case a thin mock layer of hardware drivers). Imagine that the class in question is an Elevator and I want to test the method that gives me the floor number that the elevator is. Here is how my fictitious test looks like right now: [TestMethod] public void TestGetCurrentFloor() { var elevator = new Elevator(Elevator.Environment.Offline); elevator.ElevatorArrivedOnFloor += TestElevatorArrived; elevator.GoToFloor(5); //Here's where I'm getting lost... I could block //until TestElevatorArrived gives me a signal, but //I'm not sure it's the best way int floor = elevator.GetCurrentFloor(); Assert.AreEqual(floor, 5); } Edit: Thanks for all the answers. This is how I ended up implementing it: [TestMethod] public void TestGetCurrentFloor() { var elevator = new Elevator(Elevator.Environment.Offline); elevator.ElevatorArrivedOnFloor += (s, e) => { Monitor.Pulse(this); }; lock (this) { elevator.GoToFloor(5); if (!Monitor.Wait(this, Timeout)) Assert.Fail("Elevator did not reach destination in time"); int floor = elevator.GetCurrentFloor(); Assert.AreEqual(floor, 5); } }

    Read the article

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