Calculation of the total internal angle of the triangle in Matllab

in #steemiteducation7 years ago (edited)

Introduction

Hello friends, in this opportunity, I want to share a little, a story I did to check a mathematical theorist well known by those who are familiar with geometry:
The sum of the interior angles of a triangle total 180 °

While it is true that it is a mathematical theorem that has a demonstration, I was struck by the fact that it has a geometric demonstration as simple as just having to draw any triangle and with a ferry instrument measure its internal angles and add them to note that without To import which triangle you draw, you will see that the total sum is 180 °.

So I thought about putting this demonstration to the test by drawing as many triangles as possible to measure its internal angles, add them and verify that in effect, the total sum of its angles is 180 degrees, however I do not think it would be very practical since that would depend on the number of triangles you can draw. So I decided to do it in another way and I thought I could make a script in MATLAB that "draw" the triangles, make the measurements of the angles and add them to verify that in each case their sum is 180 ° or not.

The theoretical support in this case is the cosine theorem, which is a generalization of the páramos theorem and the one used to find the sides of a triangle when the two adjacent sides are known and the angle formed by knowing the value of the triangle. 3 sides that form the triangle.

Methodology

  • Establish a series of random lengths (3 for each triangle). To do this, I defined three pairs of random points that would act as coordinates for the vertices of the triangle.

  • Defined these points, I calculated the distances between them through the following expression

Where the terms within the square root are the coordinates of the vertices of the triangle, defined in the previous step.

  • Calculated the sides of each triangle, I used the cosine theorem to calculate the internal angles of each triangle defined in step 1. The equation that relates the unknown angle with the sides of the triangle:

Where a, b and c are the sides of the triangle and is the angle to calculate.

  • After having calculated each angle, I added the angles obtained in step 2. and verified if for each triangle, its sum is effectively 180 °.

The script that I wrote in Matlab was the following:

o=0; f=0; for i=1:1000 %Puntos del triangulo definidos aleatoriamente p1=10rand(1,2); p2=10rand(1,2); p3=10rand(1,2); % Distancia entre los puntos d12=p2-p1; d23=p2-p3; d13=p3-p1; % Modulo de la distancia entre los puntos a=sqrt(sum(d12.^2)); b=sqrt(sum(d23.^2)); c=sqrt(sum(d13.^2)); % Angulo "A" an1=acos(((a)^2+(b)^2-(c)^2)/(2ab)); % Angulo "B" an2=acos(((c)^2+(b)^2-(a)^2)/(2cb)); % Angulo "C" an3=acos(((a)^2+(c)^2-(b)^2)/(2a*c)); suma=radtodeg(an1+an2+an3); suma=round(real(suma)); if suma==180 o=o+1; else f=f+1; end end disp('Hay una cantidad de aciertos de'), disp(o) disp('Hay una cantidad de fallos de'), disp(f)

As you can see, the script is designed so that when you finish calculating the angle, make a record of the times in which the sum was 180 (saved in the variable "o" and other records in case the sum was different from 180 (saved in the variable "f").

Results

I performed simulation 10, increasing the number of triangles in the "i" index of the for command on each occasion. The variations in the index were the following: 10, 50, 100, 1000 and 10000.

10 Triangles

50 Triangles

100 Triangles

1000 Triangles

10000 Triangles

Conclusion


In total, 33480 angles of a total of 11160 simulated triangles were calculated. Additionally, to each of these 11160 triangles the total sum of the internal angles was obtained, obtaining in each case a value of 180 °. Based on the above, it is possible to verify that the theorem mentioned at the beginning of the publication is fulfilled.

Sources:

All the images shown in the post were made by me using the paint tool

[1]
[2]
[3]

Sort:  

Congratulations @williamsq! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

Award for the number of posts published

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!