Points, lines, line segments, rays, and labels

With the help of Google Translate, page 13-14 of the documentation for tkz-euclide 1.16c mentions that the various macros were designed so that creating pictures could be broken up into 4 steps:

  1. Define the points whose coordinates are known.
  2. Create new points using methods (intersection, transformation, etc.).
  3. Plot the objects (vertex, line, circle, etc.) in a some order.
  4. Add the labels.

\usetkzobj{ }  This macro is part of tkz-base and it's needed when the code contains various objects (points, lines, segments, vectors, circles, polygons, arcs, sectors, protractor, and marks). Failure to declare the object results in code not running. Avoid headaches by putting \usetkzobj{all} in the preamble.

Defining Points: Points are defined as either an (x,y) pair in the Cartesian plane or as $latex (\theta: r)$ where the angle $latex \theta$ is in degrees; i.e., basically polar coordinates. The default units are in centimeters and that defining a point does not, in general, plot the point. There are 3 macros to define points.

\tkzDefPoint[<options>]{<point>} defines 1 point. Although \tkzDefPoint(1,1){A} defines a point, A, at (1,1) it doesn't print it. However, if I use some options (such as the label) the point will be printed; for example \tkzDefPoint[label=above:$1$](1,1){A} will plot the point with the label, 1 above the point.

Label positioning: The position of the label can be: above, above right, right, below right, below, below left, left, above left. You can also choose the position of the label with more precision using degrees; \tkzDefPoint[label=45:$1$](1,1){A} will print the label 1 in the above right position.

Using "polar" coordinates,  \tkzDefPoint(30:1) will define a point 1 unit (in centimeters) from the origin with a 30 degree angle above the x-axis but the point isn't plotted. Adding the label \tkzDefPoint[label=25:$2$](30:1) still doesn't plot the point.

Other options: It's not clear to me from the documentation what the local options are but shape and color have an effect; for example

\tkzDefPoint[shape = circle,fill=green!60,label=above:$W$](8,1){R}

will define and plot a green circle at (8,1) which is labeled above with W (but referred to internally as R). The effect is inconsistent so it seems best to set the label through the option but set the attributes of the point when it is plotted with \tkzDrawPoint or through \tkzSetUpPoint. This is more in keeping with the 4 step process of creating plots given above.

\tkzDefPointst[<options>]{<list of points>} defines multiple points at the same time if they're in point form (as opposed to "polar" form), so

\tkzDefPoints{0/0/A, 1/0/B, 1/1/C,0/1/D}

defines point (0,0) as A, (1,0) as B, (1,1) as C, and (0,1) as D.

\tkzDefShiftPoint[<point to be shifted>](<shift>){<point name>} defines a point in terms of a translation of a previously defined point. This is an extremely powerful macro that makes tkz-euclide special. Consider these 3 lines of code:




Line 1 defines a point (0,0) called A. Line 2 takes point A, rotates 20 degrees and moves 4 units in that direction to create point B. Line 3 takes point A, rotates it 80 degrees and moves 4 units in that direction to create point C. Though the points A, B, and C haven't been plotted they define an equilateral triangle: It's an isosceles triangle because of the sides length 4. Therefore the base angles are the same hence, if each base angle is x we have x+x=180-(80-20). Solving for x will give 60 and we know equiangular triangles are equilateral.

Once you've got points defined you can start creating more complicated shapes: circles, segments, rays, lines, polygons, and so on. But first we concentrate on what individual points will look like. This is accomplished through 2 commands:

\tkzDrawPoint[<options>](<point name>)  allows you to plot each point individually and that allows you change the options for how each point is represented. The options for a point include shape, size, color, and label.

shape: either circle, cross (+) or cross out (X); the default is circle.

size: default size of 6 times \pgflinewidth

color: default color is black.

fill: If the shape is circle and the size is big you might find the circumference is one color and the inside color is something else. The inside color is controlled by fill and the circumference color is controlled by color. This is a good time to stop and summarize with a simple example.


The files for the picture above: Euclide1 (tex)  Euclide1 (cropped PDF)

\tkzDrawPoints[<options>](<list of point name>) When you have a set of points that should all look the same time then this macro lets you plot them with just 1 line of code.

Replacing the 3 \tkzDrawPoint lines in Euclid1.tex by \tkzDrawPoints(A,B,C) will plot 3 black circular points; point A is labeled W.

Labeling points

The specifics of labeling a point can be controlled more completely through \tkzLabelPoint[<options>](<point>){<label>} and \tkzLabelPoints[<options>](<point>){<label>}. In addition to the position of the labels, you can control the color of the label. Without any options the statement  \tkzLabelPoint(B) will label the point B with the label B in the below right position. If you want B labeled with something else, such as P, then  \tkzLabelPoint(B){P} will work but to match the default style you should have the label P in math mode; i.e., \tkzLabelPoint(B){$P$}. You can add options, for example,  \tkzLabelPoint[left, red](B){$P$} to make the label P red and placed to the left of the point B. The labels of several points can be controlled at once with \tkzLabelPoints.

