A Map From $S^n\to D^n/\sim$ is Continuous. The following question is motivated by Thomas's answer here which can be used to prove that $\mathbf RP^n$ is same as the space obtained by identifying the antipodal points on the boundary circle of the closed $n$-disc.
Notation: Let $H^n_+$ denotes the open upper half-sphere of $S^n$, $\bar H^n_+$ denote the closed upper half-sphere, and $H^n_-$ denote the open lower half-sphere of $S^n$.
The equator is the intersection of $S^n$ with the set $\mathbf R^{n-1}\times\{ 0\}$.

Let $\bar H^n_+/\sim$ be the space formed by identifying the antipodal points on the equator. Let $f:S^n\to \bar H^n_+/\sim$ be the map defined as
  $$
f(x)=
\left\{
\begin{array}{ll}
x & \text{if} \ x\in H^n_+\\
\{x, -x\} & \text{if } x \text{ is on the equator circle}\\
-x & \text{if }\ x\in H^n_-
\end{array}
\right.
$$
  Then $f$ is a continuous map.

I am having a hard time showing this.
I can see that if $U$ is open in $\bar H^n_+/\sim$, and $\pi:\bar H^n_+\to \bar H^n_+/\sim$ denotes the natural projection map, then $f^{-1}(U)$ is same as $\pi^{-1}(U)\cup a(\pi^{-1}(U))$, where $a:S^n\to S^n$ is the antipodal map.
Since $\pi$ is a quotient map, we have $\pi^{-1}(U)$ is open in $\bar H^n_+$. The antipodal map $a$ is a homemorphism. Thus $a(\pi^{-1}(U))$ is open in $\bar H^n_-$.
But it is not clear that $\pi^{-1}(U)\cup a(\pi^{-1}(U))$ is open in $S^n$.
I can see is pictorially in the case when $n=2$. But do not have a proper argument.
Is there a neat way to do this?
 A: There is a basic constructive theorem for continuous maps known as the "gluing theorem", which goes like this: given a map $f:X \to Y$ of topological spaces, and given closed subsets $A,B \subset X$, suppose that the following hold:


*

*$A \cup B = X$,

*$f \bigm| A$ and $f \bigm| B$ are continuous in the subspace topologies on $A$ and $B$.


Then $f$ is continuous. 
This applies to your problem using $X=S^n$, $A=\bar H^n_+$, $B=\bar H^n_-$, $Y = \bar H^n_+ / \sim$. The map $f \bigm| B$ is continuous because it is a composition of two continuous maps: the antipodal map $x \mapsto -x$ from $B$ to $A$, followed by the map $f \bigm| A$.
The proof of the gluing theorem can be found in basic topology texts such as Munkres, but I'll write out the proof here anyway, in order to emphasize what you missed: to prove that a subset is open, one method is to write it as a union of open subsets, one containing each point.
To prove the gluing theorem, let $U \subset Y$ be open, and I'll show how to express
$$f^{-1}(U) = \cup_{x \in f^{-1}(U)} V_x
$$
so that $x \in V_x \subset f^{-1}(U)$ and so that $V_x \subset X$ is open. The subset $V_x$ is defined in three cases.
Case 1: $x \in A \setminus B$. Let $V_x = (f \bigm| (A \setminus B))^{-1}(U)$, and clearly $x \in V_x \subset f^{-1}(U)$. This function $f \bigm| (A \setminus B)$ is continuous, since it is the restriction of the continuous function $f \bigm| A$. So the set $V_x$ is open in $A \setminus B$. Also, since $B$ is closed in $X$, the set $A \setminus B = A \cap (X-B)$ is open in $X$. Therefore $V_x$ is open in $X$.
Case 2: $x \in B \setminus A$. Let $V_x = (f \bigm| (B \setminus A))^{-1}(U)$ and proceed similarly.
Case 3: $x \in A \cap B$. Let $W_{x,A} = (f \bigm| A)^{-1}(U)$ which is open in $A$, and therefore using the subspace topology we have $W_{x,A} = A \cap V_{x,A}$ for some open $V_{x,A} \subset X$. Let $W_{x,B} = (f \bigm| B)^{-1}(U)$, and similarly $W_{x,B} = B \cap V_{x,B}$ for some open $V_{x,B} \subset X$. Finally let $V_x = V_{x,A} \cap V_{x,B}$.
