ScratchData LogoScratchData
Back to Geotale's profile

Pretty Fast Triangle Filler

GEGeotale•Created June 21, 2020
Pretty Fast Triangle Filler
74
53
1711 views
View on Scratch

Instructions

Pretty fast but inaccurate + inefficient - Might have to come back and try again eventually :) Comparison between @TheLogFather's and mine, along with some remixes of this project (Compared based on final resolution of triangle, not by resolution variable. A little bit of math was used to calculate this): https://www.desmos.com/calculator/hj5tx6bokl Even if it's not the fastest in the world it might be the fastest in the west lol

Description

I don't feel like people go into an in-depth explanation on the math and stuff of a triangle filler so I'll do that here. -First I calculate the side lengths opposite of the A, B, and C points on the triangle (just the three corners) and name them a, b, and c respectively. I calculate the perimeter (p) by adding up all of the side lengths. -Next off I calculate the incircle, which is where you can fit the largest circle inside of a triangle. I name these points ox and oy. -I can't draw the circle yet, because I don't have its size. To get this I find the area of the triangle and name it A (yes, I know I already names the first points Ax and Ay). The size of the pen (named S, I will be using this variable later) will end up being (4 * A) / p. -Now I simply plot the inner circle of the triangle, then I set a variable l to 0.5. -Finally, I draw the edges by setting the pen size to l * S, then calculating where the triangle should be drawn, with each point being (100 * l)% of the way towards the center (as to not go outside of the triangle boundaries). -Last (and, let's be honest, probably least) I set l to l/2, and repeat the drawing edges process again (res) times or until the pen size is smaller than 0.5. Because l is decreasing the pen size keeps getting smaller, leading to a more accurate triangle.

Project Details

Project ID406665845
CreatedJune 21, 2020
Last ModifiedAugust 3, 2021
SharedJune 22, 2020
Visibilityvisible
CommentsAllowed