Discuss Scratch

abrakaidabra
Scratcher
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
Scratcher
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
Scratcher
100+ posts

How to find a triangle's area?

RL1123 wrote:

What information are you given to find the area? Do you only know the points of the triangle?
Just the points, yes
rodper6635
Scratcher
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
Scratcher
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
Scratcher
100+ posts

How to find a triangle's area?

rodper6635 wrote:

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)
But does this work with triangles that aren’t right triangles?
abrakaidabra
Scratcher
100+ posts

How to find a triangle's area?

abrakaidabra wrote:

rodper6635 wrote:

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)
But does this work with triangles that aren’t right triangles?
Oh wait nvm I see how it works
abrakaidabra
Scratcher
100+ posts

How to find a triangle's area?

rodper6635 wrote:

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.
I’m confused, could you give me a scratchblocks formula for that
abrakaidabra
Scratcher
100+ posts

How to find a triangle's area?

rodper6635 wrote:

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.
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?
rodper6635
Scratcher
100+ posts

How to find a triangle's area?

abrakaidabra wrote:

rodper6635 wrote:

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.
I’m confused, could you give me a scratchblocks formula for that
(((point 1 x) + (point 2 x)) / (2))
(((point 1 y) + (point 2 y)) / (2))
rodper6635
Scratcher
100+ posts

How to find a triangle's area?

abrakaidabra wrote:

rodper6635 wrote:

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.
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?
That's just part of the midpoint formula, btw midpoint is the point between points 1 and 2.
rodper6635
Scratcher
100+ posts

How to find a triangle's area?

abrakaidabra wrote:

rodper6635 wrote:

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)
But does this work with triangles that aren’t right triangles?
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)?

Last edited by rodper6635 (Nov. 25, 2024 03:29:23)

Scratch-Minion
Scratcher
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))
Kevinxad
Scratcher
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
Scratcher
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
Scratcher
100+ posts

How to find a triangle's area?

rodper6635 wrote:

abrakaidabra wrote:

rodper6635 wrote:

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)
But does this work with triangles that aren’t right triangles?
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)?
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:
((90) - ([acos v] of ([first side] / [second side]))) //ninety minus to convert to scratch units from trig units
I think.
abrakaidabra
Scratcher
100+ posts

How to find a triangle's area?

Bump
Scratch-Minion
Scratcher
1000+ posts

How to find a triangle's area?

Scratch-Minion wrote:

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
Scratcher
100+ posts

How to find a triangle's area?

Scratch-Minion wrote:

Scratch-Minion wrote:

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”
Yeah, I’ll try that. I think I see how that works.

Powered by DjangoBB