def pic_in_circle(center_x, center_y, radius, snapshots_number):
'''
:param center_x: X coordinates of the center of the bbox
:param center_y: Y coordinates of the center of the bbox
:param radius: distance between corners and center of the bbox
:param snapshots_number: number of markers to create
:return: df containing X and Y coordinates of selected points with lenght based on number of snapshots
'''
arr=[]
for i in range(360):
x = center_x + radius*math.cos(i)
y = center_y + radius*math.sin(i)
#Create array with all the x-co and y-co of the circle
arr.append([x,y])
df = pd.DataFrame(arr)
df.columns = ['X', 'Y']
indexes = np.arange(0, len(df), step=(360/snapshots_number))
df = df.iloc[indexes]
return df
circle = pic_in_circle(center.position[0], center.position[1], radius, 50)
with center of the Bbox containing ref model is Vector([4.521869862724644, 50.6898008733669, 4.897874583534293]) X Y 0 38.008388 -199.830643 7 30.059443 -178.610007 14 10.125042 -167.834073 |
for index, row in circle.iterrows():
pos = Metashape.Vector((row['X'], row['Y'], 0))
circleM = ref_model.addMarker()
circleM.label = "circle " + str(index + 1)
circleM.reference.location = ref_model.crs.project(ref_model.transform.matrix.mulp(pos))
circleM.reference.enabled = True
print(circleM.reference.location)
Vector([4.521858890254145, 50.68958594593813, 6.024067006404548]) Vector([4.5218386528562995, 50.68962537116644, 18.59051823922667]) Vector([4.521751947695833, 50.68971443077309, 25.186119392769566]) |
circleM.reference.location = ref_model.crs.project(ref_model.transform.matrix.mulp(pos))