Last active
January 3, 2018 10:14
-
-
Save vixtory09678/d4e5687737d54f8f099c7c4f374fd3e1 to your computer and use it in GitHub Desktop.
draw_triangle.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void drawTriagle(float sideLength , float xOrigin , float yOrigin){ | |
stroke(0); | |
float sideBx = sideLength / 2.0 * -1; | |
float sideBy = sqrt(pow(sideLength,2) - pow(sideBx,2)); | |
float Bx = xOrigin + sideBx; | |
float By = yOrigin + sideBy; | |
line(xOrigin,yOrigin,Bx,By ); // วาดจากจุด Axy ไปจุด Bxy | |
float sideCx = sideLength / 2.0; | |
float sideCy = sqrt(pow(sideLength,2) - pow(sideCx,2)); | |
float Cx = xOrigin + sideCx; | |
float Cy = yOrigin + sideCy; | |
line(xOrigin,yOrigin,Cx,Cy); // วาดจากจุด Axy ไปจุด Cxy | |
line(Bx, By,Cx, Cy); // วาดจากจุด Bxy ไปที่จุด Cxy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment