The following is an equilateral triangle: Bisecting ∠ACB splits the triangle into two congruent triangles (and the bisector meets the line AB at its midpoint and forms a right angle!)
if A is (1,0) and B is (5,0) and C is (c,y) and D is (c,0). C has an angle of tan(theta/2). In this case 60 degrees. How would I derive a formula in order to get the following output 3.4641016151377553.
Another example: A (-2,0), B(6,0), theta is: 120 degrees The output is: 2.309401076758504
Output must be in radians (pi/180)
Output is the C coordinate enter image description here
Assuming that the Points A=(a,0)
and B=(b,0)
are on the x-axis and that ABC
is an isosceles triangle with the angle theta
at C
:
Then
D
has the coordinates ((a+b)/2,0)
. And in the right angled triangle ADC
we have tan(theta/2) = (b-a)/2 / h
. Hence we get the y-coordinate of C as h = (b-a)/2/tan(theta/2)
.
Here is the corresponding racket code:
#lang racket
(require math)
(define (half v) (/ v 2))
(define (deg2rad angle_deg) (* angle_deg (/ pi 180)))
(define (cy a b theta) (/ (half (- b a)) (tan (deg2rad (half theta)))))
(cy 1 5 60)
(cy -2 6 120)
giving the output:
3.464101615137755
2.309401076758504