## Using surface normals with on a triangulated surface

### Using surface normals with on a triangulated surface

Quote:> i have got a bunch of triangles with their normals that describe a
> surface. Now i want to raytrace them as smooth_triangles in povray with
> surface normals at each corner. What is the best way to calculate these
> normals ? My algorithm already adds the normal of each triangle to each
> corner.
> But , is it better to make to the vectorlength proportional to
> the area of the triangle that the normal came from before adding? Or
> should i add all vectors with a normalized length 1.
> i want to make a triangulated sphere look like a sphere. But it seems,
> that both methods arent suitable.

I think you need more points. Try this, Without giving normal
information, use triangle {} statement to produce the sphere.
[Let PovRay do the work of normals for you.]
If the sphere output is worse than what you want, consider
having more points to approximate the sphere. Once you are
near to what you want, Switch to giving the calculated
normal information to PovRay.

If your calculation of the normal is correct(I mean the
addition of the normals of the triangles incident on a vertex)
and number of points are good enough, Normalized length 1
should suffice to give a good sphere.

Hope this Helps,
--Piyush

### Using surface normals with on a triangulated surface

Quote:

> > I think you need more points. Try this, Without giving normal
> > information, use triangle {} statement to produce the sphere.
> > [Let PovRay do the work of normals for you.]

> Well, POVRAY cant do the normals. The standard normal of a triangle is
> perpendicular to the triangle. I think you want me to calculate more
> triangles to describe the surface better.

Yes, I meant that. And I still think, you should once try the
standard normals if you haven't...(:-)[They are the safest ones to rely]

Quote:> I already got a huge number of triangles to describe the surface of a
> molecule. Calculating more triangles would dramatically increase the
> time and RAM needed.

Of course. But if you are not getting what you want, you got to
go to finer approximation. That was the intention when I said that.
But now I think you probably dont have that problem.

Quote:> And thats exactly the wrong way. i want to use smooth_triangles with
> separate normals for each corner, so that the surface looks better with
> _fewer_ triangles.

Yes, smooth_triangles are better than triangle_. But if you are supplying
wrong normal information, it lets you catch the error.

Quote:> > If the sphere output is worse than what you want, consider
> > having more points to approximate the sphere. Once you are
> > near to what you want, Switch to giving the calculated
> > normal information to PovRay.

> And thats the problem. What is the best way to combine the normals of
> each triangle?

Quote:> > If your calculation of the normal is correct(I mean the
> > addition of the normals of the triangles incident on a vertex)
> > and number of points are good enough, Normalized length 1
> > should suffice to give a good sphere.

> The optimum is: fewer triangles, optimal normals.

You are perfectly right.

Quote:> BTW the look generated with smooth_triangles is (almost) independent
> from the number of triangles used.

Initially, I mean with very less points, the smooth_triangles will have
a different look when you increase the number of points. At the optimum
level, increasing points does not help. If you are finding the look
independent of the number of triangles, you have the right number of points
I suppose.

Quote:> i used the vector from the
> nearest atom to the corner of a triangle. That looked very good, but now
> i got smooth transitions between atoms, just like blobs. And this method
> doesnt work here.

How's your atom described? Is it that you are using a polygonal mesh with
Initially you said,

Quote:> i have got a bunch of triangles with their normals that describe a
> surface.

Then you say you take normals to nearest atoms and corner of triangle.
And then you say your heuristic doen't work. Dont have any idea how

