By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,354 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

normal vector?

P: 4
I'm having issues determining the normal vector of a plane in a specfic point on it. Let's say I have the 3 points of a plane, and the point inside the plane where I need the vector. I need to know how to do this on python without the use of any modules, pure python. Thanks!!
May 1 '11 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 2.5K+
P: 2,851
You will need a point/vector object class which can easily be written in Python. Having 3 points, p1, p2 and p3, the normal vector Nv of a plane is the cross product of the vectors p1->p2 and p1->p3. The unit vector would be:
Expand|Select|Wrap|Line Numbers
  1. m = magnitude(Nv)
  2. Point(Nv.x/m, Nv.y/m, Nv.z/m)
So the plane is now defined as a point (p1) and a unit vector. How do you know the 4th point lies on the plane?

The cross product of 2 vectors (p1 and p2):
Expand|Select|Wrap|Line Numbers
  1. def cross_product(p1, p2):
  2.     '''Return the cross product of two Point object vectors. The cross product
  3.     of two vectors is a vector perpendicular to the two vectors. For
  4.     example, in an orthonormal basis, the cross product of a vector along
  5.     the X axis and a vector along the Y axis returns a vector along the Z
  6.     axis.'''
  7.     return Point(p1.y*p2.z - p1.z*p2.y,
  8.                  p1.z*p2.x - p1.x*p2.z,
  9.                  p1.x*p2.y - p1.y*p2.x)
May 4 '11 #2

P: 4
i know the 4th point lies on the plane because the plane is intersected by a line,that 4th point is the intersection of the line and the plane, thanks for the answer, i'm actually trying that right now
May 4 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.