Adding a normal vector to a curved mesh area

How can I put a normal vector on the outer blue mesh?

TeXample

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\usepackage{pgfplots}

\newcommand\pgfmathsinandcos[3]{%
\pgfmathsetmacro#1{sin(#3)}%
\pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % azimuth
\tikzset{#1/.estyle = {cm = {\cost, \sint*\sinEl, 0, \cosEl, (0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % latitude
\pgfmathsetmacro\yshift{\cosEl*\sint}
\tikzset{#1/.estyle = {cm = {\cost, 0, 0, \cost*\sinEl, (0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style = {scale = #1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane] (\angVis:1) arc (\angVis:\angVis + 180:1);
\draw[current plane, dashed] (\angVis - 180:1) arc (\angVis - 180:\angVis:1);
}
\newcommand\DrawLatitudeCircle[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style = {scale = #1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane] (\angVis:1) arc (\angVis:-\angVis - 180:1);
\draw[current plane, dashed] (180 - \angVis:1) arc (180 - \angVis:\angVis:1);
}
\newcommand\DrawLongitudeCirclered[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane, blue, thick] (150:1) arc (150:180:1);
% \draw[current plane,dashed] (-50:1) arc (-50:-35:1);
}%for drawing the grid
\newcommand\DLongredd[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane, black, dashed, ultra thick] (150:1) arc (150:180:1);
}
\newcommand\DLatred[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane, dashed, black, ultra thick] (-50:1) arc (-50:-35:1);
}
\newcommand  \fillred[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane, blue, thin] (\angVis:1) arc (\angVis:\angVis+180:1);
}
\newcommand\DrawLatitudeCirclered[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
% \draw[current plane,red,thick] (-\angVis-50:1) arc (-\angVis-50:-\angVis-20:1);
\draw[current plane, blue, thick] (-50:1) arc (-50:-35:1);
}

\tikzset{%
>=latex, % option for nice arrows
inner sep = 0pt,%
outer sep = 2pt,%
mark coordinate/.style = {inner sep = 0pt, outer sep = 0pt, minimum size = 3pt,
fill = black, circle}%
}

\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}

\def\angEl{25} % elevation angle
\def\angAz{-100} % azimuth angle
\def\angPhiOne{-50} % longitude of point P
\def\angPhiTwo{-35} % longitude of point Q
\def\angBeta{30} % latitude of point P and Q

%% working planes

\pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole
\LongitudePlane[xzplane]{\angEl}{\angAz}
\LongitudePlane[pzplane]{\angEl}{\angPhiOne}
\LongitudePlane[qzplane]{\angEl}{\angPhiTwo}
\LatitudePlane[equator]{\angEl}{0}
\fill[ball color = green!10] (0,0) circle (\R); % 3D lighting effect
\coordinate (O) at (0,0);
\coordinate[mark coordinate] (N) at (0,\H);
\coordinate[mark coordinate] (S) at (0,-\H);
\path[xzplane] (\R,0) coordinate (XE);
%defining points outsided the area bounded by the sphere
\path[qzplane] (\angBeta:\R+3) coordinate (XEd);
\path[pzplane] (\angBeta:\R) coordinate (P);
\path[pzplane] (\angBeta:\R+3) coordinate (Pd);
\path[pzplane] (\angBeta:\R+5.2376) coordinate (Td);
\path[pzplane] (\R,0) coordinate (PE);
\path[pzplane] (\R+3,0) coordinate (PEd);
\path[qzplane] (\angBeta:\R) coordinate (Q);
\path[qzplane] (\angBeta:\R) coordinate (Qd);

\path[qzplane] (\R,0) coordinate (QE);
\path[qzplane] (\R+3,0) coordinate (QEd);

\DrawLongitudeCircle[\R]{\angPhiOne} % pzplane
\DrawLongitudeCircle[\R]{\angPhiTwo} % qzplane
\DrawLatitudeCircle[\R]{\angBeta}
\DrawLatitudeCircle[\R]{0} % equator
% labelling north and south
\node[above = 8pt] at (N) {$\mathbf{N}$};
\node[below = 8pt] at (S) {$\mathbf{S}$};

\draw[-, dashed, thick] (N) -- (S);
%\draw[->] (O) -- (P);
%\draw[dashed] (XE) -- (O) -- (PE);
\draw[dashed] (O) -- (QE);
% connecting Points outside the sphere
\draw[-, dashed, black, very thick] (O) -- (Pd);
\draw[-, dashed, black, very thick] (O) -- (PEd);
\draw[-, dashed, black, very thick] (O) -- (QEd);
\draw[-, dashed, black, very thick] (O) -- (XEd);
\path[pzplane] (0.5*\angBeta:\R) node[right] {$$}; \path[qzplane] (0.5*\angBeta:\R) node[right] {$$};
\path[xzplane] (0:\R) node[below] {$$}; \path[xzplane] (\angBeta:\R) node[below left] {$$};
\foreach \t in {0,2,...,30} { \DrawLatitudeCirclered[\R]{\t} }
\foreach \t in {130,133,...,145} { \DrawLongitudeCirclered[\R]{\t} }

