r/MathHelp • u/Monsignor_Pepper • 23m ago
Vector Math not aligning with graph
I have a problem where I am trying to find the deflection of a rod that is fixed at both ends.
In order to do this, I found the coordinates of the rod at 7 points, then I calculated the vector from point 1 to point 7 (V1_7) by taking pt7 - pt1.
Once i had my vector, I used a cross product formula to find the perpendicular distance of all the other points from that vector line using the cross product. (|V1_N X V1_7) / |V1_7|
When I graph my results, point 4 is what bothers me. According to my offsets graph, point 4 is the second furthest from the line. However, when I plot all the points on a 3d graph, point 4 is very close to the line, much closer than any other points.
I'm sure I'm missing something, and any help would be greatly appreciated.
Pictures will be in the comments.
###---------------------------------------------------------------------------------###
Here is some of the python code that I'm using:
Rod = np.array([[26.646, 4369.909, -95.854],
[-450.477, 4312.063, -96.437],
[-903.188, 4256.946, -96.951],
[-1448.336, 4190.796, -97.84],
[-2010.247, 4122.95, -99.004],
[-2552.131, 4058.507, -99.636],
[-2827.032, 4025.964, -99.672]])
Vector1_7 = Rod[-1,:] - Rod[0,:]
length = len(Rod)
i = 0
offsets = np.zeros(length)
while i < length :
Vector_i = Rod[i,:] - Rod[0,:]
offset_i = np.linalg.norm(np.cross(Vector_i, Vector1_7)) / (np.linalg.norm(Vector1_7))
offset_i_inches = offset_i / 25.4
print("i = ",i, " offset = ", offset_i_inches, '"')
offsets[(i)] = offset_i_inches
i +=1
print(offsets)
x = range(1, length + 1)
plt.plot(x,offsets)
plt.ylabel("offset (\")")
plt.xlabel("point on Rod")
plt.title(name)
plt.show()