0

I have the normal of a plane and a point lying on it. I am trying to plot both of these out but I don't think this is coming out correctly and I cannot figure out why. Here is my code.

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

point  = np.array([1309.66102863, -531.22959263,  341.89779288])
normal = np.array([ 80.60165306, -32.69394323,  21.04172506])

# a plane is a*x+b*y+c*z+d=0
# [a,b,c] is the normal. Thus, we have to calculate
# d and we're set
d = -point.dot(normal)

# create x,y
xx, yy = np.meshgrid(range(1200,1400), range(-600,-400))

# calculate corresponding z
z = (-normal[0] * xx - normal[1] * yy - d) * 1. /normal[2]

# plot the surface
plt3d = plt.figure().gca(projection='3d')
plt3d.plot_surface(xx, yy, z, alpha=0.2)
plt3d.plot([point[0], point[0]+normal[0]], 
           [point[1], point[1]+normal[1]], 
           [point[2], point[2]+normal[2]])
plt.show()

I modified it from this post. The result that I am getting looks like this -

enter image description here

Clearly the normal is not perpendicular to the plane.

However sometimes it works though, for example when I set

point  = np.array([1, 2, 3])
normal = np.array([1, 1, 2])

The plot that I am getting is

enter image description here

Clearly this is much better. How is it not working in the first case?

Ananda
  • 2,925
  • 5
  • 22
  • 45

1 Answers1

1

It looks weird because of the aspect ratio of the axis.

If you set the range limit for each axis to be 1:1:1 it will look perpendicular.

Here is an example of 1:1 and not 1:1 range limit of the same "angle":

Angle in Different aspect traio

Ernie Yang
  • 114
  • 5