0

I want to draw a circle in the XZ plane. The middlepoint of the circle should be coincide with the green spot. Unfortunately i can´t find a way to draw the circle in the XZ-Plane (only in XY-plane). The center of the circle is (0,0).

Do you have an idea to draw the circle in the XZ-Plane?

That´s the code:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

def singular_value_decomposition(X):
    import numpy as np
    C = np.average(X,axis=0)
    print(C)
    CX = X-C
    U,S,V = np.linalg.svd(CX)
    return C,V

def cloud():
    import numpy as np
    h = 0.5*(1+np.sqrt(5))
    p1 = np.array([[0,1,h],[0,1,-h],[0,-1,-h]])
    p2 = p1[:,[1,2,0]]
    p3 = p1[:,[0,1,2]]
    return np.vstack((p1,p2,p3))

A = cloud()
print(A)
centroid, V = singular_value_decomposition(A)

# calculate a  circle
theta = np.linspace(0, 2*np.pi, 100)
r = np.sqrt(0.5)
x1 = r*np.cos(theta)
x2 = r*np.sin(theta)



# plot graph
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

ax.scatter(centroid[0], centroid[1], centroid[2], color='green',s=100)

#draw circle
ax.plot(x1,x2)

ax.set_xlabel('$X$',fontsize=20)
ax.set_ylabel('$Y$',fontsize=20)
ax.set_zlabel('$Z$', fontsize=20)


plt.show()

0 Answers0