Solved

Finding inner normal of an edge using C

Posted on 1998-05-28
10
507 Views
Last Modified: 2010-04-15
Hi,

How can we calculate the inner normal of a linear edge of a polygonal face ?
The data i have is some face data (its surface normal, face center and face boundary) and the vertices of the edge.
The vertices and other data are represented in the Cartesian form.
(only x,y coordinate is of the interest)

Your info is much appreciated.
I have a routine to calculate the normal vector** to the edge, but no idea how to make sure it
is an inner normal.
** note: edge vector = <x1,y1>
             normal vector = <-y1,x1>

thanks,
Sam
0
Comment
Question by:kutaksama
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 5

Expert Comment

by:julio011597
ID: 1251039
What's an inner normal? I mean, AFAIK, a normal is a normal... there should be no concept of direction. Also, since you talk about a face normal, we should be in 3D, so why z-coord in not of interest?

-julio
0
 
LVL 84

Expert Comment

by:ozo
ID: 1251040
How about just traversing the edges counterclockwise?
0
 

Author Comment

by:kutaksama
ID: 1251041
Reply to Julio's comment:
I am working in a 3D geometric problem, but i reduce the problem into 2D when i just focus my attention to a planar face of a 3D object. This planar face is in the xy plane of the Cartesian space. That's why z-coordinate can be omited.
Inner normal mean a normal vector to the edge in the direction towards the region bounded by the face, instead of directing away from the face region.

-Sam
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kutaksama
ID: 1251042
Edited text of question
0
 
LVL 2

Expert Comment

by:Slarti
ID: 1251043
If the face is in the x-y plane, then the normal should be in the z direction, and your only problem is whether it is (0,0,1) or (0,0,-1) - is that correct?
0
 
LVL 5

Accepted Solution

by:
julio011597 earned 200 total points
ID: 1251044
Given the edge P1-P2 where:

P1(x1, y1);
P2(x2, y2);

The slope of the P1-P2 edge is:

m(P1,P2) = (y2 - y1) / (x2 - x1);

and the slope of *the* (ANY) normal is:

m'(P1,P2) = - (1 / m(P1,P2)) = - (x2 - x1) / (y2 - y1);

This is almost all you need to know of a normal... indeed there's a normal direction, not a normal vector.

Let's go a bit further. Now we want the normal straight line passing by the mid-point M of edge P1-P2.

M = M((x2 + x1) / 2, (y2 + y1) / 2);

so we need to work out our particular y=mx+q, by the following system:

{ m = m'(P1,P2) =  - (x2 - x1) / (y2 - y1);
{ (y2 + y1) / 2 = m (x2 + x1) / 2 + q;  (passage through M)

a couple of steps lead to:

{ m =  - (x2 - x1) / (y2 - y1);
{ q = (y2^2 - y1^2 + x2^2 - x1^2) / (2 (y2 - y1));

so the normal straight line to our edge, passing through M, is:

y =  - (x2 - x1) / (y2 - y1) x + (y2^2 - y1^2 + x2^2 - x1^2) / (2 (y2 - y1));

This is almost all analytic geometry has to tell about the problem.
Again, there's no concept of direction, that is, there's no concept of inner or outer normals.

I just wander if your final goal is actually related to analytic geometry...

-julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1251045
BTW, i say:

> indeed there's a normal direction, not a normal vector

It is hard for me since i don't know the exact English terms, but there's a distinction between "direction" and "way" (orientation?) Geometry tells "direction" is just - to put it *very* simply - the slope of a straight line. A "way" instead means which way you walk the straight line towards, which brings the concept of inner/outer... but, again, analytical geometry does not deal with "ways".

-julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1251046
So (sorry for so much comments), when i later say:

> Again, there's no concept of direction, that is, there's no concept of inner or outer normals.

i actually mean "there's no concept of way" (or "orientation"...).

Just to tell, we call them "direzione" and "verso".

-julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1251047
...BTW, i've seen the question you previously posted.

First, if you need further clarifications, you can just add comments and hit submit with no grading box checked.

Also, i can give a C code that given P1 and P2 coords, gives back m' or... whatever you're looking for :)

Third, i've seen the answer you refer to, but i cannot understand what it is about. That is, <x,y> is not an edge, unless it means <P1,P2>... and, if so, <P2,-P1> is not its normal, AFAIK.

-julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1251048
kutaksama, did that help?

-julio
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SCANF - LIMIT THE NUMBER OF CHARARACTERS 1 68
chcp 65001 File encoding 66 300
Grammars for C C++ and java 1 140
Memory going from 12gb to 64gb or 96gb. worth it? 15 214
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question