% drawing grids on the spere invoking DLongredd and DrawLongitudeCirclered

\foreach \t in {130,145,...,145} { \DLongredd[\R+3]{\t} }
\foreach \t in {130,133,...,145} { \DrawLongitudeCirclered[\R+3]{\t} }

\foreach \t in {0,30,...,30} { \DLatred[\R+3]{\t} }
\foreach \t in {0,2,...,30} { \DrawLatitudeCirclered[\R+3]{\t} }
\end{tikzpicture}
\caption{The normal pressure force of the surrounding water on $m$.}
\end{figure}

\end{document}
-
I just now attempted to compile you code, and I get the error LaTeX Error: Command \DrawLongitudeCirclered already defined. Also, I don't think @Jubobs was trying to be rude -- the "insist" was probably just intended to highlight the "M" and "W" in MWE. There are numerous non-english speakers here so please try not to take offense. – Peter Grill Apr 27 '13 at 2:45
I get the same error as @PeterGrill when i compile your code. My guess is your code is built on a texample.net example. Kindly give credits or links to give a clear context in the question. – texenthusiast Apr 27 '13 at 2:58
Earlier MWE tested by @PeterGrill was better compared to this as there is no \begin{document} and nothing after that.. Kindly care to make sure the MWE is correct before posting. – texenthusiast Apr 27 '13 at 3:08
I was referring to revision5. Any i have to leave bye – texenthusiast Apr 27 '13 at 3:21
I don't know why you provided a complete, long code while minimizing it is still possible to conforms to the MWE protocol. :-) – kiss my armpit Apr 27 '13 at 6:17

I created a solution using the primitives already defined in the not-so-minimal MWE. :-)

Due to the length of the code, I'll explain my additions line-by-line; the complete code follows.

\def\angPhiAvg{-42.5}
defines angle phi for the vector to follow (in this case, the average of the grid extents).

\LongitudePlane[myplane]{\angEl}{\angPhiAvg}
defines an additional working plane in which the vector will lie.

\path[myplane] (\angBeta/2:\R+3) coordinate (Ts);
\path[myplane] (\angBeta/2:\R+4) coordinate (Tf);
define the start and finish of the vector; in this case, a unit length.

\draw[->, green, very thick] (Ts) -- (Tf) node[right] {$\mathbf{\hat{n}}$};
draws and labels the normal vector.

Complete Code

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\usepackage{pgfplots}

