Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to find a triangle's area?
- abrakaidabra
-
100+ posts
How to find a triangle's area?
So I'm making a triangle filler and I need to find the area of the triangle to figure out how much the density should be. Can someone help me please? I will credit you in the project and follow you if you do
- RL1123
-
1000+ posts
How to find a triangle's area?
What information are you given to find the area? Do you only know the points of the triangle?
- abrakaidabra
-
100+ posts
How to find a triangle's area?
Just the points, yes What information are you given to find the area? Do you only know the points of the triangle?
- rodper6635
-
100+ posts
How to find a triangle's area?
The area of a triangle is 1/2 * base length * height. To find the base length use
([sqrt v] of ((((x of point 2) - (x of point 1)) * ((x of point 2) - (x of point 1))) + (((y of point 2) - (y of point 1)) * ((y of point 2) - (y of point 1)))::operators)
- rodper6635
-
100+ posts
How to find a triangle's area?
Height is kind of complicated. You take the midpoint of the two points you used in the formula (x of point 1 plus x of point 2, divide that by two, and do the same for the y values) and find the distance between that and the third point using the formula I showed last post.
Last edited by rodper6635 (Nov. 25, 2024 02:39:11)
- abrakaidabra
-
100+ posts
How to find a triangle's area?
But does this work with triangles that aren’t right triangles? The area of a triangle is 1/2 * base length * height. To find the base length use([sqrt v] of ((((x of point 2) - (x of point 1)) * ((x of point 2) - (x of point 1))) + (((y of point 2) - (y of point 1)) * ((y of point 2) - (y of point 1)))::operators)
- abrakaidabra
-
100+ posts
How to find a triangle's area?
Oh wait nvm I see how it worksBut does this work with triangles that aren’t right triangles? The area of a triangle is 1/2 * base length * height. To find the base length use([sqrt v] of ((((x of point 2) - (x of point 1)) * ((x of point 2) - (x of point 1))) + (((y of point 2) - (y of point 1)) * ((y of point 2) - (y of point 1)))::operators)
- abrakaidabra
-
100+ posts
How to find a triangle's area?
I’m confused, could you give me a scratchblocks formula for that Height is kind of complicated. You take the midpoint of the two points you used in the formula (x of point 1 plus x of point 2, divide that by two, and do the same for the y values) and find the distance between that and the third point using the formula I showed last post.
- abrakaidabra
-
100+ posts
How to find a triangle's area?
Why divide by 2? Wouldn’t that be in relation to x zero y zero if your taking the x and y midpoints as positions? Height is kind of complicated. You take the midpoint of the two points you used in the formula (x of point 1 plus x of point 2, divide that by two, and do the same for the y values) and find the distance between that and the third point using the formula I showed last post.
- rodper6635
-
100+ posts
How to find a triangle's area?
I’m confused, could you give me a scratchblocks formula for that Height is kind of complicated. You take the midpoint of the two points you used in the formula (x of point 1 plus x of point 2, divide that by two, and do the same for the y values) and find the distance between that and the third point using the formula I showed last post.
(((point 1 x) + (point 2 x)) / (2))
(((point 1 y) + (point 2 y)) / (2))
- rodper6635
-
100+ posts
How to find a triangle's area?
That's just part of the midpoint formula, btw midpoint is the point between points 1 and 2.Why divide by 2? Wouldn’t that be in relation to x zero y zero if your taking the x and y midpoints as positions? Height is kind of complicated. You take the midpoint of the two points you used in the formula (x of point 1 plus x of point 2, divide that by two, and do the same for the y values) and find the distance between that and the third point using the formula I showed last post.
- rodper6635
-
100+ posts
How to find a triangle's area?
I'm sorry, I just realized the base length formula works with non-right triangles, but not the height formula. To get the height you would need more than just the points' coordinates. Is there any other information about the triangles you have (angles, side lengths, etc)?But does this work with triangles that aren’t right triangles? The area of a triangle is 1/2 * base length * height. To find the base length use([sqrt v] of ((((x of point 2) - (x of point 1)) * ((x of point 2) - (x of point 1))) + (((y of point 2) - (y of point 1)) * ((y of point 2) - (y of point 1)))::operators)
Last edited by rodper6635 (Nov. 25, 2024 03:29:23)
- Scratch-Minion
-
1000+ posts
How to find a triangle's area?
If you have a triangle with vertices (x1,y1), (x2,y2), (x3,y3) then its area is:
Area = 1/2 * Abs( x1(y2 − y3) + x2(y3 − y1) + x3(y1 − y2) )
Area = 1/2 * Abs( x1(y2 − y3) + x2(y3 − y1) + x3(y1 − y2) )
set [Triangle Area v] to (((1) / (2)) * ([abs v] of (((x1) * ((y2) - (y3))) + (((x2) * ((y3) - (y1))) + ((x3) * ((y1) - (y2)))))::operators))
- Kevinxad
-
12 posts
How to find a triangle's area?
just serch heoron's formula to find area given 3 sides. the pythagorean theorem can be used to find the lenghts. another way is by simply finding the fistance from one point to the line connected by the two other points. there are many ways to do this. the one that i have just come up wiht(NOT MOST OPTIMIZED!) is by calcalating the direction of the two points, the slope of it. then have -1 divided by that number which makes a 90 degree angle. then the lenght from the intersection of the 90 degree line and line connecting two points can be found by simply using a y intercept formula like in graphing calcalators, but backwards. so find the graphs of the two lines, and make a code to do the algebra to find the coords where both equations are true. then find the distance of the intersection and other point. another way to to it is by finding the distance between points, the largest difference in x and y. then take those differences and multiply. what you get it the smallest rectangle that fits all 3 points. then, you can add the products of all 3 ways to pair the 3 points, the products of the differences in x and y. then divide by two. then just subtract the rectangle area from the triangles area. I think this is the much better way.
- Kevinxad
-
12 posts
How to find a triangle's area?
the idea is to cut 3 right triangles off a rectangle to get another triangle.
- abrakaidabra
-
100+ posts
How to find a triangle's area?
You can get the side lengths by using the distance formula a^2 + b^2 = c^2, you can get the angles using trigonometry, angle between any two points:I'm sorry, I just realized the base length formula works with non-right triangles, but not the height formula. To get the height you would need more than just the points' coordinates. Is there any other information about the triangles you have (angles, side lengths, etc)?But does this work with triangles that aren’t right triangles? The area of a triangle is 1/2 * base length * height. To find the base length use([sqrt v] of ((((x of point 2) - (x of point 1)) * ((x of point 2) - (x of point 1))) + (((y of point 2) - (y of point 1)) * ((y of point 2) - (y of point 1)))::operators)
((90) - ([acos v] of ([first side] / [second side]))) //ninety minus to convert to scratch units from trig unitsI think.
- Scratch-Minion
-
1000+ posts
How to find a triangle's area?
If you have a triangle with vertices (x1,y1), (x2,y2), (x3,y3) then its area is:
Area = 1/2 * Abs( x1(y2 − y3) + x2(y3 − y1) + x3(y1 − y2) )set [Triangle Area v] to (((1) / (2)) * ([abs v] of (((x1) * ((y2) - (y3))) + (((x2) * ((y3) - (y1))) + ((x3) * ((y1) - (y2)))))::operators))
You could try the formula I gave above.
To see a proof of the formula you could google “triangle area from vertices”
- abrakaidabra
-
100+ posts
How to find a triangle's area?
Yeah, I’ll try that. I think I see how that works.If you have a triangle with vertices (x1,y1), (x2,y2), (x3,y3) then its area is:
Area = 1/2 * Abs( x1(y2 − y3) + x2(y3 − y1) + x3(y1 − y2) )set [Triangle Area v] to (((1) / (2)) * ([abs v] of (((x1) * ((y2) - (y3))) + (((x2) * ((y3) - (y1))) + ((x3) * ((y1) - (y2)))))::operators))
You could try the formula I gave above.
To see a proof of the formula you could google “triangle area from vertices”
- Discussion Forums
- » Help with Scripts
-
» How to find a triangle's area?