I'm building a simple Android Game. And I'm stuck on detecting the direction of a collision of two balls. I have a moving ball A, and a fixed ball B. Ball A is much smaller than B. I do not care about the mass of two balls. After the collision of two balls, the ball B is disappear, and the ball A changes the direction! I want something like this..  Here is my current code: private void collision(Ball a, Ball b){         if(b.isVisible){             double d = Math.sqrt((a.cx - b.cx)*(a.cx - b.cx) + (a.cy - b.cy)*(a.cy - b.cy));              if(d &lt;= a.radius + b.radius) {                 b.isVisible = false;                 if(a.dx * b.dx &lt; 0 &amp;&amp; a.dy * b.dy &lt; 0){                     a.dx = - a.dx;                     a.dy = - a.dy;                     b.dx = - b.dx;                     b.dy = - b.dy;                 } else if(a.dx * b.dx &lt; 0){                     a.dx =- b.dx;                     a.dx = - b.dx;                 } else if(a.dy * b.dy &lt; 0){                     a.dy = - a.dy;                     b.dy = - b.dy;                 } else{                     a.dx = - a.dx;                     a.dy = - a.dy;                     b.dx = - b.dx;                     b.dy = - b.dy;                 }             }          }      }  But it just reverses the direction of the ball B So, I'm finding the better solution. Anyone help? Thanks a lot!
I played around with it for a while, but I simply can't figure it out.  I made a tank that fires missiles, and when the missiles hit the walls, I want them to bounce off, but I want them to bounce off to the right angle.  Right now I haven't got any obstacles, the missiles just bounce off when they get outside the viewportRectangle I made.  Is the solution I'm looking for quite advanced?  Is there a relativly simple way to do it?
Counting integer partitions of n into exactly k distinct parts size at most M How can I find the number of partitions of $n$ into exactly $k$ distinct parts, where each part is at most $M$?  The number of partitions $p_k(\leq M,n)$ of $n$ into at most $k$ parts, each of size at most $M$, is given by the generating function: $$  \binom{M+k}{k}_{x} = \prod_{j=1}^{k}\frac{1-x^{M+k-j+1}}{1-x^j}= \sum_{n=0}^{kM} p_{k}(\leq M,n) x^n $$  For the number of the partitions $p_k(\mathcal{D},n)$ of $n$ into at most $k$ parts there is the recurrence relationship: $$   p_{k}(\mathcal{D},n) = p_{k}(\mathcal{D},n-k) + p_{k-1}(\mathcal{D},n) $$  But what, if I want to count only the partitions with distinct parts and restricted number of parts and restricted part size?  Update: Now I know the generating function for the number of distinct restricted partitions $p_k(\leq M, \mathcal{D},n)$ of $n$ into exactly $k$ distinct parts, all at most $M$ is $$    \prod_{j=1}^{M} (1+xq^{j}) = \sum_{k,n=0}^{\infty}p_k(\leq M, \mathcal{D},n)x^{k}q^{n} $$ and there is also a recurrence relation $$    p_k(\leq M, \mathcal{D},n) =         p_{k-1}(\leq M-1, \mathcal{D},n-k) +         p_k(\leq M-1, \mathcal{D},n-k) $$ How can I prove this? Could you recommend a book, where I could read about this? How Do I Apply to Become a Marketplace Creator? So I wanted to make some minecoins and I also heard that anyone become a marketplace creator could but I don't know where to apply. I'm in Minecraft Pocket Edition 1.14.30. Can you tell me where I can apply? I want to show that for $S,T\in B(H)$ bounded operators on Hilbertspace with $S\geq 0,T\geq 0$ and $ST=TS$,  we have $S+T\geq 0$, and $ST\geq 0$.  $T\geq 0$ means $(Tx,x)\geq 0$.    To me it seems that $((S+T)x,x) = (Sx,x)+(Tx,x)\geq 0$. But for $ST$ i like some help.   There is a theorem in Rudin (12.32) that says that for every $T\in B(H)$ we have an equivalence:   $T$ is positive $\Leftrightarrow$ $T$ is self adjoint, i.e. $T=T^*$ and $\sigma(T)\subset [0,\infty)$.   Since $S, T$ are self adjoint we know that $ST=TS = S^*T^* = T^*S^*$ ($ST$ is selfadjoint since $S,T$ commute). Also I read somewhere that if $S,T $ commute then $\sigma(ST)\subset \sigma(S)\sigma(T)$, but I am not sure if this is true. Clearly I cant prove it, but if it were true by this ''Theorem'' it would follow that $ST \geq 0$.   Is there a more straightforward way? Bash shell script output alignment My script:  date echo -e "${YELLOW}Network check${NC}\n\n"  while read hostname do  ping -c 1 "$hostname" &gt; /dev/null 2&gt;&amp;1 &amp;&amp;  echo -e "Network $hostname : ${GREEN}Online${NC}" || echo -e "${GRAY}Network $hostname${NC} : ${RED}Offline${NC}"  done &lt; list.txt         sleep 30 clear done   Is outputting info like this:    Network 10.x.xx.xxx : Online    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.xxx : Offline    Network 10.x.xx.x : Online    Network 139.xxx.x.x : Online    Network 208.xx.xxx.xxx : Online    Network 193.xxx.xxx.x : Online   which I'd like to clean up to get something like this:    Network 10.x.xx.xxx       : Online   Network 10.x.xx.xxx       : Offline    Network 10.x.xx.xxx       : Offline     Network 10.x.xx.x         : Online     Network 139.xxx.x.x       : Online   Network 208.xx.xxx.xxx    : Online     Network 193.xxx.xxx.x     : Online   Network 193.xxx.xxx.xxx   : Offline Route SSH to host through interface Is it possible to route all outgoing requests for SSH (port 22) to mydynamicdns.afraid.org via wlan0 instead of eth0 when both are connected?  Since my IP is dynamic, I would like to use a name instead of IP. General way to determine $\mathbb{Q}(\gamma) = \mathbb{Q}(\alpha,\beta)$ given $\alpha$ and $\beta$ How does one add boarding passes to Apple Wallet? PHP replacing special characters like à->a, è->e A story about a male protagonist with special eyes that tells him if things are safe or not; green = safe. Can’t remember if it’s a manga or webtoon. It starts with a male protagonist who was dying on a battlefield, the goddess took pity on him, sent his emotions back into his younger self, (not memories). He had eyes that told him what is safe/good and what is dangerous/bad by using colors: green, orange, red. He used this to gamble, his eyes stopped working, borrowed money from his ex-girlfriend (who works in a cafe). Money got stolen while he took a nap by a river, the evil lady who stole his money tried to get him to enter a contract. From his future emotions, he knew he wanted an invitation instead. This leads to a gathering of people in a school gym, their tasks are given. Invited people are given bags with tools. An oni busted out under the floor. People get killed. Stairways with gates, etc. This is considered the tutorial. Points are given after, those points are needed to buy daily necessities. The protagonist had the highest points, given VIP room. Etc. I recall being somewhat impressed by a novel I read a few years back – this book may be less than five years old – which featured a college-aged man.  He had a laptop which transformed into a troll goblin that served as his familiar.  In the story's universe, mages had switched to the Internet for most of their magic &amp; communication.  The main character was essentially a magical hacker, and spent much of the book fighting against his evil aunt (I think, I know it was a female relative) with the help of his cousin.  Older forms of magic were also featured, including using special paintings as magical portals, and spells being whistled by wizards.  It features a scene at a gas station where the laptop is disabled by a virus, and the main character whistles a spell to reanimate dinosaurs from the gasoline.  Is this ringing any bells? Enabling GPU rendering for Cycles? Cannot get onto Apple Developer Forums Every time I attempt to log on to the apple developer forums it tells me I need to create a new user account (even though I already have one), and when I try to sign up it gives me an error:   Anyone else have this issue and/or know how to fix it? Thanks! how to tell Latex to ignore empty lines Irreducibility of $X^n - 2$ over $\mathbf Z[i]$. I was “playing” with Eisenstein's criterion and the polynomials $X^n-p$ ($p$ being a prime number).  Over $\mathbf Z$, the classical Eisenstein's criterion directly applies and shows that $X^n - p$ is an irreducible element of $\mathbf Z[X]$. The question was “what happens over $\mathbf Z[i]$?”  We know that in this new ring, a prime number $p$ has one of three different fates:   if $p \equiv -1\ (\mathrm{mod}\, 4)$, $p$ still is an irreducible element of $\mathbf Z[i]$, or equivalently $(p) \subset \mathbf Z[i]$ still is prime. (Unless I'm mistaken, number theorists say that $p$ is inert). Eisenstein's criterion still applies and the polynomial is irreducible over $\mathbf Z[i]$. if $p \equiv 1\ (\mathrm{mod}\, 4)$, $p$ can be written as a sum of two squares: $p = n^2 + m^2$ and is therefore reducible on $\mathbf Z[i]$: $p = (n+im)(n-im)$. These two factors aren't associated (the units in $\mathbf Z[i]$ being $\pm 1$ and $\pm i$) so $(p)$ splits: $(p) = (n+im)(n-im)$ is the product of two different prime ideals. One can still use Eisenstein's criterion with either of these prime ideals, and $X^n - p$ is irreducible over $\mathbf Z[i]$. if $p = 2$, the oddest of all primes, one still has a factorisation $p = (1+i)(1-i)$ but this time, $1+i$ and $1-i$ are associated. In NT slang, $(2)$ is ramified: $(2) = (1+i)(1-i) = (1+i)^2$ and one cannot directly use Eisenstein's criterion.   So here's my question: how do we prove (or disprove) the irreducibility of $X^n - 2$ over $\mathbf Z[i]$? A word or short phrase for 'better in every way'? When we're comparing two or more things, there are times when we have to weigh the advantages or disadvantages of each one.  There are other times when one of the things is better for every way in which it's being judged, and the final decision is not based upon trade-offs.  I know that I've heard a phrase for this (I want to say it was two words), but I've had no luck in remembering it.    I don't think 'clearly superior' or 'clear winner' quite fit the bill, as that might still suggest that the disadvantages are significantly outweighed by the advantages.  Is there such a phrase, or even a single word, that would convey this meaning without using idioms? When should end punctuation go inside quotes? I have a large mesh with > 1.5 million faces. I would like to uniformly add a texture to the object without UV mapping (as blender freezes every time). The texture is quite simple and can be applied evenly throughout the object. Does entropy increase or decrease as our Universe is expanding? Scientists say that entropy of our universe is increasing as it is expanding and our universe is cooling down gradually from the time of its birth. If something is getting cooler and cooler, then how can it become more random (entropy increase) with the passage of time? According to laws of thermodynamics, at absolute zero temperature, the entropy is zero. That means as we go down and down to the temperature scale entropy must decrease, but why is it not happening in the case of our universe? Why doesn't the tilde (~) expand inside double quotes? According to  and my own understanding, the tilde expands to the home directory:  $ echo ~ /home/braiam   Now, whenever I want the shell expansion to work, i. e. using variable names such $FOO, and do not break due unexpected characters, such spaces, etc. one should use double quotes ":  $ FOO="some string with spaces" $ BAR="echo $FOO" $ echo $BAR echo some string with spaces   Why doesn't this expansion works with the tilde?  $ echo ~/some/path /home/braiam/some/path $ echo "~/some/path" ~/some/path I am interested in finding out how confident my model (say Logistic Regression) is in predicting the label of a new data point. For example, if it is not confident, I better abstain from making a prediction.   Logistic Regression outputs probabilities, which gives you a notion that there is confidence in prediction. But in fact, it is not. $P(y|x)$ being 0.3, doesn't tell me that the model is confident in its prediction or not. All, we can say is that it believes 100% that class A is 0.3 and other class is 0.7.  Can we use confidence intervals of LR as some sort of confidence in prediction? E.g., larger the difference between upper and lower bound for a particular data point, less confident it is, and vice-versa?  If not, how can we build confidence in our prediction? Can anybody guide me to some paper or field of study?