There are some examples of rendering spheres(Two and three spheres merging
into one) in the POVRAY help. You can have a look if you haven't.
I dont have a clear picture of what you are trying to do to comment. (:

Regards,
--Piyush

### Using surface normals with on a triangulated surface

> i have got a bunch of triangles with their normals that describe a
> surface. Now i want to raytrace them as smooth_triangles in povray with
> surface normals at each corner. What is the best way to calculate these
> normals ? My algorithm already adds the normal of each triangle to each
> corner.
> But , is it better to make to the vectorlength proportional to
> the area of the triangle that the normal came from before adding? Or
> should i add all vectors with a normalized length 1.

If I understand you correctly, this is an interesting general question. The
simplest method is to take all surface normals of all polygons which share a
particular vertex, add them up, then renormalize, so giving a vertex normal.
Glassner describes this technique in Graphics Gems. However, as pointed out in
"Computing Vertex Normals from Polygonal Facets" (abstract at
http://www.acm.org/jgt/papers/ThurmerWuthrich98/), the answer changes if a
polygon is triangulated (i.e. a single polygon can turn into more than one
triangle, and then each of these triangles [all of which have the same surface
normal] adds into the averaged normal). The article gives a clever solution,
which is to weight each contributing polygon's normal by the angle at the
polygon's vertex - tessellation of the polygon will not change this weighting
factor, it will merely distribute it among the triangles created.

Weighting each polygon's contribution by its amount of angle at the vertex has a
sense to it, but I've heard there might be a better solution (sorry, I don't know
more than this at this time).

Eric

### Using surface normals with on a triangulated surface

Hi Eric,

This seems to be a good idea to use angle of the polygon
at a vertex to weigh the normal. I'm hearing this one for
the first time. Dont know how good the results are going
to be. My be Hewitt can tell us.

Regards,
--Piyush

> > i have got a bunch of triangles with their normals that describe a
> > surface. Now i want to raytrace them as smooth_triangles in povray with
> > surface normals at each corner. What is the best way to calculate these
> > normals ? My algorithm already adds the normal of each triangle to each
> > corner.
> > But , is it better to make to the vectorlength proportional to
> > the area of the triangle that the normal came from before adding? Or
> > should i add all vectors with a normalized length 1.

> If I understand you correctly, this is an interesting general question. The
> simplest method is to take all surface normals of all polygons which share a
> particular vertex, add them up, then renormalize, so giving a vertex normal.
> Glassner describes this technique in Graphics Gems. However, as pointed out in
> "Computing Vertex Normals from Polygonal Facets" (abstract at
> http://www.acm.org/jgt/papers/ThurmerWuthrich98/), the answer changes if a
> polygon is triangulated (i.e. a single polygon can turn into more than one
> triangle, and then each of these triangles [all of which have the same surface
> normal] adds into the averaged normal). The article gives a clever solution,
> which is to weight each contributing polygon's normal by the angle at the
> polygon's vertex - tessellation of the polygon will not change this weighting
> factor, it will merely distribute it among the triangles created.

> Weighting each polygon's contribution by its amount of angle at the vertex has a
> sense to it, but I've heard there might be a better solution (sorry, I don't know
> more than this at this time).

> Eric

### Using surface normals with on a triangulated surface

Quote:> Weighting each polygon's contribution by its amount of angle at the vertex
has a
> sense to it, but I've heard there might be a better solution (sorry, I
don't know
> more than this at this time).

This thread appears regularly--computing vertex normals for
a triangle mesh.  My proposal is not to average even with
weights.  Instead use the axis of the minimal cone containing
the normals of the triangles sharing the vertex.  This works
as long as the cone angle does not exceed pi radians.  If
it does, the surface is "ruffled" at the vertex, so lighting
is going to be screwed up anyway.

The number of triangles sharing the vertex is usually
quite small, so it is not expensive to compute the
cone axis.  But for large point sets,  the general
problem of finding minimal cone containing points on
a sphere can be solved using randomized linear
methods.  In fact, this is the equivalent of finding a
minimum area circle containing a set of points.

--
Dave Eberly

http://www.magic-software.com

### Using surface normals with on a triangulated surface

Quote:

> This thread appears regularly--computing vertex normals for
> a triangle mesh.  My proposal is not to average even with
> weights.  Instead use the axis of the minimal cone containing
> the normals of the triangles sharing the vertex.

I said in one of the threads that angles at a vertex
is a good idea. I thought this because given a smooth
surface's approximation by a triangulated mesh, I think
if we try a bit, we can prove that the bigger the angle
a triangle makes at a vertex(say V), the Less it's normal
deviates from the actual normal at the vertex (V).[Of course
if the approximating triangular mesh is dense enough]

But I dont have any inkling of such a proof for Dave's proposal.
Can someone give me an insight of why this should be better than
angles...

And above all, Does anyone have a backing of an implementation to
what we are talking about, I mean has anyone seen how the results
are when one uses the angle and cone proposals..., and which one
is better when the surface is good, I mean say the cones Dave
is talking about are small.(Say pi/4 or pi/6) at every vertex,
And I apply both the proposals,
Which one gives me better results...

--Piyush

### Using surface normals with on a triangulated surface

> > This thread appears regularly--computing vertex normals for
> > a triangle mesh.  My proposal is not to average even with
> > weights.  Instead use the axis of the minimal cone containing
> > the normals of the triangles sharing the vertex.

> I said in one of the threads that angles at a vertex
> is a good idea.

I never said it was a bad idea :)

Quote:> But I dont have any inkling of such a proof for Dave's proposal.
> Can someone give me an insight of why this should be better than
> angles...

I also never "proved" anything, just stated my preference for
constructing a normal.   The minimal cone construction
is a geometric construction on the sphere and, in a sense,
computes a "median" of vectors.   In that sense I view
it as a natural algorithm to use and find it relatively easy
to understand how the final vector relates to the original
input.  My objection to averaging normals, then unitizing, is
that I find a linear combination of normals not intuitive in
a geometric sense.  Weighting by some quantity such
as triangle area always seemed ad hoc.

