Fractions
Author: Irina Boyadzhiev
Date: 4 December 2012

This applet can be used to demonstrate proper and improper fraction as parts of the whole and as points on the number line.
   Drag the red slider to cut the whole in several parts.
   Drag the blue slider to color some parts.
Examples:1/2; 2/3;3/5,4/5, 5/5, 7/5.

Number of parts in the whole

Number of taken parts

Hint 1

Hint 2

Show/Hide Parts

Check

A = (0, 0.5)
u = Vector((0, 0), (1, 0))
d = Random(1, 6)
n = Random(1, 6)
remainder = Mod(n, d)
whole: (n - remainder) / d
endNumber = If(remainder ≟ 0, whole, whole + 1)
B = (1, 0.5)
poly1, a, b, c, e, C, D = Polygon(A, B, 4)
SecondLow = Sequence(B + i * u, i, 0, whole)
FirstLow = Sequence(A + i * u, i, 0, whole)
list1 = Zip(Polygon[X, Y, 4], X, FirstLow, Y, SecondLow)
PtBottom = Sequence(Point[A, Vector[i * u / d]], i, 1, n)
PtTop = Sequence(Point[D, Vector[i * u / d]], i, 1, n)
PtTop1 = Append(D, Take[PtTop, 1, n - 1])
PtBottom1 = Append(A, Take[PtBottom, 1, n - 1])
list2 = Zip(Polygon[E, F, G, H], E, PtBottom1, F, PtBottom, G, PtTop, H, PtTop1)
poly2, f, g, h, i, E, F = Polygon(C, B, 4)
poly3, j, k, l, m, G, H = Polygon(F, E, 4)
poly4, p, q, r, s, I, J = Polygon(H, G, 4)
poly5, t, a_1, b_1, c_1, K, L = Polygon(J, I, 4)
poly6, d_1, e_1, f_1, g_1, M, N = Polygon(L, K, 4)
OO = (0, 0)
list3 = Sequence(Point[OO, Vector[i * u / d]], i, 1, 10 * d)
maximum: 6 * d
Z = Element(list3, n)
text3: "$ \frac{" + (LaTeX[n]) + "}{" + (LaTeX[d]) + "} $"
whole1: whole - 1
list4 = Zip(Segment[M, N], M, list3, N, PtBottom)
h_1 = Segment(A, OO)
allTop = Sequence(Point[D, Vector[i * u / d]], i, 1, d * endNumber)
allBott = Sequence(Point[A, Vector[i * u / d]], i, 1, d * endNumber)
list5 = Zip(Segment[M, N], M, allTop, N, allBott)
hnt1 = false
hnt2 = false
seePrts = false
BB = Corner(text3, 2)
CC = Corner(text3, 3)
DD = Corner(text3, 4)
AA = Corner(text3, 1)
frame, aa, bb, cc, dd = Polygon(AA, BB, CC, DD)
MM = Midpoint(AA, BB)
fr: n / d
good: abs(x(MM) - n / d) ≤ 0.05
ans = false