Projection
Projection
import numpy as np
import math
class Point3D:
self.x = x
self.y = y
self.z = z
self.w = w
def to_homogeneous(self):
class Shape:
self.points = points
self.edges = edges
@staticmethod
Point3D(0, 0, 0),
Point3D(w, 0, 0),
Point3D(w, w, 0),
Point3D(0, w, 0),
Point3D(0, 0, w),
Point3D(w, 0, w),
Point3D(w, w, w),
Point3D(0, w, w),
edges = [
@staticmethod
points = [
Point3D(0, 0, 0),
Point3D(w, 0, 0),
Point3D(w, w, 0),
Point3D(0, w, 0),
Point3D(w / 2, w / 2, w),
]
edges = [
class ProjectionTransformer:
@staticmethod
return np.array([
[1, 0, -a / c, 0],
[0, 1, -b / c, 0],
[0, 0, 0, 0],
[0, 0, -1 / c, 1]
], dtype=float)
@staticmethod
return np.array([
[1, 0, a, 0],
[0, 1, b, 0],
[0, 0, c, 0],
[0, 0, 0, 1]
], dtype=float)
@staticmethod
return np.array([
[0, 0, 0, 0],
[0, 0, 0, 1]
], dtype=float)
class Visualizer:
self.width = width
self.height = height
plt.figure(figsize=(10, 10))
plt.title(title)
start = transformed_points[start_idx]
end = transformed_points[end_idx]
plt.axis('equal')
plt.grid(True)
plt.show()
class ProjectionApp:
def __init__(self):
self.transformer = ProjectionTransformer()
self.visualizer = Visualizer()
self.width = 100 # Default shape width
transformed_points = []
homogeneous_point = point.to_homogeneous()
transformed_points.append(Point3D(
transformed_point[0] / transformed_point[3],
transformed_point[1] / transformed_point[3],
transformed_point[2] / transformed_point[3]
))
return transformed_points
def run(self):
while True:
print("7. Exit")
if choice == '7':
break
shape_type = input("Select shape (1-Cube, 2-Pyramid): ")
projection = self.transformer.perspective(a, b, c)
projection = self.transformer.parallel(a, b, c)
projection = self.transformer.oblique(f, q)
else:
continue
if __name__ == "__main__":
app = ProjectionApp()
app.run()
OUTPUT: