https://en.wikipedia.org/wiki/Incircle_and_excircles
Last active
April 6, 2024 21:35
-
-
Save uwezi/1708d40356922744e4e8fc8dba54f0a9 to your computer and use it in GitHub Desktop.
[inner and outer circle] Showing the inner and outer circle of a triangle. #manim #geometry #triangle #circle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class inoutcircleTriangle(Scene): | |
def construct(self): | |
triangle = VMobject() | |
incirc = VMobject() | |
outcirc = VMobject() | |
for i in range(5): | |
A = np.array([np.random.uniform(-5,5),np.random.uniform(-3,3),0]) | |
B = np.array([np.random.uniform(-5,5),np.random.uniform(-3,3),0]) | |
C = np.array([np.random.uniform(-5,5),np.random.uniform(-3,3),0]) | |
a = np.linalg.norm(B-C) | |
b = np.linalg.norm(A-C) | |
c = np.linalg.norm(A-B) | |
s = (a+b+c)/2 | |
I = (a*A + b*B +c*C)/(a+b+c) | |
r = np.sqrt(((s-a)*(s-b)*(s-c))/s) | |
ocenter = (a**2*(b**2+c**2-a**2)*A + b**2*(c**2+a**2-b**2)*B + c**2*(a**2+b**2-c**2)*C)/(a**2*(b**2+c**2-a**2) + b**2*(c**2+a**2-b**2) + c**2*(a**2+b**2-c**2)) | |
oradius = np.linalg.norm(A-ocenter) | |
self.play(Transform(triangle, Polygon(A,B,C))) | |
self.play(Transform(incirc, Circle(radius=r,color=RED).move_to(I))) | |
self.play(Transform(outcirc, Circle(radius=oradius,color=YELLOW).move_to(ocenter))) | |
self.wait() | |
# https://en.wikipedia.org/wiki/Incircle_and_excircles | |
# https://en.wikipedia.org/wiki/Circumcircle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment