Given the following from the image below:
The green circle has a radius equal to B
The yellow line is tangent to the green circle
The vertical purple line is parallel to the green line and perpendicular to the yellow line.
The yellow line is perpendicular to both the green line and the vertical purple line
The purple point is centered on the green circle's edge
A and B are known values
I realize several of these constraints overlap, just trying to be thorough.
Pythagorean's theorem can provide the value of C, just to illustrate what I know we can determine already.
What is the formula/equation to determine D, where D is the perpendicular distance from the tangent yellow line to the arc/circle (at the purple point)?
Update
Replacing previous attempts to illustrate solution now with one that I can now visualize as the correct representation of the answer and comments provided by John
The distance D can be found by computing the lowest intersection between the vertical ray from the right endpoint of the yellow segment and the circle.
Some notations (x axis to the right, y axis to the bottom, origin at the center of the circle):
center of the circle: P_C = (0, 0)
origin of the vertical ray: P_O = (A, B)
direction of the vertical ray: v_d = (0, -1)
Points on the ray satisfy: P = P_O + t v_d = (A, B - t)
Points on the circle satisfy: |P P_O|^2 = B^2
Expanding the first equation into the second gives: A^2 + (B - t)^2 = B^2 = A^2 + B^2 - 2 B t + t^2
Solving t^2 - 2 B t + A^2 = 0 for t yields d = B^2 - A^2 > 0, so two solutions t_1 = B - sqrt(d), t_2 = B + sqrt(d) (one near the bottom of the circle, the other near the top as expected). But t actually gives the distance along the ray (since v_d is a unit vector), so what we are looking for is the smallest solution t_1. Hence D = B - sqrt(B^2 - A^2).
The final result can also be derived and / or verified geometrically (courtesy of John, see all the corresponding comments): D = B - B' and B'^2 + A^2 = B^2 (Pythagorus on the right triangle with the center of the circle and the purple point as two of its vertices and an edge sitting on the purple line).
As you mentioned C is the easy part. However with A,B,C and the cosine theorem you can work out the angel opposite to B (b):
cos(b) = (a^2 + c^2 -b^2)/(2ac)
knowing b and that A and D have a right angel you can work out the angle between C and D (b'):
b' = 90° - b
given that D lies on the circle you know that the distance from the center to D is B so you now have a triangle with sides B,D and C where you know two of the sides and one of the angles. With the cosine law again:
B^2 = C^2 + D^2 - 2CD cos(b')
so in one more step we can find:
B^2 - C^2 = D^2 - 2CD cos(b') + (C cos(b'))^2 -(C cos(b'))^2 <=>
B^2 - C^2 + (C cos(b'))^2 = (D - C cos(b'))^2 <=>
sqrt(B^2 - C^2 + (C cos(b'))^2) + C cos(b') = D
hope I didn't put stupid mistakes in there and this helps...
Related
I have two points A(x1,y1) & B(x2,y2) and I need to check if point c(x3,y3) falls on the straight line formed by point A & B.
A------C--------------------B then yes C is between A & B
A---------------------------B
C
in second case C isn't between A & B.
Using complex numbers, we define a similarity transformation that maps A to 0 and B to 1:
W = (Z - Za) / (Zb - Za)
Then Wc = (Zc - Za) / (Zb - Za) is a complex number that should have a zero or tiny imaginary value, and a real value between 0 and 1.
Make two vectors
cax = x1 - x3
cay = y1 - y3
cbx = x2 - x3
cby = y2 - y3
and check that angle between them is Pi:
Calculate dot and cross product of these vectors
dot = cax * cbx + cay * cby
cross = cax * cby - cay * cbx
Point C lies on segment AB if cross is zero and dot is negative
dot < 0
abs(cross) < eps
where eps is small value like 1e-6 to compensate floating point calculation errors.
if you are sure that all three point are aligned, you can use the dot product between vectors AC and AB, and the dot product between vectors BA and BC.
Reminder: Vector AB = (xB - xA, yB - yA)
Reminder: dot(AB, AC) = xABxAC + yAByAC
if dot(AB, AC) > 0, then it means C is in direction of B from A
if dot(BA, BC) > 0, then it means C is in direction of A from B
if both conditions above are satisfied, it means C is between A and B
I don't know if this question makes sense, but is there a formulaic way to calculate the height of a chord from a circle's edge in one of the circles from 3 tangent circles?
I have included a diagram to provide detail. Circles C1, C2 and C3 are connected at tangents and have equal radii (in this case 1 mm, but that is only for depiction). Triangle ABC is formed by connecting the centers of these circles. Line LM meets sides AB and AC and is tangential to Circle C1. Line PQ cuts through Circle C1 and triangle ABC and is tangential to both circles C2 and C3.
Diagram for question
What is the formula for the distance (x) between lines LM and PQ?
Given that the radii are equal (say, r), the total height of these 3 circles (line RS shown in diagram, which is my objective to calculate) is 4 times the radius minus the distance (x) between lines LM and PQ. In other words,
|RS| = {(4*r) - x}
variable x needs to be converted into a formula based exclusively on radius r so as to solve this equation.
It has been a while since I revisited my high school geometry lessons, so I hope this can be solved.
Distance A-LM is equal to r (circle center - tangent)
Distance BC-PQ is equal to r
If we add these distances and subtract distance PQ-LM (x), we'll get height of equilateral triangle ABC (with edge 2*r)
r + r - x = height of ABC = 2 * r * sqrt(3)/ 2
x = r * (2 - sqrt(3))
In the picture below I have a triangle. It represents a mechanical arm, where
A = Shoulder (base point of the object)
B = Hand (turret that shoots at the player)
C = Elbow
x = Upper arm (same length as z)
y = Distance between Shoulder and Hand
z = Lower arm (same length as x)
Point B can freely move around point A as long as it doesn't go too far away (pre-determined value). The position of point C should be calculated so that the lines x and z doesn't suffer any changes in length. In other words, point C has to stay a pre-determined distance away from points A and B. How should I calculate this?
First observation (you can't overstretch and you can't touch your shoulder if your under arm is shorter than your upper arm):
| x - z | <= | y | <= | x + z |
Next, it can be calculated with the cosine rule, where you can calculate any angle you want (e.g. angle a = CAB).
From there you can calculate C.
I have a square, for simplicity assume bottom left corner is on origin and width of the square is 1.
A ray divides the square into two parts. I have the coordinates of intersection points. I want to obtain the area that lies right of the vector from p1 to p2:
Right now I have 16 if statements checking every combination of 2 points and calculating the area accordingly. It looks awful. Is there a more clever way of doing this?
Call the points A and B instead of p1 and p2. I'll assume x increases to the right and y increases upward, as per convention.
The point A must have a coordinate (x or y) that is 0 or 1. Rotate the square (really just the two points) to make it x=0.
The point B might be at x=-1, in which case the area is 1-(Ay+By)/2.
Or B might be at y=0, area = 1+(AyBx)/2
Or B might be at y=1, area = (Ay-1)Bx/2
This solution assumes that p1 and p2 form a right-triangle as depicted in the shaded area:
Area to the right of the vector = (w * w) - (0.5 * p1 * p2)
where w is the width of the square, and 0 <= p1 <= w, and 0 <= p2 <= w.
For example if w = 1, p1 = 0.5, and p2 = 0.75
then Area = (1 * 1) - (0.5 * 0.5 * 0.75) = 0.8125
I am trying to find intersecting Points for Circle with help of this link.
The following note describes how to find the intersection point(s) between two circles on a plane, the following notation is used. The aim is to find the two points P3 = (x3, y3) if they exist.
First calculate the distance d between the center of the circles. d = ||P1 - P0||.
If d > r0 + r1 then there are no solutions, the circles are separate.
If d < |r0 - r1| then there are no solutions because one circle is contained within the other.
If d = 0 and r0 = r1 then the circles are coincident and there are an infinite number of solutions.
Considering the two triangles P0P2P3 and P1P2P3 we can write
a2 + h2 = r02 and b2 + h2 = r12
Using d = a + b we can solve for a,
a = (r02 - r12 + d2 ) / (2 d)
It can be readily shown that this reduces to r0 when the two circles touch at one point, ie: d = r0 + r1
Solve for h by substituting a into the first equation, h2 = r02 - a2
So
P2 = P0 + a ( P1 - P0 ) / d
And finally, P3 = (x3,y3) in terms of P0 = (x0,y0), P1 = (x1,y1) and P2 = (x2,y2), is
x3 = x2 +- h ( y1 - y0 ) / d
y3 = y2 -+ h ( x1 - x0 ) / d
http://paulbourke.net/geometry/2circle/
b:=CircleMorph new.
b center: 60#60.
b openInWorld.
b1:=CircleMorph new.
b center: 100#100.
b1 openInWorld.
d:= b1 center - b center. // distance between 2 circles
r1:= (((b center x abs)squared +(b center y abs)squared)sqrt).
r2:= (((b1 center x abs)squared +(b1 center y abs)squared)sqrt).
r3:= r1+ r2.
(d) > (r3) ifTrue:[Transcript show:'Circles are seprate';cr]
When i compare distance with sum of radius of 2 circles is get distance less than radius of both circles which i know is not true,when circles are seprate Am i calculating radius correctly or not idk there is some problem with this help.
One possible solution is this:
| b b1 d r1 r2 r3 |
b := CircleMorph new.
b center: 60#60.
b bounds: (Rectangle origin: 100#40 corner: 40#100).
b openInWorld.
b1 := CircleMorph new.
b center: 100#100.
b bounds: (Rectangle origin: 100#40 corner: 40#100).
b1 openInWorld.
r1 := b bounds width / 2.
r2 := b1 bounds width / 2.
r3 := r1+ r2.
(d < r3)
ifTrue: [| a h mid |
a := (r1 squared - r2 squared + d squared) / (2 * d).
h := (r1 squared - a squared) sqrt.
mid := (b1 center x - b center x) # (b1 center y - b center y).
{(mid x + (h * (b1 center y - b center y))) # (mid y - (h * (b1 center x - b center x))).
(mid x - (h * (b1 center y - b center y))) # (mid y + (h * (b1 center x - b center x)))}]
ifFalse: ['separate']
You'll want to check my arithmetic. (Update: I hadn't used the point between the two circle centres to calculate the points.)