I have a mask shader which reveals the texture depending on an angle. It uses this logic:  float line_val(vec2 coord) {     float radians = (direction-90.0)/180.0 * M_PI;     return coord.x * cos(radians) + coord.y * sin(radians); }  vec2 corners[4];  void main(void) {     corners[0] = vec2(0.0, 0.0);     corners[1] = vec2(1.0, 0.0);     corners[2] = vec2(1.0, 1.0);     corners[3] = vec2(0.0, 1.0);      float minD = 0.0;     float maxD = 0.0; // for corner #0     for (int i=1; i&lt;4; i++) {         float val = line_val(corners[i]);         minD = min(minD, val);         maxD = max(maxD, val);     }      float middle = (maxD - minD) * mask_level + minD;      float dist = line_val(coord);     if( dist &lt; middle ){       // show texture     }else{       // show nothing     } }   Now I wonder, what if instead of showing nothing I would like to show the color on the mask edge (the closest to the current coordinate). How do I get the closest point to the current coordinates giving that my line doesn't have a start and end but it's drawn based on an angle (direction)?
Consider the infinite line, $L$ in $2D$ consisting of all points $p$ such that $p.[0.3511 0.9263]= 6$. Find the point on the line closest to $(10, 20)$. Find the point on the line closest to $(4, 3)$. Find the distance from the line to both of these points.  Hi, I was reading the book $3D$ Maths Primer for Graphics and Game Development. The book mention about $2$ formulas but I don't know how to apply them.   $\text{Signed distance} = d-q.n$  $q' = q + (d-q.n)n$  for any point $q$, the point $q'$ that is the closest point on $L$ to $q$.  This is what I have tried,   Since the lines are parallel then the normal are the same so   $q' = q + (6 - q(0.3511 0.9263))(0.3511 0.9263)$   I'm stuck here.
Focus in night photography I've recently read the Yahoo manifesto . They recommend to put the JavaScript inclusion at the bottom of the HTML code when we can.  But where exactly and when?  Should we put it before closing &lt;/html&gt; or after ? And above all, when should we still put it in the &lt;head&gt; section? Proving that if $|f''(x)| \le A$ then $|f'(x)| \le A/2$ Suppose that $f(x)$ is differentiable on $[0,1]$ and $f(0) = f(1) = 0$. It is also   known that $|f''(x)| \le A$ for every $x \in (0,1)$. Prove that   $|f'(x)| \le A/2$ for every $x \in [0,1]$.   I'll explain what I did so far. First using Rolle's theorem, there is some point $c \in [0,1]$ so $f'(c) = 0$.  EDIT: My first preliminary solution was wrong so I tried something else. EDIT2: Another revision :\  I define a Taylor series of a second order around the point $1$: $$ f(x) = f(1) + f'(1)(x-1) + \frac12 f''(d_1)(x-1)^2 $$ $$ f(0) = f(1) + f'(1)(-1) + \frac12 f''(d_1)(-1)^2 $$ $$ |f'(1)| = \frac12 |f''(d_1)| &lt;= \frac12 A $$  Now I develop a Taylor series of a first order for $f'(x)$ around $1$: $$ f'(x) = f'(1) + f''(d_2)(x-1) $$ $$ |f'(x)| = |f'(1)| + x*|f''(d_2)|-|f''(d_2)| \leq \frac{A}{2} + A - A = \frac{A}{2} $$  It looks correct to me, what do you guys think?  Note: I cannot use integrals, because we have not covered them yet. How many solutions $X^{10} - I=0$ has in $M_2(\mathbb{R})$? How many solutions $X^{10} - I=0$ has in $M_2(\mathbb{R})$? Where $M_2(\mathbb{R})$ denotes the set of $2 \times 2$ real matrices.  I absolutely have no idea of where I should start from. $I$ and $-I$ solve the equation, but are there any other non-trivial solutions? Are there infinitely many solutions? Compute $\lim_{x\to\infty}x\;\left[\left(1+\frac{1}{x}\right)^x-e\right]$ How can I compute the following limit, and is there a general method to resolve problems of this type?  $$\lim_{x\to\infty}x\left[\left(1+\frac{1}{x}\right)^x-e\right]$$ Introduction to statistics for mathematicians What is a good introduction to statistics for a mathematician who is already well-versed in probability?  I have two distinct motivations for asking, which may well lead to different suggestions:   I'd like to better understand the statistics motivation behind many problems considered by probabilists. I'd like to know how to better interpret the results of Monte Carlo simulations which I sometimes do to form mathematical conjectures.   I'm open to the possibility that the best way to go is not to look for something like "Statistics for Probabilists" and just go to a more introductory source. Feature request - links underlined Mail App keeps popping up in the background in Mac OS Mojave Problem  Let $n \geq 3$ be an odd number and let $G=\{1,...,2n\}$ be a group of order $2n$. Let $\phi:G \to S_{2n}$ be the morphism defined by $\phi(g_i)(g_j)=g_ig_j$ and let $H=\phi^{-1}(A_{2n})$. Show that $H$ is a proper normal subgroup of $G$.  So basically the result of this problem is that every group of order $2n$, with $n$ odd, is not simple.   The morphism $\phi$ can be seen as the action of $G$ on itself by left multiplication. Since $A_{2n} \lhd S_{2n}$, then $H=\phi^{-1}(A_{2n}) \lhd G$. I am stuck at showing that $H \neq \{1\},G$. All I could think of is that $G$ has an element $g$ of order $2$, then $\phi(g)$ is of order $1$ or $2$, but it is easy to see that $\phi(g)=1$ if and only if $g=1$, so $ord(\phi(g))=2$. I don't know which are the elements of order two in $S_{2n}$. I would appreciate some help to solve the problem, thanks in advance. How to create a file system as a non root user? I'd like to create a filesystem image as a non-root user, the problem I'm facing is that the way I'm currently doing it, it needs a mount and as a non-root can't do a mount.  This is what I'm now doing:  #!/bin/sh  IMG="app.ext4" LBL="PIHU_APP" MNT="/mnt/PIHU_APP" APP="/home/buildroot/board/arctura/PIHU_APP/application"  #64MB: dd if=/dev/zero of=$IMG bs=4096 count=16384  mkfs.ext4 $IMG e2label $IMG $LBL  mkdir -p $MNT mount -o loop $IMG $MNT cp -r $APP $MNT sync umount $MNT   I have full root access, so I can setup/prepare anything, but the script will be executed from a non-root account.  However, I have a feeling there may be a better way that might not even need mounting, but I'm not sure.. Can I smoothly upgrade from one LTS to next LTS release? Why did Obi-Wan allow Leia to get adopted by such a high profile figure? I know that Leia is a princess because she was adopted by the Queen of Alderaan, but why would Obi-Wan allow this? Wasn't the original plan of Obi-Wan and Yoda to hide the Skywalkers from Palpatine? Luke was placed into a very low-profile position, being the child of two farmers on a backwater planet. However, Leia occupies a very important political position.  Is there any reason why Obi-Wan would do this if he was trying to hide her? Splitting a semicolon-separated string to a dictionary, in Python Let $m$ be a natural number. Define $f(m) = m + \lfloor\sqrt{m}\rfloor$. Prove that at least one of the number among $m, f(m), f^2(m), \ldots$ is a perfect square. Here $f^k(m)$ denotes the composition of $f$ over itself $k$ times.  I tried the question, but the greatest integer along with square root is creating trouble. Which computer science / programming Stack Exchange sites do I post on? Call native javascript function that has been "erased" by the web page Does the MacBook battery cycle count reset when replacing a battery I've been  on battery cycle counts and checked out my current count on my MacBook (13-inch, Aluminum, Late 2008) - recommended maximum cycle count is 500.  I've had this laptop now for over 4 years and at the 2 year mark I had the battery replaced by AppleCare. The first time I checked out the cycle count was today and it's currently on 1004. Now my question is, is this the cycle count of the battery since I replaced it (as in, it reads the cycle count from the battery), or is it the combined cycle count (as in, it stores the count somewhere and increments occasionally)? My assumption is that it's the count of that battery but I have no idea how to verify this.  Either way, it looks like I need a new battery ;) Freeman and Tukey interval If $Y$ is Poisson$(\lambda)$ distributed, how do we obtain this confidence interval for $\lambda$:  $$ \left (\frac{(\sqrt Y+\sqrt{Y + 1}-z_{(α⁄2)} )^2 - 1}{4},\  \frac{(\sqrt Y+\sqrt{Y  +1}+z_{(α⁄2)} )^2 - 1}{4} \right ) $$ I'm pretty sure the answer to this should be obvious - even to me ...  It's been a while I've been reading and attempting to construct simple electronic circuits. The supply almost always is either through a battery/cell, or AC duly rectified to DC.   I have the impression electronic circuits rarely ever work off an AC supply.    Is this impression correct? If yes, why is an electronic circuit rarely (if ever) powered/biased using straight AC? I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a "download" file. And when I try documentroot/index.php it just downloads the PHP file.  I have PHP installed but Apache doesn't seem to want to execute it. People suggested adding a 'Load Module' line to my httpd.conf but I don't have that file.