Assignment 1
Assignment 1
Introduction
Ax2+2Hxy+By2+2Gx+2Fy+C= 0
Purpose:
Code:
import numpy as np
import matplotlib.pyplot as plt
from sympy import symbols, Eq, solve, cos, sin
import tkinter as tk
from tkinter import messagebox
rotation_rad = np.deg2rad(rotation_deg)
if verify_straight_lines(A, B, H, G, F, C):
initial_lines = extract_lines(A, H, B, G, F, C)
plt.show()
else:
messagebox.showinfo("Result", "The input does not correspond to a pair of straight lines.")
except ValueError:
messagebox.showerror("Error", "Invalid input. Please provide valid numeric values.")
# GUI configuration
root = tk.Tk()
root.title("Straight Line Pair Transformation")
tk.Label(root, text="Equation Coefficients for Ax^2 + 2Hxy + By^2 + 2Gx + 2Fy + C = 0").grid(row=0,
columnspan=2)
tk.Label(root, text="A: ").grid(row=1, column=0)
entry_A = tk.Entry(root)
entry_A.grid(row=1, column=1)
root.mainloop()
Mathematical Concepts
Δ=A.B⋅C+2GHF−AF2−BG2−CH2=0
2. Equation Transformation
x′=x−shiftx, y′=y−shifty
x′=xcosθ+ysinθ, y′=xsinθ-ycosθ
Graphical Visualization
visualization:
Conclusion
This task provided insights into the mathematical and programming aspects of 2D geometry.
Study of Direction Ratios, Planes, and Straight Lines
Introduction
This task involves analyzing the relationship between planes and straight lines in 3D space. The
objectives are:
1. Input the equation of a plane (normal vector) and a straight line (direction vector and a
point on the line).
2. Visualizing the plane and the straight line in 3D space.
3. Computing the direction ratios of the line.
4. Determining and visualize relationships such as intersection, parallelism, or angle
between the plane and line.
Input the normal vector for the plane and direction vector for the line.
Compute the equation of the plane and generate the line points.
Visualize both the plane and the line in a 3D plot.
Code:
# Plotting
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x_vals, y_vals, z_vals, color='cyan', alpha=0.6)
# Line calculation
line_points = np.array([point_on_line + t * direction_vector for t in np.linspace(-10, 10, 200)])
print(f"Line Coordinates: {line_points}") # Debugging output
ax.plot(line_points[:, 0], line_points[:, 1], line_points[:, 2], color='magenta')
# Labels
ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis')
ax.set_zlabel('Z Axis')
plt.show()
# GUI Setup
window = tk.Tk()
window.title("3D Plane and Line Plotter")
window.mainloop()
Mathematical Concepts
n⋅d
𝐜𝐨𝐬θ =
∣n∣∣d∣
Graphical Visualization
The Matplotlib 3D toolkit is used to plot the plane and the line.
Visualization:
Results and Observations
Initial Input:
o Plane normal vector: (nx, ny, nz) = (1, 2, −1)
o Line direction vector: (dx, dy, dz) = (3, −1, 2)
o Point on line: (px, py, pz) = (2, 1, −1)
Outputs:
o Direction Ratios: dx = 3, dy = −1, dz = 2
o Plane equation:
x + 2y - z - 1 = 0
Conclusion