Kig (software)


Kig is free and open-source interactive geometry software, which is part of the KDE Education Project. It has some facilities for scripting in Python, as well as the creating macros from existing constructions.

Import and export

Kig can import files made by DrGeo and Cabri Geometry as well as its own file format, which is XML-encoded. Kig can export figures in LaTeX format and as SVG files.

Objects

Kig can handle any classical object of the dynamic geometry, but also:
  1. The center of curvature and osculating circle of a curve;
  2. The dilation, generic affinity, inversion, projective application, homography and harmonic homology;
  3. The hyperbola with given asymptotes;
  4. The Bézier curves ;
  5. The polar line of a point and pole of a line with respect to a conic section;
  6. The asymptotes of a hyperbola;
  7. The cubic curve through 9 points;
  8. The cubic curve with a double point through 6 points;
  9. The cubic curve with a cusp through 4 points.

    Scripting language

Inside the figure

Another object is available inside Kig, it is a Python language script. It can accept Kig objects as variables, and always return one object.
For example, if there is already a numeric object inside the figure, for example 3, the following Python object can yield its square :

def square:
return DoubleObject

The variables are always called arg1, arg2 etc. in the order they are clicked upon. Here there is only one variable arg1 and its numerical value is obtained with arg1.value.
If now one wants to implement the square of a complex number, the object which has to be selected at the creation of the script must necessarily be a point, and the script is

def csquare:
x = arg1.coordinate.x
y = arg1.coordinate.y
z = x * x - y * y
y = 2 * x * y
x = z
return Point

The abscissa of the point representing the square of the complex number is as can be seen by expanding. Coordinate creates a Python list made of the two coordinates of the new point. And Point creates the point which coordinates are precisely given by this list.
But a Python object inside a figure can only create one object and for more complex figures one has to build the figure with a script:

Figure created by a script

Kig comes up with a little program called pykig.py which can
  1. load a Python script, e.g. MyScript.py
  2. build a Kig figure, described by this script
  3. open Kig and display the figure.
For example, here is how a Sierpinski triangle can be made with pykig:

from random import *
kigdocument.hideobjects
A = Point
A.show
B = Point
B.show
C = Point
C.show
M = Point
for i in range:
d = randrange
if d 0:
s = Segment
M = s.midpoint
if d 1:
s = Segment
M = s.midpoint
if d 2:
s = Segment
M = s.midpoint
M.show