KUVAUS |
Laskee kolmion pinta-alan kärkipisteistä. |
KÄYTTÖ |
TriangleArea(x1, y1, x2, y2, x3, y3) |
x1, y1 = Kolmion ensimmäisen kärkipisteen koordinaatit x2, y2 = Kolmion toisen kärkipisteen koordinaatit x3, y3 = Kolmion kolmannen kärkipisteen koordinaatit |
Katso myös: PointInTriangle
ESIMERKKI |
Include "sdk/include/cbMath.cb" // Arvotaan kolmio x1 = Rand(0, ScreenWidth()) y1 = Rand(0, ScreenHeight()) x2 = Rand(0, ScreenWidth()) y2 = Rand(0, ScreenHeight()) x3 = Rand(0, ScreenWidth()) y3 = Rand(0, ScreenHeight()) Repeat x = MouseX() y = MouseY() If MouseHit(1) Then // Mahdollisuus muuttaa kolmion pisteiden paikkoja If KeyDown(cbKey1) Then x1 = x: y1 = y If KeyDown(cbKey2) Then x2 = x: y2 = y If KeyDown(cbKey3) Then x3 = x: y3 = y EndIf Text 10,10, "Kolmion pinta-ala: " + TriangleArea(x1,y1,x2,y2,x3,y3) Line x1, y1, x2, y2 Line x2, y2, x3, y3 Line x3, y3, x1, y1 DrawScreen Forever |