I have a plane defined as an xyz vector and a point that lies on the plane.
I would like to generate xyz coordinates for 4 points (N_points
) on the plane surrounding the defined point (centroid
) at a defined distance/radius (r
).
My current solution only works in 2D. I would like to expand this to work in 3D but my knowledge of geometry is failing me. Any ideas would be much appreciated.
def circlePoints(r, N_points, plane=(1,1,1), centroid=(0,0,0), rotation=0):
(plane_x, plane_y, plane_z) = plane
(centroid_x, centroid_y, centroid_z) = centroid
step = (np.pi*2) / N_points
rot=rotation
i=0
points=[]
for i in xrange(N_points):
x = round(centroid_x + ((np.sin(rot)*r) / plane_x), 2)
y = round(centroid_y + ((np.cos(rot)*r) / plane_y), 2)
z=0 #?
points.append((x,y,z))
rot+=step
return points
print circlePoints(1, 4, [1,2,0], [2,3,1])
print circlePoints(1, 4)