tags:

views:

347

answers:

4
+5  A: 

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.
dmckee
+1  A: 

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.

Nils Pipenbrinck
+3  A: 

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).

Christoph
+2  A: 

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.

P Daddy
Thank you for your answer, however this is a misunderstanding. I have a circle around only this vertex. What I meant to say is that I need to compute its area, but only outside of the polygon, which is defined by this vertex and others. And I know that other parts of the polygon don't matter here.
ypnos