简体   繁体   中英

Is One Function/Object Visually Inside Another Function/Object in Plot / Image

I need to use either Python or Matlab , for this problem.

I have the following plot and equations below, which are also available on desmos .

How can I determine whether red circle 1 is in region A or region B ?

Current Approach(es):

  1. use a lot of if statements to figure out where the circle is relative to every region, but this makes for a confusing program that would require a lot of careful recoding if the shapes of the regions change.

  2. generate a set of all points (x,y) that lie in each region and then check whether the points at the boundaries of the circle are are contained in one of those sets. ...but this seems very naive and inefficient.

Note:

The real problem involves more complex shapes created from piecewise functions, but I thought this would be a good starting point.

另一个图像中有一个功能?

import numpy as np

f1 = lambda theta : 3 / np.cos(2/5 * np.arcsin(np.sin(5*2*theta)))
c1 = lambda theta : np.sqrt(0.1)

inside, outside = False, False
for theta in np.linspace(0, 2*np.pi, 100):
    if c1(theta) <= f1(theta):
        inside = True
    if c1(theta) >= f1(theta):
        outside = True

if inside and outside:
    print('intersect')
elif inside:
    print('inside')
else:
    print('outside')

Given a region f1 and a circle c1 , both in polar coordinates. Compute their radius for different theta s, and compare them.

The polar coordinates of a circle can by obtained by solving

在此处输入图片说明

for r

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM