cos
→ cos()Returns the cosine of an angle — a number that swings between -1 and 1.
cos(sekhutlo)cos is a wave just like sin, but it starts somewhere else: cos(0) is 1, where sin(0) is 0. It is the same wave, shifted by a quarter turn.
That is why the two are used together to build a circle: cos gives x, and sin gives y.
cos is also reached for when you want a number that begins high and eases down — something opening, or fading out.
By default the angle is read in radians; seeloSaSekhutlo(DEGREES) changes that.
The name is left as it stands, for the same reason as sin: it is notation taught in English in a Botswana classroom.
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(20, 24, 32);
tlogelaMothalo();
metlha dintlha = 48;
gopheta (diri i = 0; i < dintlha; i = i + 1) {
// Go dikologa go go feletseng ke PEDI_PI diradiane
metlha sekhutlo = selekanyo(i, 0, dintlha) * PEDI_PI;
metlha x = 200 + cos(sekhutlo) * 140;
metlha y = 200 + sin(sekhutlo) * 140;
tlatsaMmala(lekanyetsa(cos(sekhutlo), -1, 1, 60, 250), 160, lekanyetsa(sin(sekhutlo), -1, 1, 250, 60));
thalaSediko(x, y, 20);
}
}tiro setaLoeto() {
thalaKanefase(400, 400);
bokamorago(244);
boketeMothalo(3);
// cos e simolola kwa godimo — cos(0) ke 1
mothaloMmala(220, 120, 70);
gopheta (diri x = 0; x < 400; x = x + 2) {
thalaNtlha(x, 200 - cos(x * 0.025) * 110);
}
// sin e simolola fa gare — sin(0) ke 0
mothaloMmala(60, 130, 210);
gopheta (diri x = 0; x < 400; x = x + 2) {
thalaNtlha(x, 200 - sin(x * 0.025) * 110);
}
}See also
Section titled “See also”sin, tan, acos, seeloSaSekhutlo, PEDI_PI