###

Question:

I search for the fastest or simplest method to compute the outer angle at any point of a convex polygon. That means, always the bigger angle, whereas the two angles in question add up to 360 degrees.

Here is an illustration:

illustration http://fopref.meinungsverstaerker.de/div_priv/crap.png

Now I know that I may compute the angles between the two vectors A-B and C-B which involves the dot product, normalization and cosine. Then I would still have to determine which of the two resulting angles (second one is 180 degrees minus first one) I want to take two times added to the other one.

However, I thought there might be a much simpler, less tricky solution, probably using the mighty atan2() function. I got stuck and ask you about this :-)

**UPDATE:** I was asked what I need the angle for. I need to calculate the area of this specific circle around B, but only of the polygon that is described by A, B, C, ... So to calculate the area, I need the angle to use the formula `0.5*angle*r*r`

.

###

Solution:1

Use the inner-product (dot product) of the vectors describing the lines to get the inner angle and subtract from 360 degrees?

Works best if you already have the lines in point-vector form, but you can get vectors from point-to-point form pretty easily (i.e. by subtraction).

Taking `.`

to be the dot product we have

` v . w = |v| * |w| * cos(theta) `

where `v`

and `w`

are vectors and `theta`

is the angle between the lines. And the dot product can be computed from the components of the vectors by

` v . w = SUM(v_i * w_i : i=0..3) // 3 for three dimensions. Use more or fewer as needed `

here the subscripts indicate components.

Having actually *read* the question:

- The angle returned from inverting the dot-product will always be less than 180 degrees, so it is always the inner angle.

###

Solution:2

Use this formula:

`beta = 360Â° - arccos(<BA,BC>/|BA||BC|) `

Where `<,>`

is the scalar product and `BA`

(`BC`

) are the vectors from `B`

to `A`

(`B`

to `C`

).

###

Solution:3

I need to calculate the area of the circle outside of the polygon that is described by A, B, C, ...

It sounds like you're taking the wrong approach, then. You need to calculate the area of the circumcircle, then subtract the area of the polygon.

###

Solution:4

If you need the angle there is no way around normalizing the vectors and do a dot or cross-product. You often have a choice if you want to calculate the angle via asin, acos or atan but in the end that does not make a difference to execution speed.

However, It would be nice if you could tell us what you're trying to archive. If we have a better picture of what you're doing we might be able to give you some hints how to solve the problem without calculating the angle at the first place.

Lots of geometric algorithms can be rewritten to work with cross and dot-products only. Euler-angles are rarely needed.

**Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com**

EmoticonEmoticon