I'm having an issue with calculating the predicted linear angle a projectile needs to move in to intersect a moving enemy ship for my 2D game.  I've tried following the document , but what I've have come up with is simply awful.  protected Vector2 GetPredictedPosition(float angleToEnemy, ShipCompartment origin, ShipCompartment target) {     // Below obviously won't compile (document wants a Vector, not sure how to get that from a single float?)     Vector2 velocity = target.Thrust - 25f; // Closing velocity (25 is example projectile velocity)     Vector2 distance = target.Position - origin.Position; // Range to close     double time = distance.Length() / velocity.Length(); // Time      // Garbage code, doesn't compile, this method is incorrect     return target.Position + (target.Thrust * time); }   I would be grateful if the community can help point out how this is done correctly.  EDIT  Here is my (working) method following the advice given:  protected Vector2 GetPredictedPosition(ShipCompartment origin, ShipCompartment target, Ship enemyShip, Ship firingShip) {     Vector2 targetVelocity = enemyShip.Direction * enemyShip.Thrust;     Vector2 projectileVelocity = firingShip.Direction * 25f;      Vector2 velocity = targetVelocity - projectileVelocity; // Closing velocity     Vector2 distance = target.Position - origin.Position; // Range to close     double time = distance.Length() / velocity.Length(); // Time      return target.Position + new Vector2(Convert.ToSingle(targetVelocity.X * time), Convert.ToSingle(targetVelocity.Y * time)); }
I saw this question: .  My situation is a little different though.   My target moves, and the shooter moves.  Also, the shooter's velocity is added to the bullets' velocities, i.e. bullets fired while sliding to the right will have a greater velocity toward the right.   What I'm trying to do is to get the enemy to be able to determine where they need to shoot in order to hit the player.  Using the linked SO solution, unless the player and enemy are stationary, the velocity difference will cause a miss.  How can I prevent that?      Here is the solution presented from the stack overflow answer.  It boils down to solving a quadratic equation of the form:  a * sqr(x) + b * x + c == 0   Note that by sqr I mean square, as opposed to square root. Use the following values:  a := sqr(target.velocityX) + sqr(target.velocityY) - sqr(projectile_speed) b := 2 * (target.velocityX * (target.startX - cannon.X)       + target.velocityY * (target.startY - cannon.Y)) c := sqr(target.startX - cannon.X) + sqr(target.startY - cannon.Y)   Now we can look at the discriminant to determine if we have a possible solution.  disc := sqr(b) - 4 * a * c   If the discriminant is less than 0, forget about hitting your target -- your projectile can never get there in time. Otherwise, look at two candidate solutions:  t1 := (-b + sqrt(disc)) / (2 * a) t2 := (-b - sqrt(disc)) / (2 * a)   Note that if disc == 0 then t1 and t2 are equal.
The correct omission of the definite and indefinite articles Numbers to the Power of Zero I have been a witness to many a discussion about numbers to the power of zero, but I have never really been sold on any claims or explanations.  This is a three part question, the parts are as follows...    1) Why does $n^{0}=1$ when $n\neq 0$?  How does that get defined?  2) What is $0^{0}$?  Is it undefined?  If so, why does it not equal 1?  3) What is the equation that defines exponents?  I can easily write a small program to do it (see below), but what about in equation format?    I just want a little discussion about numbers to the power of zero, for some clarification.    Code for Exponents: (pseudo-code/Ruby)  def int find_exp (int x, int n){     int total = 1;     n.times{total*=x}     return total; } Does anyone know how to get your business map location displayed in the right hand sidebar of the Google search results page? As in the screenshot below:      I already added my business to this link: .  Is adding detail in above link enough or do I need to change my website coding? Kepler problem in time: how do two gravitationally attracted particles move? Two particles with initial positions and velocities $r_1,v_1$ and $r_2,v_2$ are interacting by the inverse square law (with G=1), so that  $$ {d^2r_1\over dt^2} = - { m_2(r_1-r_2)\over |r_1-r_2|^3} $$ $$ {d^2r_2\over dt^2} = - { m_1(r_2-r_1)\over |r_1-r_2|^3} $$  (the inverse square law along the line of separation). What is the complete solution of these differential equations? What is the position of the two objects as a function of time?  After reading a lot on Wikipedia, I've come to the definition of center of mass and relative coordinates:   $$R(t) ~=~ \frac{m_1 r_1 + m_2 r_2}{m_1+m_2}$$  $$\ddot{r}(t) r(t)^2 ~=~ (m_1+m_2)G$$  Where $R$ is the center of mass, and $r$ is the displacement between the particles... Is this correct? How do I proceed to solve the differential equation? How to get Url Hash (#) from server side How to change phone number in Google account? I gave Google my phone number to verify it, not knowing that it would change it, and now my phone number is completely different? What have I done, and how do I unverify it and change my phone number back? How do I update the GUI from another thread? Which is the simplest way to update a Label from another Thread?   I have a Form running on thread1, and from that I'm starting another thread (thread2).  While thread2 is processing some files I would like to update a Label on the Form with the current status of thread2's work.   How could I do that? Let $a=p_1^{x_1}p_2^{x_2}\cdots\cdot p_q^{x_q}$ and $b=p_1^{y_1}p_2^{y_2}\cdots p_r^{x_r}$ ,   say — Since gcd(a,b) is the largest common divisor of a and b and is divisible by any other common divisor of the two,   GCD$(a,b)=p_1^{\min(x_1,y_1)}p_2^{\min (x_2,y_2)} \cdots p_q^{\min (x_q,y_q)}$  LCM$(a,b)= p_1^{\max(x_1,y_1)}p_2^{\max(x_2,y_2)}\cdots p_r^{\max (x_r,y_r)}$  I understand GCD(a,b) has to divide both $a,b$. Therefore the exponent of any prime factor $p_i$ in GCD has to be in both $a,b$  — therefore $p_i^{\min(x_i, y_i)}$. But I'm muddled and anxious. Why does $\min$ appear in GREATEST common divisor? Why does $\max$ appear in LOWEST common multiple? SharePoint 2013 Online - Missing Follow Link How many $m\times n$ tables are there if they are subject to the following two conditions?    In each cell of the table we have $1$ or $-1$. The product of all the cells in any given row and the product of all cells in any given column equals $-1$.    I already know if Parity of $m$ and $n$ are different there is no such a table. what is the answer in general? Assume that $f$ be continuous on $\mathbb{R}$, $f'(x)$ exists for all $x\neq 0$, and $\lim_{x\rightarrow 0} f'(x)=1$. We need to show $f'(0)$ exist and is equal to $1$.  $f'(0)=\lim_{x\rightarrow 0}\frac{f(x)-f(0)}{x}$, $\lim_{x\rightarrow 0}f'(x)=1\Rightarrow\lim_{x\rightarrow 0}\lim_{h\rightarrow 0}\frac{f(x+h)-f(x)}{h}=1$...am I going in the right direction? Please help. I'm on SO pretty much every day researching something to do with programming, and over the last month or two, I find I'm growing frustrated and a little disgusted at how many interesting questions have been closed as "not a good fit" or "too subjective".  I think there is a confusion between "subjective" and "calls for judgement". To me one of the most valuable things about SO is the tremendous breadth and depth of experience of the members, and experience translates into smart decisions and advice, and that advice cannot always be asked for, or expressed in terms of, bald facts and data.  It's going to be 'subjective'.  I don't think SO should be Wikipedia. I think that if I could ask a question to a group of skilled programmers sitting around a table at lunch, and get interesting, valuable answers, then I don't care whether the question or the answers are 'subjective', I think that question should equally well be fair game for Stack Overflow.  I would like to see a mechanism whereby people who vote to close a question lose reputation when somebody expresses interest in that question or its responses.  How can I, or can I, influence this aspect of SO? How does order-preserving encryption work? Order-preserving encryption (OPE) is, apparently, a method of encrypting data so that it's possible to make efficient inequality comparisons on the encrypted items without decrypting them.  I've been coming across this term in various places (including ) lately, but I have no idea how such encryption schemes are supposed to work.  Any obvious methods I can think of to allow such comparisons on encrypted data would result in catastrophic security failure.  Certainly, I assume that OPE must involve some kind of security tradeoff compared to traditional encryption, but given that it seems to be actively  and , it seems that it must be possible to implement in a way that retains at least some level of useful security.  I just don't see how.  Given that  didn't turn up any convenient Wikipedia articles or other popular summaries of OPE, I figured I'd try asking for one here before diving into the academic literature.  (At worst, I may try to answer my own question later, if nobody else beats me to it.)  So, to summarize, my question is: How does order-preserving encryption work, and what security properties does it provide? What is the term for replacing a name or brand with a funny pejorative / sardonicism? What is the term for when one replaces a well-known name [(Proper) noun, company, brand, etc.] with one that tries to be funny yet pejoratively descriptive, different but similar enough that one's audience can likely understand the replacement?  For example: Whole Foods ===> Whole Paycheck; Comcast ==> Scumcast; Starbucks ==> Charbucks; Kinko's == Stinko's; eBay ==> Evil Bay  I tend to use sobriquet don't believe this explicitly implies funny as well as insulting. Moniker again is close but not specific to the above description.  There is a similar question which proposes tortonym and malapropsim, but it does not seem to settle the argument definitively:   Another answer here proposes dysphemism, but to me it isn't a full fit:  because it doesn't cover the humor aspect. Where can I see how many posts have I edited? How to ensure that string interpolated into `sed` substitution escapes all metachars I recently traveled from India to USA. I am on H1B. I entered USA on 29th December 2016. As my Visa extension is due in August 2017, I was gathering documents for Visa Extension. It was required to provide a scanned copy of passport page with all entry and exit stamps.  Myself and my wife both travelled back from India. My wife's passport has a entry stamp with date as 29th December 2016. But the same is missing from my passport. I guess the officer missed putting the entry stamp on my passport. My I 94 reflects the correct date of entry as 29th December. Somehow I still have my boarding pass from this trip (usually I throw them once trip is complete).   Want to know what could be implications of missing entry stamp when I travel to India next time (somewhere towards early next year)? Does this impact my H1B Visa extension ? Also what can I do to correct this information on my passport? Was Voldemort allowed to visit Hogsmeade while in school? We know that in order for third-years and up to be allowed to visit the village of Hogsmeade, they must present a form duly signed by their parent or guardian. When Harry’s guardians, the Dursleys, miss their opportunity (!) to sign his, he is not allowed to go to Hogsmeade. Both Cornelius Fudge (as Minister for Magic) and Professor McGonagall (as head of Gryffindor House) refuse to sign the form on his guardians’ behalf—probably at least in part because they think there’s a mad killer on the loose looking for Harry, but also, as McGonagall specifically states, simply because:  “You heard what I said. No form, no visiting the village. That’s the rule. […] The form clearly states that the parent or guardian must give permission.” Prisoner of Azkaban, Bloomsbury/UK paperback, p. 113  Obviously, Tom Riddle did not have any parents or guardians ready to sign his form for him: his mother was dead, his father likely did not even wish to know of his existence, and if he did have a legal guardian at all (I don’t know how orphanages worked in Britain in the 1930s), it was likely to be  (warning: Wikia link) as the matron of Wool’s Orphanage where Riddle grew up. As Mrs. Cole was perfectly Muggle in every way and was never told by Dumbledore—nor, we must assume, by the boy himself—that Riddle was a wizard attending a wizardry school, it seems unlikely in the extreme that she ever signed Riddle’s form to visit Hogsmeade.1 I don’t recall any incidents in the books where Voldemort speaks specifically of him visiting Hogsmeade as a school boy (then again, why would he?); but being content to remain at the castle while his classmates have fun in the village seems quite out of character for him, too. Are there any (canonical) indications whether special provisions were made for orphans with no legal guardians to sign, so that they were allowed to visit Hogsmeade after all? Or, oppositely, whether such cases were played strictly by the book and unguardianed orphans, and thereby Riddle, were not allowed to visit Hogsmeade?    1 One might of course easily envision that Riddle simply Confounded Mrs. Cole to sign the form; but that would lead to detection of underage magic (assuming this was even a thing in 1940). Riddle may of course have forged Mrs. Cole’s signature, but that would be rather likely to be discovered as a forgery, since at least Dumbledore was aware that Mrs. Cole did not know of Riddle’s magical abilities. What species of insect is this? I saw this insect near a beach in Corsica France: How to keep an SSD in shape on Yosemite? As of OS X 10.10, Apple uses kext signing. Ever since it has become  to manually activate TRIM for third-party SSDs on OS X. That means users with non-Apple SSDs will sooner or later see degrading write speeds.   So I am wondering what are my options to avoid this situation. Some approaches I could think of imply additional problems:   Are you aware of any alternative approach, that does not require disabling kext signing?  Are there tools or tricks to manually clean up a SSD (i.e. issue a TRIM command)? If I decided to temporarily use a tool like TRIM Enabler how long would it need to be activated, in order to clean the disk?   To summarize: No TRIM on Yosemite. What can I do?