Discuss Scratch

Arzenist
Scratcher
98 posts

Center and Incircle formula not working

I used text book formulas and verified it on calculators, it doesn’t work

https://scratch.mit.edu/projects/732151758/
skywalker858347
Scratcher
100+ posts

Center and Incircle formula not working

bump
mlcreater
Scratcher
1000+ posts

Center and Incircle formula not working

Arzenist wrote:

I used text book formulas and verified it on calculators, it doesn’t work

https://scratch.mit.edu/projects/732151758/
Your script finds the centroid of a triangle, which is the intersection of the three line segments with one end at a vertex and the other end at the midpoint of the opposite side, and is also the center of mass of a physical triangle.

You need to find the incenter, which is the center of the incircle (the circle tangent to every side), and is also the intersection of the three rays that bisect the interior angles of a triangle:
setxtoA*x3+B*x1+C*x2/S*2setytoA*y3+B*y1+C*y2/S*2

The centroid and incenter of a triangle are only the same point when the triangle is equilateral.

Also, “set pen size” sets the pen diameter, which is twice the radius, so once you are at the incenter you need to
setpensizetoRad*2pendownpenup
Arzenist
Scratcher
98 posts

Center and Incircle formula not working

mlcreater wrote:

Arzenist wrote:

I used text book formulas and verified it on calculators, it doesn’t work

https://scratch.mit.edu/projects/732151758/
Your script finds the centroid of a triangle, which is the intersection of the three line segments with one end at a vertex and the other end at the midpoint of the opposite side, and is also the center of mass of a physical triangle.

You need to find the incenter, which is the center of the incircle (the circle tangent to every side), and is also the intersection of the three rays that bisect the interior angles of a triangle:
setxtoA*x3+B*x1+C*x2/S*2setytoA*y3+B*y1+C*y2/S*2

The centroid and incenter of a triangle are only the same point when the triangle is equilateral.

Also, “set pen size” sets the pen diameter, which is twice the radius, so once you are at the incenter you need to
setpensizetoRad*2pendownpenup

Ah thanks
Arzenist
Scratcher
98 posts

Center and Incircle formula not working

Arzenist wrote:

mlcreater wrote:

Arzenist wrote:

I used text book formulas and verified it on calculators, it doesn’t work

https://scratch.mit.edu/projects/732151758/
Your script finds the centroid of a triangle, which is the intersection of the three line segments with one end at a vertex and the other end at the midpoint of the opposite side, and is also the center of mass of a physical triangle.

You need to find the incenter, which is the center of the incircle (the circle tangent to every side), and is also the intersection of the three rays that bisect the interior angles of a triangle:
setxtoA*x3+B*x1+C*x2/S*2setytoA*y3+B*y1+C*y2/S*2

The centroid and incenter of a triangle are only the same point when the triangle is equilateral.

Also, “set pen size” sets the pen diameter, which is twice the radius, so once you are at the incenter you need to
setpensizetoRad*2pendownpenup

Ah thanks

https://turbowarp.org/733119336 not sure why the new formula is not working, it’s better but it messes up with offset, im pretty sure it’s right so I don’t know what I did wrong

Last edited by Arzenist (Sept. 16, 2022 23:18:42)

mlcreater
Scratcher
1000+ posts

Center and Incircle formula not working

Right now it looks like the problem is with the order of the points in the x and y formulas.
A is the distance between 1 and 2, so it must be A * x/y pos of P3
B is the distance between 2 and 3, so it must be B * x/y pos of P1
C is the distance between 3 and 1, so it must be C * x/y pos of P2
Xubse
Scratcher
7 posts

Center and Incircle formula not working

Hi, looking at this, what does S mean?
mlcreater
Scratcher
1000+ posts

Center and Incircle formula not working

Xubse wrote:

Hi, looking at this, what does S mean?
S is the semi-perimeter of the triangle, which is half of the sum of the side lengths.
It seems I assumed that @Arzenist would understand this because their project set a variable S to this quantity.
A, B, and C were the distances between points 1 and 2, between points 2 and 3, and between points 3 and 1, respectively.
S*2 = A+B+C
Xubse
Scratcher
7 posts

Center and Incircle formula not working

mlcreater wrote:

Xubse wrote:

Hi, looking at this, what does S mean?
S is the semi-perimeter of the triangle, which is half of the sum of the side lengths.
It seems I assumed that @Arzenist would understand this because their project set a variable S to this quantity.
A, B, and C were the distances between points 1 and 2, between points 2 and 3, and between points 3 and 1, respectively.
S*2 = A+B+C
It seems to just go to the corner, am i dumb?
———————————————————–
https://scratch.mit.edu/projects/886648512/
go inside and run draw frame

Last edited by Xubse (Sept. 8, 2023 09:21:11)

Xubse
Scratcher
7 posts

Center and Incircle formula not working

Last edited by Xubse (Sept. 8, 2023 09:23:38)

Powered by DjangoBB