\newcommand\pgfmathsinandcos[3]{%
\pgfmathsetmacro#1{sin(#3)}%
\pgfmathsetmacro#2{cos(#3)}%
}
\newcommand\LongitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % azimuth
\tikzset{#1/.estyle = {cm = {\cost, \sint*\sinEl, 0, \cosEl, (0,0)}}}
}
\newcommand\LatitudePlane[3][current plane]{%
\pgfmathsinandcos\sinEl\cosEl{#2} % elevation
\pgfmathsinandcos\sint\cost{#3} % latitude
\pgfmathsetmacro\yshift{\cosEl*\sint}
\tikzset{#1/.estyle = {cm = {\cost, 0, 0, \cost*\sinEl, (0,\yshift)}}} %
}
\newcommand\DrawLongitudeCircle[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style = {scale = #1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane] (\angVis:1) arc (\angVis:\angVis + 180:1);
\draw[current plane, dashed] (\angVis - 180:1) arc (\angVis - 180:\angVis:1);
}
\newcommand\DrawLatitudeCircle[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style = {scale = #1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane] (\angVis:1) arc (\angVis:-\angVis - 180:1);
\draw[current plane, dashed] (180 - \angVis:1) arc (180 - \angVis:\angVis:1);
}
\newcommand\DrawLongitudeCirclered[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane, blue, thick] (150:1) arc (150:180:1);
% \draw[current plane,dashed] (-50:1) arc (-50:-35:1);
}%for drawing the grid
\newcommand\DLongredd[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane, black, dashed, ultra thick] (150:1) arc (150:180:1);
}
\newcommand\DLatred[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
\draw[current plane, dashed, black, ultra thick] (-50:1) arc (-50:-35:1);
}
\newcommand  \fillred[2][1]{
\LongitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
% angle of "visibility"
\pgfmathsetmacro\angVis{atan(sin(#2)*cos(\angEl)/sin(\angEl))} %
\draw[current plane, blue, thin] (\angVis:1) arc (\angVis:\angVis+180:1);
}
\newcommand\DrawLatitudeCirclered[2][1]{
\LatitudePlane{\angEl}{#2}
\tikzset{current plane/.prefix style={scale=#1}}
\pgfmathsetmacro\sinVis{sin(#2)/cos(#2)*sin(\angEl)/cos(\angEl)}
% angle of "visibility"
\pgfmathsetmacro\angVis{asin(min(1,max(\sinVis,-1)))}
% \draw[current plane,red,thick] (-\angVis-50:1) arc (-\angVis-50:-\angVis-20:1);
\draw[current plane, blue, thick] (-50:1) arc (-50:-35:1);
}

\tikzset{%
>=latex, % option for nice arrows
inner sep = 0pt,%
outer sep = 2pt,%
mark coordinate/.style = {inner sep = 0pt, outer sep = 0pt, minimum size = 3pt,
fill = black, circle}%
}

\begin{document}
\begin{figure}[H]
\centering
\begin{tikzpicture}

\def\angEl{25} % elevation angle
\def\angAz{-100} % azimuth angle
\def\angPhiOne{-50} % longitude of point P
\def\angPhiTwo{-35} % longitude of point Q
\def\angPhiAvg{-42.5} % longitude of normal vector ******
\def\angBeta{30} % latitude of point P and Q

%% working planes

\pgfmathsetmacro\H{\R*cos(\angEl)} % distance to north pole
\LongitudePlane[xzplane]{\angEl}{\angAz}
\LongitudePlane[pzplane]{\angEl}{\angPhiOne}
\LongitudePlane[qzplane]{\angEl}{\angPhiTwo}
\LongitudePlane[myplane]{\angEl}{\angPhiAvg} % ******
\LatitudePlane[equator]{\angEl}{0}
\fill[ball color = green!10] (0,0) circle (\R); % 3D lighting effect
\coordinate (O) at (0,0);
\coordinate[mark coordinate] (N) at (0,\H);
\coordinate[mark coordinate] (S) at (0,-\H);
\path[xzplane] (\R,0) coordinate (XE);
%defining points outsided the area bounded by the sphere
\path[qzplane] (\angBeta:\R+3) coordinate (XEd);
\path[pzplane] (\angBeta:\R) coordinate (P);
\path[pzplane] (\angBeta:\R+3) coordinate (Pd);
\path[myplane] (\angBeta/2:\R+3) coordinate (Ts); % ******
\path[myplane] (\angBeta/2:\R+4) coordinate (Tf); % ******
\path[pzplane] (\R,0) coordinate (PE);
\path[pzplane] (\R+3,0) coordinate (PEd);
\path[qzplane] (\angBeta:\R) coordinate (Q);
\path[qzplane] (\angBeta:\R) coordinate (Qd);

\path[qzplane] (\R,0) coordinate (QE);
\path[qzplane] (\R+3,0) coordinate (QEd);

\DrawLongitudeCircle[\R]{\angPhiOne} % pzplane
\DrawLongitudeCircle[\R]{\angPhiTwo} % qzplane
\DrawLatitudeCircle[\R]{\angBeta}
\DrawLatitudeCircle[\R]{0} % equator
% labelling north and south
\node[above = 8pt] at (N) {$\mathbf{N}$};
\node[below = 8pt] at (S) {$\mathbf{S}$};

\draw[-, dashed, thick] (N) -- (S);
%\draw[->] (O) -- (P);
%\draw[dashed] (XE) -- (O) -- (PE);
\draw[dashed] (O) -- (QE);
% connecting Points outside the sphere
\draw[-, dashed, black, very thick] (O) -- (Pd);
\draw[-, dashed, black, very thick] (O) -- (PEd);
\draw[-, dashed, black, very thick] (O) -- (QEd);
\draw[-, dashed, black, very thick] (O) -- (XEd);
\path[pzplane] (0.5*\angBeta:\R) node[right] {$$}; \path[qzplane] (0.5*\angBeta:\R) node[right] {$$};
\path[xzplane] (0:\R) node[below] {$$}; \path[xzplane] (\angBeta:\R) node[below left] {$$};
\foreach \t in {0,2,...,30} { \DrawLatitudeCirclered[\R]{\t} }
\foreach \t in {130,133,...,145} { \DrawLongitudeCirclered[\R]{\t} }
\draw[->, green, very thick] (Ts) -- (Tf) node[right] {$\mathbf{\hat{n}}$}; % ******

% drawing grids on the spere invoking DLongredd and DrawLongitudeCirclered

\foreach \t in {130,145,...,145} { \DLongredd[\R+3]{\t} }
\foreach \t in {130,133,...,145} { \DrawLongitudeCirclered[\R+3]{\t} }

\foreach \t in {0,30,...,30} { \DLatred[\R+3]{\t} }
\foreach \t in {0,2,...,30} { \DrawLatitudeCirclered[\R+3]{\t} }
\end{tikzpicture}
\caption{The normal pressure force of the surrounding water on $m$.}
\end{figure}

\end{document}
-