Skip to content

Instantly share code, notes, and snippets.

@vixtory09678
Last active January 3, 2018 10:14
Show Gist options
  • Save vixtory09678/d4e5687737d54f8f099c7c4f374fd3e1 to your computer and use it in GitHub Desktop.
Save vixtory09678/d4e5687737d54f8f099c7c4f374fd3e1 to your computer and use it in GitHub Desktop.
draw_triangle.java
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