import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
l = np.array([])
x = int(input("Input starting x coordinate: "))
y = int(input("Input starting y coordinate: "))
z = int(input("Input starting z coordinate: "))
l = np.array([x, y, z])
x_data = (0, l[0] + 0.00001)
y_data = (0, l[1] + 0.00001)
z_data = (0, l[2] + 0.00001)
print(x_data)
print(y_data)
print(z_data)
ax.set_title("Matrix Rotation")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ac = np.array([l[0], l[1], l[2]])
ax.plot(x_data, y_data, z_data)
plt.show()
while True:
angl = int(input("What angle would you like to rotate it by? "))
answer = input("Would you like to rotate the line around the x, y, or z axis? (Enter 'x', 'y', or 'z') ")
if answer.lower() == "x":
matx = np.array([[1, 0, 0], [0, np.cos(np.degrees(angl)), -np.sin(np.degrees(angl))], [0, np.sin(np.degrees(angl)), np.cos(np.degrees(angl))]])
newcoordinates = np.dot(ac, matx)
print(newcoordinates)
elif answer.lower() == "y":
maty = np.array([[np.cos(np.degrees(angl)), 0, np.sin(np.degrees(angl))], [0, 1, 0], [-np.sin(np.degrees(angl)), 0, np.cos(np.degrees(angl))]])
newcoordinates = np.dot(ac, maty)
elif answer.lower() == "z":
matz = np.array([[np.cos(np.degrees(angl)), -np.sin(np.degrees(angl)), 0], [np.sin(np.degrees(angl)), np.cos(np.degrees(angl)), 0], [0, 0, 1]])
newcoordinates = np.dot(ac, matz)
print(newcoordinates)
else:
print("Invalid input. Please enter 'x', 'y', or 'z'.")
continue
print("Out of if conditional")
x_data = np.array([0, newcoordinates[0] + 0.000001])
y_data = np.array([0, newcoordinates[1] + 0.000001])
z_data = np.array([0, newcoordinates[2] + 0.000001])
ac = np.array([newcoordinates[0], newcoordinates[1], newcoordinates[2]])
ax.clear()
ax.set_title("Matrix Rotation")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ax.plot(x_data, y_data, z_data)
plt.ion()
plt.pause(0.001)
plt.show()
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
l = np.array([])
x = int(input("Input starting x coordinate: "))
y = int(input("Input starting y coordinate: "))
z = int(input("Input starting z coordinate: "))
l = np.array([x, y, z])
x_data = (0, l[0] + 0.00001)
y_data = (0, l[1] + 0.00001)
z_data = (0, l[2] + 0.00001)
print(x_data)
print(y_data)
print(z_data)
ax.set_title("Matrix Rotation")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ac = np.array([l[0], l[1], l[2]])
ax.plot(x_data, y_data, z_data)
plt.show()
while True:
angl = int(input("What angle would you like to rotate it by? "))
answer = input("Would you like to rotate the line around the x, y, or z axis? (Enter 'x', 'y', or 'z') ")
if answer.lower() == "x":
matx = np.array([[1, 0, 0], [0, np.cos(np.degrees(angl)), -np.sin(np.degrees(angl))], [0, np.sin(np.degrees(angl)), np.cos(np.degrees(angl))]])
newcoordinates = np.dot(ac, matx)
print(newcoordinates)
elif answer.lower() == "y":
maty = np.array([[np.cos(np.degrees(angl)), 0, np.sin(np.degrees(angl))], [0, 1, 0], [-np.sin(np.degrees(angl)), 0, np.cos(np.degrees(angl))]])
newcoordinates = np.dot(ac, maty)
elif answer.lower() == "z":
matz = np.array([[np.cos(np.degrees(angl)), -np.sin(np.degrees(angl)), 0], [np.sin(np.degrees(angl)), np.cos(np.degrees(angl)), 0], [0, 0, 1]])
newcoordinates = np.dot(ac, matz)
print(newcoordinates)
else:
print("Invalid input. Please enter 'x', 'y', or 'z'.")
continue
print("Out of if conditional")
x_data = np.array([0, newcoordinates[0] + 0.000001])
y_data = np.array([0, newcoordinates[1] + 0.000001])
z_data = np.array([0, newcoordinates[2] + 0.000001])
ac = np.array([newcoordinates[0], newcoordinates[1], newcoordinates[2]])
ax.clear()
ax.set_title("Matrix Rotation")
ax.set_xlabel("x")
ax.set_ylabel("y")
ax.set_zlabel("z")
ax.plot(x_data, y_data, z_data)
plt.ion()
plt.pause(0.001)
plt.show()