Jump to content

Any formula for height of triangle?


DNGunpla
 Share

Recommended Posts

I am working on a game that requires me to find the height of the triangle and draw the line for it from whichever base I click on.

But so far, I have been encountering this issue.

This is the code I am using to get the height of of triangle.
 

Quote

triangleformula: function(x1,x2,y1,y2,l1){

        midx = (x1 + x2)/2;

        midy = (y2 - y1)/2 + y1;

      
        linetest = this.game.add.graphics(0, 0);
        linetest.lineStyle(3, 0x000000);
        linetest.moveTo(l1.x+2, midy);
        linetest.lineTo(l1.x+2, l1.y);
    }


It is based on using the coordinates of 2 points.

Anyway to resolve this?

 

Sample_Height of Triangle.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...