Centroid Exists Theorem
The Theorem
PlaneGeometry.Theorems.Centroid
โ ModuleThe centroid of a triangle is the point of intersection of its medians (the lines joining each vertex with the midpoint of the opposite side). The Centroids Exists Theorem states that the three medians indeed intersect at single point.
Finding the centroid and medians
PlaneGeometry.Theorems.Centroid.centroid
โ Functioncentroid(๐๏ธ)
Find the centroid and the three medians of ๐๏ธ
.
function centroid(tri)
medians = map(i->median(circshift(vertices(tri), i)...), 0:2)
cpt = concurrent(medians)
cpt, medians
end
Examples
PlaneGeometry.Theorems.Centroid.centroid_draw
โ Methodcentroid_draw(๐๏ธ::Triangle)
Verify Centroid Exists Theorem for the triangle ๐๏ธ
.
A = Point(0,0); B = Point(1, 3); C = Point(4,2)
plt, hold = centroid_draw(A, B, C)
does_thmhold(hold)
Theorem holds! ๐๏ธ
PlaneGeometry.Theorems.Centroid.centroid_rand
โ Methodcentroid_rand()
Verify Centroid Exists Theorem for a random triangle.
plt, hold = centroid_rand()
does_thmhold(hold)
Theorem holds! ๐๏ธ
plt, hold = centroid_rand()
does_thmhold(hold)
Theorem holds! ๐๏ธ
Proof
function centroid_proof()
@vars by cx positive=true;
@vars cy;
A = Point(0, 0); B = Point(0, by); C = Point(cx, cy);
tri = Triangle(A, B, C)
cpt, medians = centroid(tri)
cpt != nothing
end
does_thmhold(centroid_proof())
Theorem holds! ๐๏ธ