// Hi all,
//
// I tried to rotate the house. I didn't know: Is my problem the code or the calculating with COS / SIN in 4GL? Can anybody help me?
//
// Thanks a lot
// Kai
#platform "uLCD-28PTU"
#inherit "4DGL_16bitColours.fnc"
#DATA
byte xPos
120,140,140,140,140,120,120,120,120,140,120,140,120,130,130,140
byte yPos
100,100,100,140,140,140,140,100,140,100,100,140,100, 70,70,100
#END
func main()
var l := 0;
var nDegree := 45;
var x1, x2, y1, y2;
var x1Draw, x2Draw, y1Draw, y2Draw;
var Zoom := 10;
repeat
gfx_Cls();
for (l := 0; l < sizeof(xPos); l += 2)
x1 := xPos[l];
x2 := xPos[l+1];
y1 := yPos[l];
y2 := yPos[l+1];
x1Draw := (x1 * COS(nDegree)) - (y1 * SIN(nDegree)) / 127;
y1Draw := (x1 * SIN(nDegree)) + (y1 * COS(nDegree)) / 127;
x2Draw := (x2 * COS(nDegree)) - (y2 * SIN(nDegree)) / 127;
y2Draw := (x2 * SIN(nDegree)) + (y2 * COS(nDegree)) / 127;
gfx_Line(x1, y1, x2, y2, YELLOW); // Original house
gfx_Line(x1Draw / Zoom, y1Draw / Zoom, x2Draw / Zoom, y2Draw / Zoom, ORANGE); // Rotated house
next
forever
endfunc
//
// I tried to rotate the house. I didn't know: Is my problem the code or the calculating with COS / SIN in 4GL? Can anybody help me?
//
// Thanks a lot
// Kai
#platform "uLCD-28PTU"
#inherit "4DGL_16bitColours.fnc"
#DATA
byte xPos
120,140,140,140,140,120,120,120,120,140,120,140,120,130,130,140
byte yPos
100,100,100,140,140,140,140,100,140,100,100,140,100, 70,70,100
#END
func main()
var l := 0;
var nDegree := 45;
var x1, x2, y1, y2;
var x1Draw, x2Draw, y1Draw, y2Draw;
var Zoom := 10;
repeat
gfx_Cls();
for (l := 0; l < sizeof(xPos); l += 2)
x1 := xPos[l];
x2 := xPos[l+1];
y1 := yPos[l];
y2 := yPos[l+1];
x1Draw := (x1 * COS(nDegree)) - (y1 * SIN(nDegree)) / 127;
y1Draw := (x1 * SIN(nDegree)) + (y1 * COS(nDegree)) / 127;
x2Draw := (x2 * COS(nDegree)) - (y2 * SIN(nDegree)) / 127;
y2Draw := (x2 * SIN(nDegree)) + (y2 * COS(nDegree)) / 127;
gfx_Line(x1, y1, x2, y2, YELLOW); // Original house
gfx_Line(x1Draw / Zoom, y1Draw / Zoom, x2Draw / Zoom, y2Draw / Zoom, ORANGE); // Rotated house
next
forever
endfunc
Comment