Euclid2The files creating the screenshot above are: Euclide2 (tex)  Euclide2 (PDF)

Drawing lines, line segments, and rays

Line segments, rays and lines can are drawn either one at a time using \tkzDrawSegment or multiple segments at the same time using \tkzDrawSegments macros. The structure of the first is \tkzDrawSegment[<options>](<point 1, point 2>). Options give you control over the look of the segment; for example: color, line width, style (solid, dotted, dashed, dashdotted), opacity, and whether the segment begins or ends with an arrow. If you're going to keep the same style for your line segments then the \tkzDrawSegments[<options>](<point 1, point 2  point 3, point 4,  ...>). Note the spaces after every 2 points.

EuclideLinesThe code and output are: EuclideLines (tex)  EuclideLines (PDF)

Rays can be formed by adding an arrow to the options of \tkDrawSegment; e.g., \tkDrawSegment[->}(A,B) would be the ray starting at A and ending at B with an arrow. If you want the ray to go through the point before adding the arrow at the end, indicate that you want to go beyond B with add=0pt and 12pt to the options which will go 12pt beyond point B. Writing add=12pt will result in an error. You must add to both sides but, as you can see that amount can be 0. It can even be negative. Here's an example of a ray:

\tkzDrawSegment[->,line width=2pt,add=0pt and 12pt,color=DeepSkyBlue](A,B)

You can quickly adapt this to create lines as well:

\tkzDrawSegment[<->,line width=-2pt,add=4pt and 6pt,color=DeepSkyBlue](A,B)

Note that the arrows are on both ends, and that the line is 2pt shy of A and 4pt beyond B. Strangely enough, there is a \tkzDrawLine and \tkzDrawLines macro but they don't allow for arrows on the end. Since you can do everything with \tkzDrawSegment there doesn't seem to be much use for them.

Of course, once you've created a line, segment, or ray there's a chance you'll want to label them. This can be done with the \tkzLabelSegment and \tkzLabelSegment macros which let you label one or more than one segment, respectively. The format is \tkzLabelSegment[<options>](point1, point2){<label>} and the options include things like the color, placement (above, left, right, etc), and positioning. The positioning, such pos=.4, indicates that the label is .4 of the distance from the first point to the second.

EuclideLines1The code and output are: EuclideLines1 (tex)  EuclideLines1 (PDF)

Putting it all together we can create the parallogram below:

ParallelogramThe code and output: Parallelogram (tex)  Parallelogram (PDF)

Marking Angles

MarkAnglesIn geometrical diagrams it's often important to mark angles. The figure above illustrates 2 different ways of marking angles using the tikz-euclide package. The method on the left uses


\tkzMarkAngle[<options>]<angle> and on the right \tkzMarkAngle[<options>]<angle>.

But as you can see from the diagram there are 2 angles on the left (yellow and red) and 2 angles on the right (red and blue). We need a way to distinguish between the acute angle and the obtuse angle. Remember in geometry an angle is formed by two rays which have a common endpoint (called the vertex). Tikz-euclide uses three points in describing the angle but the vertex must be in the center. The angle above (left) would be angle CAB or BAC depending on whether you mean the acute angle or the obtuse angle.  To distinguish between the 2 angles it helps to think about the angle as being created by moving a ray counterclockwise in space (as is done in trigonometry). IF the initial side is ray AB and the ray is moved counterclockwise to AC then AC is the terminal side and the angle for tikz-euclide is BAC. That's the acute angle colored yellow. IF the initial side is AC and it's moved counterclockwise to AB then the terminal side is AB and the angle for tkz-euclide is CAB. That's the obtuse angle. To mark the angles above the following code is used.

\tkzMarkAngle[size=1.1cm,fill=yellow!90, line=black,opacity=0.8](B,A,C)

There are various options for the angle: size is how far out from the vertex the angle will be. This method of marking the angles doesn't seem to allow for arrows on the mark of the angle; at least, not that I can find. To mark the angle using an arrow mark (shown on the right) can be done using \tkzDrawArc[<options>](point1, point2)(degree of rotation). Point 1 will be the vertex of the angle. Point 2 will be the point where the marking of the angle begins. Point 2 will be rotated around point 1 counterclockwise and the path (arc) is traced out. The default is to have no arrows but this can modified:

\tikzset{compass style/.append style={->}}%sets the arrow orientation for \tkzDrawArc

Download the template for the diagram above: MarkAngles  (.tex)

Creating a Simple Geometric Diagram

TrigDiag1The diagram above is an example of a "simple" geometric diagram. It consists of line segments, angle markings and text. In order to create the lines, you need 2 points. Therefore, when you look at the diagram you should see 9 points are needed.

