summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/euclideangeometry/euclideangeometry.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/euclideangeometry/euclideangeometry.dtx')
-rw-r--r--macros/latex/contrib/euclideangeometry/euclideangeometry.dtx153
1 files changed, 143 insertions, 10 deletions
diff --git a/macros/latex/contrib/euclideangeometry/euclideangeometry.dtx b/macros/latex/contrib/euclideangeometry/euclideangeometry.dtx
index 7305301abf..af615d4b55 100644
--- a/macros/latex/contrib/euclideangeometry/euclideangeometry.dtx
+++ b/macros/latex/contrib/euclideangeometry/euclideangeometry.dtx
@@ -45,7 +45,7 @@ This work consists of files:
%<package>\ProvidesPackage{euclideangeometry}%
%<readme>File README.txt for package euclideangeometry
%<*package|readme>
- [2020-03-30 v.0.1.7 Extension package for curve2e]
+ [2020-04-15 v.0.1.8 Extension package for curve2e]
%</package|readme>
%<*driver>
\documentclass{ltxdoc}\errorcontextlines=100
@@ -154,7 +154,7 @@ g\raisebox{-0.715ex}{\kern-0.26em u}\kern-0.13em\I\kern-0.14em t}\xspace}
% installed with your updated complete \TeX system installation.
% Please refer to the user manual before using this package.
-% \CheckSum{1193}
+% \CheckSum{1296}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\StopEventually{}
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -605,11 +605,12 @@ g\raisebox{-0.715ex}{\kern-0.26em u}\kern-0.13em\I\kern-0.14em t}\xspace}
% but it allows to go on with typesetting, although with non sense results.
% Warnings do not stop the compilation program, therefore their message
% goes to the \file{.log} file and the user might not notice it; but
-% since the results are probably absurd, s/he certainly notice this
-% fact and look for messages; the user, therefore, who has carefully
+% since the results are probably absurd, s/he certainly notices this
+% fact and looks for messages; the user, therefore, who has carefully
% read this user manual, immediately looks onto the \file{.log} file
-% and realises the reason of the wrong results.
-%
+% and realises the reason of the wrong results. A similar approach
+% is used for the macro that determines the intersection of two circles;
+% see below
% The syntax of this macro is the following:
%\begin{ttsyntax}
%\cs{IntersectionsOfLine}\parg{point}\parg{direction} WithCircle\parg{center}\marg{radius} to\meta{int1} and\meta{int2}
@@ -659,8 +660,8 @@ g\raisebox{-0.715ex}{\kern-0.26em u}\kern-0.13em\I\kern-0.14em t}\xspace}
\SymmetricalPointOf#3respect\Smed to#4\ignorespaces}
% \end{macrocode}
%
-% Another useful macro draws a circle given its \meta{center} and the
-% coordinates of the \meta{ponit} which the circumference should pass
+% This useful macro draws a circle given its \meta{center} and the
+% coordinates of the \meta{point} which the circumference should pass
% through. The syntax is:
%\begin{ttsyntax}
%\cs{CircleThrough}\parg{[point}WithCenter\marg{center}
@@ -683,8 +684,140 @@ g\raisebox{-0.715ex}{\kern-0.26em u}\kern-0.13em\I\kern-0.14em t}\xspace}
%\end{flushleft}
% where \cs{ignorespaces} may be superfluous, but is always a safety action
% when defining commands to be used within the \amb{picture} environment.
-% In any case see example~XXX in \file{euclideangeometry-man.pdf}
-%^^A\ref{fig:twocircles-second intersection}.
+% In any case see example~15 in \file{euclideangeometry-man.pdf}
+%^^A\ref{fig:two-intersecting-circles}.
+%
+% If it is necessary to find the intersections of two circles that
+% do not share a previously known point; we can use the following
+% macro. Analytically given the equations of two circumferences,
+% it is necessary to solve a system of two second degree equations
+% the processing of which ends up with a second degree polynomial
+% that might have real roots (the coordinates of the intersection
+% points), or two coincident roots (the circles are tangent), or
+% complex roots (the circles do not intersect), or they may be
+% indefinite (the two circles heve the same center and the same
+% radii). Let us exclude the last case, although it would be trivial
+% to create the macro with a test that controls such situation. But
+% even the analysis of the discriminant of the second degree equation
+% requires a complicated code.
+%
+% On the opposite a simple drawing of the two circles, with centers
+% $C_1$ and $C_2$ and radii $R_1$ and $R_2$, with the centers distance
+% of $ a= |C_1-C_2|$, allows to understand that in order to have
+% intersections: $(\alpha)$ if $a\leq \max(R_1,R_2)$ (the center
+% of a circle is contained within the other one) then it must be
+% $ a \geq |R_1 - R_2|$, where the ‘equals’ sign applies when the
+% circles are internally tangent; $(\beta)$ otherwise
+% $a \geq \max(R_1,R_2)$ and it must be $a \leq R_1+R_2$ , where
+% the ‘equals’ sign applies when the circles are externally tangent.
+% In conclusion in any case il the range $|R_1-R_2|\leq a\leq R_1+R_2$
+% is where the two circles intersect, while outside this distance
+% range the circles do not intersect.
+%
+% For simplicity let us assume that $R_1 \geq R_2$; the macro can
+% receive the circle data in any order, but the macro very easily
+% switches their data so that circle number~1 is the one with larger
+% radius. If the distance $a$ is outside the allowed range, there
+% are no intersections, therefore a warning message is output and the
+% intersection point coordinates are both set to \texttt{0,0}, so that
+% processing continues with non sense data; the remaining geometric
+% construction based on such intersection points might continue with
+% other error messages or to absurd results; a string message to the
+% user who, having read the documentation, understand the problem and
+% provides for.
+%
+% The new macro has the following syntax:
+%\begin{ttsyntax}
+%\cs{TwoCirclesIntersections}\parg{C1}\parg{C2}withradii\marg{R1} and\marg{R2} to\meta{P1} and\meta{P2}
+%\end{ttsyntax}
+% where the symbols in input may be macros or explicit numerical
+% values; the output point coordinates \meta{P1} and \meta{P2}
+% should be definable single tokens, therefore the surrounding
+% braces are not necessary.
+% \begin{macrocode}
+\def\TwoCirclesIntersections(#1)(#2)withradii#3and#4to#5and#6{%
+ \fptest{#3 >=#4}{%
+ \edef\Cuno{#1}\edef\Cdue{#2}%
+ \edef\Runo{#3}\edef\Rdue{#4}%
+ }{%
+ \edef\Cdue{#2}\edef\Cuno{#2}%
+ \edef\Rdue{#3}\edef\Runo{#4}%
+ }
+% \end{macrocode}
+% Above we switched the circle data so as to be sure that symbols relating
+% to circle ‘one’ refer to the circle with larger (or equal) radius.
+% Now we define the centers distance in macro \cs{A}; the test if \cs{A}
+% lays in the correct range, otherwise we output a warning message.
+% \begin{macrocode}
+ \SegmentLength(\Cuno)(\Cdue)to\A
+ \edef\TCIdiffR{\fpeval{\Runo-\Rdue}}\edef\TCIsumR{\fpeval{\Runo+\Rdue}}
+ \fptest{\TCIdiffR > \A || \A > \TCIsumR}{%
+ \edef#5{0,0}\edef#6{0,0}% Valori assurdi se i cerchi non si intersecano
+ \PackageWarning{TestFP}{%
+ ***********************************\MessageBreak
+ Circles do not intersect \MessageBreak
+ Check centers and radii and retry \MessageBreak
+ Both intersection point are set to \MessageBreak
+ (0,0) therefore expect errors \MessageBreak
+ ***********************************\MessageBreak}%
+ }{%
+% \end{macrocode}
+% Here we are within the correct range and we proceed with the
+% calculations. We take as a temporary reference the segment
+% that joins the centers. The common chord that joins the
+% intersection points is perpendicular to such a segment crossing
+% it by a distance $c$ form $C_1$, and, therefore by a distance
+% $a-c$ from $C_2$; this chord forms two isosceles triangles with the
+% centers; the above segment bisects such triangles, forming four right
+% triangles; their hypotenuses equal the radii of the respective
+% circles; their bases $h$ are all equal to half the chord; Pythagoras'
+% theorem allows us to write:
+%\[
+%\left\{
+% \begin{aligned}
+% h^2 &= R_1^2 - c^2\\
+% h^2 &= R_2^2 - (a-c)^2
+% \end{aligned}
+%\right.
+%\]
+% Solving for $c$, we get:
+%\[\left\{
+%\begin{aligned}
+%c &= \frac{R_1^2 - R_2^2 + a^2 }{2a}\\
+%h &= \sqrt{R_1^2 -c^2}
+%\end{aligned}
+%\right.
+%\]
+% \begin{macrocode}
+ \SegmentArg(\Cuno)(\Cdue)to\Acompl
+ \SubVect\Cuno from\Cdue to \Cdue
+ \edef\CI{\fpeval{(\Runo^2 - \Rdue^2 +\A^2)/(2*\A)}}
+ \edef\H{\fpeval{sqrt(\Runo^2 - \CI^2)}}
+ \CopyVect\CI,-\H to\Puno
+ \CopyVect\CI,\H to\Pdue
+% \end{macrocode}
+% Now we do not need anymore the chord intersection distance \cs{CI}
+% any more, so we can use for other tasks, and we create a vector with
+% absolute coordinates; We then add the rotated vector corresponding
+% to the base \cs{H} so as to get the absolute chord extrema \cs{PPuno}
+% and \cs{PPdue}.
+% \begin{macrocode}
+ \MultVect\CI,0 by\Acompl:1 to\CI
+ \AddVect\Cuno and\CI to\CI
+ \MultVect\Puno by\Acompl:1 to\PPunorot
+ \AddVect\PPunorot and \Cuno to \PPuno
+ \MultVect\Pdue by\Acompl:1 to\PPduerot
+ \AddVect\PPduerot and \Cuno to \PPdue
+ \edef#5{\PPuno}\edef#6{\PPdue}%
+ }%
+}
+% \end{macrocode}
+% It may be noticed that the first intersection point, assigned to
+% parameter |#5| is the one found along the orthogonal direction
+% to the vector form $C_1$ to $C_2$, obtained by a rotation of
+% $90^\circ$ counterclockwise.
+% The whole construction of the geometry described above is shown
+% in figure~16 in the user manual \file{euclideangeometry-man.pdf}.
%
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \subsection{Triangle special points}