# [kde-edu]: kig: "locking" a line

Maurizio Paolini paolini at dmf.unicatt.it
Mon Jul 4 10:07:09 CEST 2005

```On Sat, Jul 02, 2005 at 09:49:09PM -0400, Noel Bush wrote:
> I have a simple scenario I want to demonstrate using kig, yet I'm not
> sure how:
>
> I want to set up a right triangle, with legs on the positive x and y
> axes, and then I want to move the rightmost vertex horizontally.  I want
> to show how the angle between the hypotenuse and the bottom leg changes
> as I move this vertex.  And I want to show how the sine, cosine and
> tangent change as this vertex moves.
>[...]

How to constrain a point

there is just one way to do that:
- create a line coinciding with the x-axis
(click on "line" and on a couple of points on the x-axis; you can hold down
the left "shift" key to help positioning the two points exactly on the
x-axis)
- create a point constrained on that line: click on "point" and then select
a point on the straight line with the mouse; check that it is constrained
by trying to move it.
- you can not make the straight line (and the two defining points) invisible
- you can force the point to lie on the positive x-axis by creating a "ray"

You second question regards making computations in kig.  This is at the
moment quite tricky, unfortunately... we have plans to include a way of doing
that in future versions, but at the moment this is not easy to do.

The most powerful way for obtaining computations is by using "python scripting";
you can construct a python script that takes in input e.g. two segments
(two sides of the triangle) and computes the ratio of their length.  Unfortunately
at the moment a python script can only output geometric objects, not a simple
number.  You can work around this problem by returning a point having appropriate
x-coordinate and then you can create a "text" that displays such x-coordinate.
Here is an example:

def calc( arg1, arg2 ):
l1 = arg1.length()
l2 = arg2.length()
return Point (Coordinate(l1/l2,0.0))

In many cases there are geometric constructions that allow to compute the
required quantities; in your case you can construct a similar right triangle
having its long edge of unit length, then measure the two remaining sides;
in this way you can avoid using the "python scripting" of kig.

> I would also love to know how to do something similar, but with an angle
> in standard position: rotate a fixed-length ray (the terminal side of
> the angle) around the origin.

Create the unit circle and then constrain a point on it...

Maurizio Paolini
```