how to find normal to slanted plane?

I wish to draw a 3d polygon that has 5 sides and 7 faces. 3 sides are equal length and 90 deg between them, 1 side also 90 deg but shorter length, last side is slanted at angle of 57 deg to horizontal so effectively, the whole figure looks like a cube with an edge “chipped off”. Problem is I do not know how to find the normal to the slanted plane… if need, how i copy a figure to here to show better what i mean

okie i think i can find it by using 3 coordinates in the slanted face, find 2 vectors in the slanted plane then do cross-product and get the unit vector, is that right?

have a query, because this 3D polygon has 2 faces that have 5 vertexes each, the rest 4 vertexes/face, that means I have to draw each face out, cannot use any for loop (eg for a cube)?

do you want to draw one polygon with 7 points, or a 3d object that is made up of 7 triangles? it is not clear what you mean… so better post a picture.

If you have a polygon (one polygon = one face) wich has more than three vertices, there are two possibilities:

  • they all lie on one plane, then they would all have the same perpendicular normal vector
  • they do not lie on one plane, then it is in fact not one polygon but should be tesselated to triangles.

once you got triangles, either because you tesselated the polygon to triangles or becaus you really meant a 3d object which is made up of triangles, you can simply compute the normals from the vertex coordinates (although I cannot give you the formula, but there is a simple one, search for it).

Jan

[This message has been edited by JanHH (edited 01-02-2004).]

[This message has been edited by JanHH (edited 01-02-2004).]

When all points have been extracted, calculate the normal by using the crossproduct and then normalize the
vector you get:

N = (p2-p1)X(p3-p1)

N/sqrt(N*N) = Ñ

Whereas p1, p2 and p3 are 3D vectors (points of the triangle, or three arbitrary points on the face/polygon.)

N is the unnormalized normal.
Ñ is the normal you seek.

N*N is the dotproduct of the normal.
sqrt means ‘square root of’

Although beware!
The order of the three points is important because they tell what direction the normal will point. Out or In.

If you treat P1 as point 1 in our rendered triangle, P2 as number 2 and so on, you will get the normal to point out of the front face of the triangle you are rendering using that same order.

So you calculate your normal as you render the triangle in gl, simple enough.

If your normals point the wrong way (out instead of in) just invert it.

Hope that helped.

thanx , i will try that out. I have 7 faces, 5 faces are quads, 2 faces have 5 vertices each. and these faces connect to form a 3D figure…

sounds weird to have faces with 4 or 5 vertices… generally rather pointless. you should tesselate this to triangles and then compute the normals as shown above. problem with faces that have more than 3 vertices is that you cannot really tell what the face looks like, as the points do not all have to lie on one plane in 3d space, so you might get strangely curved surfaces that are not lit correctly. The triangle is the only face that is completely defined by its vertices.

Jan

[This message has been edited by JanHH (edited 01-03-2004).]

Such large polygons with ‘strange’ curvature should be automatically tessalated and and get their normals and even fragment shading interpolated for a generic ‘curve’ of the surface. All you have to do is to give one Convexity vector using glConvexityfv()
… in OpenGL2.0 hopefully

As JanHH said, better tessalate (split) the polygon into triangles, because you will in some angles of view get missing surfaces or see-through artifacts.

i manage to calculate the normal and use it to draw my polygon but as I put it in another post, the colour seem brighter for this polygon compared to another object(cube) although both have same normals for front face.