Announcement

Collapse
No announcement yet.

Rotate a 2D/3D house

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ESPsupport
    replied
    Have a look at how this program works, it was put on the forum years ago, but I think it is similar to what you are trying to do, except it works in 3D

    Touch at the centre of any of the 4 edges of the screen to rotate in a different direction
    Attached Files

    Leave a comment:


  • BlackMizi
    replied
    Hi Kayven,

    I know this thread. And the calculation with the "\ 127" part is the same in my sample. It doesn't work. :-(

    Best Regards
    Kai

    Leave a comment:


  • kayven@4d
    replied
    Hi Kai,


    I finally found out the same forum thread discussion to your concern,
    if you have not seen it yet, please check the thread can be found here: COS and SIN functions don't seem to work


    Best regards,
    Kayven

    Leave a comment:


  • BlackMizi
    replied
    Hi,

    I need to calculate the rotation, because the shown data are only a sample. My original data set it's very big.

    May be a calcutalion via gfx_Orbit(angle, distance); is possible, but I have problems with the usage of this rotaton function.

    Greetings
    Kai

    Leave a comment:


  • kayven@4d
    replied
    Hi,

    Thank you for sharing your code.

    Unfortunately, the functions of Cosine () and Sine () are not recommended to use what you want to do because there are no float types available in the Picaso processor.

    Floats are important for calculations.



    Another option is, you can use a look-up record of coordinates for drawing lines.


    Best regards,
    Kayven

    Leave a comment:


  • BlackMizi
    started a topic Rotate a 2D/3D house

    Rotate a 2D/3D house

    // 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
Working...
X