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

  • Home
  • SEARCH
  • 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 8222359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:15:09+00:00 2026-06-07T14:15:09+00:00

If I have three points that create an angle, what would be the best

  • 0

If I have three points that create an angle, what would be the best way to determine if a fourth point resides within the angle created by the previous three?

Currently, I determine the angle of the line to all three points from the origin point, and then check to see if the test angle is in between the two other angles but I’m trying to figure out if there’s a better way to do it. The function is run tens of thousands of times an update and I’m hoping that there’s a better way to achieve what I’m trying to do.

  • 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-07T14:15:13+00:00Added an answer on June 7, 2026 at 2:15 pm

    Let’s say you have angle DEF (E is the “pointy” part), ED is the left ray and EF is the right ray.

          * D (Dx, Dy)
         /
        /          * P (Px, Py)
       /
      /
     *---------------*
    E (Ex, Ey)       F (Fx, Fy)
    

    Step 1. Build line equation for line ED in the classic Al * x + Bl * y + Cl = 0 form, i.e. simply calculate

        Al = Dy - Ey                    // l - for "left"
        Bl = -(Dx - Ex)
        Cl = -(Al * Ex + Bl * Ey)
    

    (Pay attention to the subtraction order.)

    Step 2. Build line equation for line FE (reversed direction) in the classic Ar * x + Br * y + Cr = 0 form, i.e. simply calculate

        Ar = Ey - Fy                    // r - for "right"
        Br = -(Ex - Fx)
        Cr = -(Ar * Ex + Br * Ey)
    

    (Pay attention to the subtraction order.)

    Step 3. For your test point P calculate the expressions

        Sl = Al * Px + Bl * Py + Cl
        Sr = Ar * Px + Br * Py + Cr
    

    Your point lies inside the angle if and only if both Sl and Sr are positive. If one of them is positive and other is zero, your point lies on the corresponding side ray.

    That’s it.

    Note 1: For this method to work correctly, it is important to make sure that the left and right rays of the angle are indeed left and right rays. I.e. if you think about ED and EF as clock hands, the direction from D to F should be clockwise. If it is not guaranteed to be the case for your input, then some adjustments are necessary. For example, it can be done as an additional step of the algorithm, inserted between steps 2 and 3

    Step 2.5. Calculate the value of Al * Fx + Bl * Fy + Cl. If this value is negative, invert signs of all ABC coefficients:

    Al = -Al, Bl = -Bl, Cl = -Cl
    Ar = -Ar, Br = -Br, Cr = -Cr
    

    Note 2: The above calculations are made under assumption that we are working in a coordinate system with X axis pointing to the right and Y axis pointing to the top. If one of your coordinate axes is flipped, you have to invert the signs of all six ABC coefficients. Note, BTW, that if you perform the test described in step 2.5 above, it will take care of everything automatically. If you are not performing step 2.5 then you have to take the axis direction into account from the very beginning.


    As you can see, this a precise integer method (no floating point calculations, no divisions). The price of that is danger of overflows. Use appropriately sized types for multiplications.

    This method has no special cases with regard to line orientations or the value of the actual non-reflex angle: it work immediately for acute, obtuse, zero and straight angle. It can be easily used with reflex angles (just perform a complementary test).

    P.S. The four possible combinations of +/- signs for Sl and Sr correspond to four sectors, into which the plane is divided by lines ED and EF.

                * D
               / 
       (-,+)  /    (+,+)
             /
     -------*------------* F
           / E
    (-,-) /     (+,-)
         /
    

    By using this method you can perform the full “which sector the point falls into” test. For an angle smaller than 180 you just happen to be interested in only one of those sectors: (+, +). If at some point you’ll need to adapt this method for reflex angles as well (angles greater than 180), you will have to test for three sectors instead of one: (+,+), (-,+), (+,-).

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

Sidebar

Related Questions

How do you write a Maxscript that gets the three points needed to create
I have a very large point cloud (> 100000 points) that I'd like to
So I have some function that receives N random 2D points. Is there any
I have three points, for example: Start 194 171 Right 216 131 Left 216
I have the coordinates of three points on a plane. Let's call them X1,Y1,
I have a dataset consisting of a large collection of points in three dimensional
Is there a way for me to have eclipse start and point to a
Have three divs in a container that I want to float over a large
I have a set of points that have latitude and longitude values and I
I have a method that, given an angle for North and an angle for

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.