Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:45:14+00:00 2026-06-11T12:45:14+00:00

I’ve found a problem with the detection of angle types (whether inner or outer

  • 0

I’ve found a problem with the detection of angle types (whether inner or outer wrt the origin of axes), given a set of polylines.
I’ve found dozens of very similar questions, but none of them solved my problem, so I put it here in hope something comes out.

classification of angles

All I have is a set of polylines. I need to find the angles (with a given tolerance close to rectangles), and classify them as inner or outer.

For each polyline I take the vertices 3 by 3, and I am able to recognize whether the central one is or is not an angle, and measure its value as a number between 0 and 180 degrees.

Now I need to give this angle a direction (let’s say a sign, negative if the acute is aiming away from the origin, positive if it aims toward the center), and I thought I’d implement it with one of the 2 methods below, but none of them worked.

1) Just the ‘sign of a 2d crossproduct’ (i know this is not mathematically correct terminology):

//given 3 contiguous vertices a,b,c
//check if b is a inner (+1) or outer (-1) vertex (0 in other cases)

double cross = ((b.x - a.x)*(c.y - a.y)) - ((b.y - a.y)*(c.x - a.x));

if(cross > 0){
  return 1;
} else if (cross < 0) {
  return -1;
}
return 0;

But it seems it only works in the bottom left quadrant, in the top right works exactly in the opposite way, while it screws in the others and i can’t understand why.

2) Compare the norm of the vertices

if b.norm() < a.norm() && b.norm() < c.norm 
then return +1
else return -1

This only works with basic cases, and overall no polylines crossing the axes (embracing the origin). I can check all the cases, but I’d rather avoid that.

Obviously, there are far safer methods, such as checking if the vertex is on the same side of the origin compared to a line passing between 2 neighbours lying on the 2 vectors.. but i need to optimize it as much as possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:45:15+00:00Added an answer on June 11, 2026 at 12:45 pm

    The short version:

    Describe the two angle vectors coming from the center point as a and b. And describe the vector from your center point to the origin as center.

    The angle will be described as “inner” if:

    dot( a + b, center ) > 0.0 && dot( cross( a, center ), cross( b, center ) ) < 0.0
    

    The explanation:

    This can be solved by using both the cross product and the dot product. (And happily, no angles at all. This can be solved entirely with adds, multiplies, and comparisons.)

    Here it is, solved in two steps.

    1. Is the angle pointing more toward the origin than away?

    The angle is pointing more towards than away if you define the “direction the angle is pointing” by summing the two angle vectors.

    Note that if the individual lengths of a and b are different, you can get some incorrect edge cases for very wide angles. Normalizing a and b will fix that.

    `dot( a + b, center ) > 0.0`
    

    2. Are vectors a and b pointing to opposite sides of the origin?

    Vectors a and b are pointing to opposite sides of the origin if their cross products point in opposing directions.

    `dot( cross( a, center ), cross( b, center ) ) < 0.0`
    

    If and only if these are both true, your angle is defined as “inner”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've tracked down a weird MySQL problem to the two different ways I was
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.