Also, I indicated that the minimal cone algorithm has
problems when the cone angle is larger than pi radians.
I can picture the ruffled surface when this happens.
It is not clear to me what the averaging method tells me
about the surface at the ruffled point.

Quote:> And above all, Does anyone have a backing of an implementation to
> what we are talking about, I mean has anyone seen how the results
> are when one uses the angle and cone proposals..., and which one
> is better when the surface is good, I mean say the cones Dave
> is talking about are small.(Say pi/4 or pi/6) at every vertex,
> And I apply both the proposals,
> Which one gives me better results...

Like any algorithms you want to compare, someone is going
to have to quantify what "better" means.  I am also not sure
how to define what a "good surface" is.

--
Dave Eberly

http://www.magic-software.com

### Using surface normals with on a triangulated surface

> (beginning of original message)

> Subject: Re: Using surface normals with on a triangulated surface

> Date: 1999/10/03
> Newsgroups: comp.graphics.algorithms

> > > This thread appears regularly--computing vertex normals for
> > > a triangle mesh.  My proposal is not to average even with
> > > weights.  Instead use the axis of the minimal cone containing
> > > the normals of the triangles sharing the vertex.

> > I said in one of the threads that angles at a vertex
> > is a good idea.

> I never said it was a bad idea :)

Thanks. (:

Quote:> > But I dont have any inkling of such a proof for Dave's proposal.
> > Can someone give me an insight of why this should be better than
> > angles...

> I also never "proved" anything, just stated my preference for
> constructing a normal.   The minimal cone construction
> is a geometric construction on the sphere and, in a sense,
> computes a "median" of vectors.   In that sense I view
> it as a natural algorithm to use and find it relatively easy
> to understand how the final vector relates to the original
> input.  My objection to averaging normals, then unitizing, is
> that I find a linear combination of normals not intuitive in
> a geometric sense.  Weighting by some quantity such
> as triangle area always seemed ad hoc.

Yes, Area seems to be adhoc. But Angles should be ok, IFF the
surface is well approximated by the triangles and the surface
is itself Smooth. Anyway in that case I think most heuristics
that we can think of will work.

Quote:> Also, I indicated that the minimal cone algorithm has
> problems when the cone angle is larger than pi radians.

I think that's a real bad case U are talking about. And
anything will have problems there.

Quote:> I can picture the ruffled surface when this happens.
> It is not clear to me what the averaging method tells me
> about the surface at the ruffled point.

Nothing can provably work out in this case I suppose.
Heuristics may work well in one case and fail in another.

Quote:

> > And above all, Does anyone have a backing of an implementation to
> > what we are talking about, I mean has anyone seen how the results
> > are when one uses the angle and cone proposals..., and which one
> > is better when the surface is good, I mean say the cones Dave
> > is talking about are small.(Say pi/4 or pi/6) at every vertex,
> > And I apply both the proposals,
> > Which one gives me better results...

> Like any algorithms you want to compare, someone is going
> to have to quantify what "better" means.  I am also not sure
> how to define what a "good surface" is.

This is a good question. What is better. I think I meant this
by its quantification: I take a surface, Densely approximate it
with a mesh.[Assume the surface is real good, I mean homeomorphic
to a ball + smooth, to begin with] And then I calculate the normals
at the sampled vertices using the ways we talked about. Which one
provably comes closest to the actual normal(2 the initial surface)
at the vertices.

Thanks and Best Regards,
--Piyush

--
Piyush Kumar
--
C1-110, IIT Campus,.....................| E-Mail:

Kharagpur-721302........................| Home:
INDIA...................................|  http://www.acm.org/~piyush

Phone(Res): +91-3222-77770,     +91-3222-55221-Ext:3489

"Thinkers are rare, doers are rarer, Thinker-doers The Rarest"
--The M^3(F.P.Brooks)

I am trying to write a program which will generate a surface composed of triangles at a specified distance from a similiar triangular mesh.  The initial mesh is in the form of indexed vertices and triangular groupings of these vertices to form the surface using clockwise ordering to define interior from exterior.  The generated surface would be in the same form but would lie at a constant distance inside the first surface.

The first set will be used to generate a "pipe" structural framework and the second will be used to generate "panels" offset from the structure at a constant distance for an architectural system.  Geometry will eventually be rendered by Radiance.

My first inclination was to write an program to calculate surface normals to the vertices in the first mesh and use the endpoints of these normals as the vertices for the second mesh.  It seems easy enough for a vertex with three faces but I'm stumped about how to porceed to four or more faces intersecting at a single vertex.

If you have a solution or could point me in the right direction for books or articles on this sort of thing I would greatly appreciate the assistance.

Thanks,
Jim Callahan