Editing Computational geometry
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 227: | Line 227: | ||
\begin{array}{rl} | \begin{array}{rl} | ||
1. & det \gets A_1 B_2 - A_2 B_1 \\ | 1. & det \gets A_1 B_2 - A_2 B_1 \\ | ||
− | 2. & \mathrm{if}\ det = 0 \\ | + | 2. & \mathrm{if}\ det = 0 : \\ |
3. & \ \ \ \ \ \mathrm{fail} \\ | 3. & \ \ \ \ \ \mathrm{fail} \\ | ||
− | 4. & \mathrm{else} \\ | + | 4. & \mathrm{else} : \\ |
5. & \ \ \ \ \ x \gets (B_1 C_2 - B_2 C_1)/det \\ | 5. & \ \ \ \ \ x \gets (B_1 C_2 - B_2 C_1)/det \\ | ||
6. & \ \ \ \ \ y \gets (A_2 C_1 - A_1 C_2)/det | 6. & \ \ \ \ \ y \gets (A_2 C_1 - A_1 C_2)/det | ||
Line 429: | Line 429: | ||
1. & d_1 \gets C_1/\sqrt{A_1^2+B_1^2} \\ | 1. & d_1 \gets C_1/\sqrt{A_1^2+B_1^2} \\ | ||
2. & d_2 \gets C_2/\sqrt{A_2^2+B_2^2} \\ | 2. & d_2 \gets C_2/\sqrt{A_2^2+B_2^2} \\ | ||
− | 3. & \mathrm{if} A_1 \neq 0 \\ | + | 3. & \mathrm{if} A_1 \neq 0 : \\ |
− | 4. & \ \ \ \ \ \mathrm{if} A_1 \mathrm{\,and\,} A_2 \mathrm{\,have\ the\ same\ sign} \\ | + | 4. & \ \ \ \ \ \mathrm{if} A_1 \mathrm{\,and\,} A_2 \mathrm{\,have\ the\ same\ sign:} \\ |
5. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 - d_2| \\ | 5. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 - d_2| \\ | ||
− | 6. & \ \ \ \ \ \mathrm{else} \\ | + | 6. & \ \ \ \ \ \mathrm{else:} \\ |
7. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 + d_2| \\ | 7. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 + d_2| \\ | ||
8. & \mathrm{else:} \\ | 8. & \mathrm{else:} \\ | ||
− | 9. & \ \ \ \ \ \mathrm{if} B_1 \mathrm{\,and\,} B_2 \mathrm{\,have\ the\ same\ sign} \\ | + | 9. & \ \ \ \ \ \mathrm{if} B_1 \mathrm{\,and\,} B_2 \mathrm{\,have\ the\ same\ sign:} \\ |
10. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 - d_2| \\ | 10. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 - d_2| \\ | ||
− | 11. & \ \ \ \ \ \mathrm{else} \\ | + | 11. & \ \ \ \ \ \mathrm{else:} \\ |
12. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 + d_2| | 12. & \ \ \ \ \ \ \ \ \ \ dist \gets |d_1 + d_2| | ||
\end{array} | \end{array} |