TrigDiag1aI take the bottom left point to be the origin but that isn't required. The building on the left is made up of 4 points:


The building on the right has 5 points:


Once you have the 9 points defined you create the line segments. In addition to \tkzLabelSegment there is \tkzDrawPolygon. The \tkzDrawPolygon takes 3 or more points and creates polygon defined by them. The building on the left and right are \tkzDrawPolygon(A1,A2,B2,B1) and \tkzDrawPolygon(D1,D2,E2,E1), respectively. The dashed lines are created:

\tkzDrawSegments[dashed](B2,H B2,D2 B2,D1)

Be careful here! Note that there is a space after every 2 vertices. Putting a comma between them causes an error. After that the \tkzLabelSegment is used to get text.
\tkzLabelSegment[right=3pt](B1,B2){$100$ ft}

and finally the angles are marked and labelled.

\tkzLabelAngle[pos = 0.75](H,B2,E2){$42^{\circ}$}
\tkzLabelAngle[pos = 1.0](E1,B2,H){$20^{\circ}$}

Note the is a special command to create the right angle mark.

By breaking down a simple geometric diagram into the points needed to create the lines, you can easily decompose the picture into pieces that can be plotted with the macros given on this page. Define the points, create the lines, and add the text.

Download the file: TrigDiag1  (.tex)

Snell's Law Diagrams

Here's another example of how using just a few features of the Altermundus packages can help design 2 pictures used in explaining Snell's Law--the key is to find the important points you'll need for constructing the diagram and then break the problem into steps. The first picture is a ray of light going from the air, hitting the water, and then moving along a new path.



In deriving Snell's Law another line gets added to the diagram. This creates two angles used in Snell's Law:

SnellsLaw2In using the Altermundus packages to design both pictures the important points are:

SnellsLaw1bThese 9 points are used to generate the diagrams. Building the second diagram is then broken down into smaller pieces.

Define the points:


Color the water and sky:

\fill[blue!40,opacity=9] (A) -- (G) -- (H) -- (I) -- cycle;
\fill[blue!20,opacity=.3] (A) -- (B) -- (F) -- (G) -- cycle;

Line separating the air/water, label each piece of that line:

Draw the light:

Indicate h1, h2, and d:
\tkzDrawSegment[color=brown, dashed](A,B)
\tkzDrawSegment[color=brown, dashed](G,H)
\tkzDrawSegment[color=brown, dashed](B,F)

Label the water, indicate where the light hits the water

Label points A and B:
\tkzLabelPoint (H){$B$}

Draw the vertical line, label the angles used for Snell's Law:
\tkzText[above=15pt, left](D){$\theta_a$}
\tkzText[below=30pt, right](D){$\theta_w$}

Here is the working code for you to experiment with:

SnellsLaw1 (.tex) and SnellsLaw2 (.tex)

Parallel and Perpendicular Lines

Two practical examples that would show up in high school math: parallel lines cut by an perpendicular line and looking at the distance from a point to a line. Creating parallel and perpendicular lines is possible in tkz-euclide with the help of adding some options to our macros:

\tkzDefLine[parallel=through C](A,B)

will be used to create a line through C which is parallel to line (A,B). The macro actually creates a point on the line which we then get, and name, with


Now that we have two points on the line, we can draw it:

\tkzDrawSegment[<->,add=17pt and -14pt](C,D)

I've added arrows to both ends of the line, increased the line beyond C and decreased the line so it doesn't get to D.

Perpendicular lines are drawn in similar fashion. The macro:

\tkzDefLine[orthogonal=through C](B,A)

will create a point on the line going through point C which is perpendicular to line (B,A). Once again, the point needs to be captured with \tkzGetPoint{E} after which a line can be drawn through C and E:

\tkzDrawSegment[<->,add=15pt and -35pt](C,E)

The point of intersection for two lines can be useful. It's accomplished as follows:


Think of this as "the intersection of two lines which are (C,E) and (A,B)". The LL is telling you intersection is of two lines. Other macros have been created that behave in similar fashion but might involve LC, for line and circle. The point of intersection is captured as point I with: \tkzGetPoint{I}

I've put together the working code along with some comments on what is going on. This is the output in Gummi:


Download the file: AlterLL (.tex)

The next example illustrates some of the subtleties in working with the package. The order of executing the commands will influence how the picture looks so the point P is drawn after the dashed line. Likewise, the thick option is helpful in creating the right angle mark. Otherwise the dashed line influences the look of the figure. Finally, I've rotated my text through adding an option to the macro that creates the label on my segment


I had to experiment with angles before deciding 74.5 looked okay.


Download the file: AlterLL2  (.tex)



Leave a Reply

Your email address will not be published. Required fields are marked *

AlphaOmega Captcha Classica  –  Enter Security Code