Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculation of circles
#11
I added one more circle and seems ok. Just another thing - how I will find length from center of 1. circle (center I have 0,0) to theoretical intersection of other 3 circles? And the angle? In my example is it 8.5mm and 42°.
Just for information - it is about this calculation:
https://www.linkedin.com/pulse/single-pl...eer-irani/
Reply
#12
This code should help you compute distance and angle between two points
from math import dist, atan2, degrees

def clock_angle(point, origin=(0,0)):
    a = degrees(atan2(point[0]-origin[0], point[1]-origin[1]))
    return 360 + a if a < 0 else a

p = (5, 6)
orig = (0, 0)

d = dist(p, orig)
print("The distance from origin is", d)

a = clock_angle(p, orig)
print("The clockwise angle from vertical is", a)
Output:
The distance from origin is 7.810249675906656 The clockwise angle from vertical is 39.80557109226519
Reply
#13
It works well. I have one more question.

How to check if intersection is True or False?

For example:
r1 = 16
r2 = 48
r3 = 16
r4 = 46

In this case I have only one intersection r2+r4.

I want get:
r2+r3 is False
r3 + r4 is False
r4 + r2 is True
And get intersection coordinates and clock_agnle only for True values.

Now I have this error if no intersection:
    y = sqrt(rr**2 - tt**2)
    ValueError: math domain error
Thank you
Reply
#14
I guess you will have to check if rr**2 - tt**2 >= 0 or catch the domain error exception. What is the appropriate corrective action if there is no intersection?
Reply
#15
Yes, I am trying
  if (rr**2 - tt**2) >= 0:
seems ok.

I want to see minimal one intersection - coordinates and lenght from first circle centre to the intersection.
I can see max 3 intersections and minimal 1.

Output something like:
Intersection1:
True
[10,10]
7

Intersection2:
False

Intersection3:
True
[5,8]
4
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to detect irregular circles in python with opencv johansigaran 4 3,761 May-01-2020, 02:07 AM
Last Post: johansigaran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020