Loading commands, almost done…
Here we use autograd to connect two theorems - one from geometry and one from calculus:
We use them to show that the gradient of an angle of a triangle always points towards its circumcenter.
Let's demonstrate this by creating a triangle and computing the gradient of one of its angles:
Setting up the triangle:
t = \triangle a b c\highlight a - this is the vertex whose angle we'll optimize\param a - this tells the system that point a is trainableComputing and backpropagating the loss:
loss = \angle b a c - this calculates the angle ∠bacWhen you backpropagate, you'll see the gradient vector appear at point a.
\backprop loss - computes the gradient of the loss with respect to point a This gradient points in the direction that would increase the angle ∠bac the fastest. According to the orthogonality property, this gradient is perpendicular to the level curves of the angle function - meaning if you move point a along a curve where the angle stays constant, the gradient will be perpendicular to that curve.
Since the level curve of the angle is the circumcircle of the triangle, it means that the gradient is parallel to the line joining the circumcenter to the point a.
p = \circumcenter tr = \distance p a\line p aRun the \gradient-of-an-angle command in the geomatic editor to see this in action. You can also manually run each step to understand the process better.