sin
→ sin()Returns the sine of an angle — a number that swings between -1 and 1.
sin(sekhutlo)As an angle grows, sin runs from 0 up to 1, back to 0, down to -1, back to 0 — and repeats without end. It is a wave.
This is what makes art in Bopa: give sin a growing angle and you get waves, rings and loops, without reaching for translate or rotate at all.
A circle with sin and cos. Every point on a circle can be worked out like this:
x = middle + cos(angle) * radius
y = middle + sin(angle) * radius
By default the angle is read in radians, so a full turn is PEDI_PI. To work in degrees, call seeloSaSekhutlo(DEGREES) first.
The name is left as it stands. “Sine” is the word a Botswana learner writes on a BGCSE examination paper, in English — the sine, cosine and tangent ratios topic appears in the BGCSE syllabus in English only, and no Setswana word stands in its place.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
sekhutlo | palo | The angle, in radians by default, or in degrees when seeloSaSekhutlo(DEGREES) is set. |
Examples
Section titled “Examples”tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(18, 22, 34);
tlogelaMothalo();
gopheta (diri x = 0; x < 400; x = x + 4) {
// sin e busa -1..1, e lekanyediwa mo bogodimong jwa kanefase
metlha lekhubu = sin(x * 0.03);
metlha y = 200 + lekhubu * 120;
tlatsaMmala(lekanyetsa(lekhubu, -1, 1, 60, 250), 150, 220);
thalaSediko(x, y, 10);
}
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(245);
boketeMothalo(2);
metlha bogolo = [40, 70, 100];
metlha lebelo = [0.08, 0.04, 0.02];
gopheta (diri m = 0; m < 3; m = m + 1) {
mothaloMmala(60 + m * 70, 130 + m * 30, 220 - m * 50);
gopheta (diri x = 0; x < 400; x = x + 2) {
metlha y = 110 + m * 90 + sin(x * lebelo[m]) * bogolo[m];
thalaNtlha(x, y);
}
}
}See also
Section titled “See also”cos, tan, asin, seeloSaSekhutlo, PEDI_PI