# Signed angle between two normals?

This topic is 1561 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have two polygons which share two vertices, and the normals for both polygons.

What I need to determine is whether the shared line between the polygons is a mountain or valley, ie the surfaces point away from each other or towards each other.

Finding the angle between the normals is easy:  angle = arccos(dotproduct(N1,N2))

I can't seem to find a simple solution to determine the sign of the angle.

I have tried the atan2 method but this doesn't work, I keep getting an unsigned angle.

There is also a method online (angle between two vectors) that requires the comparison between the cross product of two vectors and the original normal to the plane, but since there isn't a plane, the normal (to the normals) is calculated using the cross product, so only ever compares to itself.

I've tried a method of adding the normals to the centers of the polygons and measuring the distances between them, this works most of the time but fails when using acute angles.

Is there an equation that will give me the signed angle?

or any other method that can determine if the line is a mountain or valley?

Thanks.

##### Share on other sites

If I understand your description, the crossproduct of the normals alone should be sufficient. For a mountain fold, the normals should point away from each other; for a valley fold, the normals should point towards each other. The signs of those crossproducts should be different. Which is which depends on whether your crossproduct function/routine is left-hand or right-hand rule.

Since crossproduct = |a| |b| sin( theta ), and, if the normals are normalized (length=1): angle = sin-1( crossproduct ). Test for angle < 0 or > 0. As mentioned, crossproduct functions can be left- and or-handed, so determine which is which.

##### Share on other sites

You can check for sign of dotproduct between first polygon's edge that is not shared with other triangle (but connected to shared vertice), and other polygon's normal.

##### Share on other sites
This was discussed not too long ago in this thread.

I don't know what the sign of a cross product means, Buckeye: 3D vectors don't have signs. If you take the result of the cross product and compute its dot product with the common edge, that will give you something whose sign answers the question.

##### Share on other sites

Buckeye: 3D vectors don't have signs

You're absolutely correct. Don't know what I was thinking.

Edited by Buckeye

##### Share on other sites

Buckeye: 3D vectors don't have signs

You're absolutely correct. Don't know what I thinking.

Thank god, because i was just seriously doubting my understanding of the cross product.

##### Share on other sites

Buckeye: 3D vectors don't have signs

You're absolutely correct. Don't know what I thinking.

Thank god, because i was just seriously doubting my understanding of the cross product.

Sorry about that. And it was so clear to me when I wrote it!

##### Share on other sites

Dot product method works to 0.1 degrees (floating point errors at 0.01 degrees).

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633742
• Total Posts
3013633
×