Angle Between Two Vectors Facing A PointAngle between GPS coordinatesPhi vs Theta referring to angles of vectorsHow to convert a dot product of two vectors to the angle between the vectors.Is it possible to get the angle between two vectors in a single direction?Formula to find an angle of point on a coordinate planeMaximization of angle between two 3D vectorsFinding the angle between a point and another point with an angleAngles between vectors: is my textbook wrong here, or am I mistaken?Find the angle of a tangent line between two circlesHow to get the direction of the angle from a dot product of two vectors

Do electrons really perform instantaneous quantum leaps?

A quine of sorts

Chandra exiles a card, I play it, it gets exiled again

Calculus, water poured into a cone: Why is the derivative non-linear?

What does this Pokemon Trainer mean by saying the player is "SHELLOS"?

What's the lunar calendar of two moons

Basis and cardinality

How much of a mortgage should I take on to maximize my 5 year financial plan?

Cat files in subfolders in order given by a list

tikz: draw multicolor curve with smooth gradient

Enterprise Layers and Naming Conventions

Does a lens with a bigger max. aperture focus faster than a lens with a smaller max. aperture?

How to count the number of bytes in a file, grouping the same bytes?

Is it OK to throw pebbles and stones in streams, waterfalls, ponds, etc.?

My mom helped me cosign a car and now she wants to take it

Active wildlife outside the window- Good or Bad for Cat psychology?

How does mmorpg store data?

How soon after takeoff can you recline your airplane seat?

What are the children of two Muggle-borns called?

What prevents a US state from colonizing a smaller state?

Two palindromes are not enough

Why was Pan Am Flight 103 flying over Lockerbie?

Why are examinees often not allowed to leave during the start and end of an exam?

What's the point of stochastic volatiliy models if you can use local volatility?



Angle Between Two Vectors Facing A Point


Angle between GPS coordinatesPhi vs Theta referring to angles of vectorsHow to convert a dot product of two vectors to the angle between the vectors.Is it possible to get the angle between two vectors in a single direction?Formula to find an angle of point on a coordinate planeMaximization of angle between two 3D vectorsFinding the angle between a point and another point with an angleAngles between vectors: is my textbook wrong here, or am I mistaken?Find the angle of a tangent line between two circlesHow to get the direction of the angle from a dot product of two vectors













6












$begingroup$


I need a mathematical algorithm for finding the angle, formed by three points, which is open toward a fourth point.



For example, in Fig1 below I desire angle $theta$ because it is "facing" point $P$. However, the formula for the angle between two vectors, $$theta=cos^-1Big(fracvecucdotvecvuvBig)$$ gives angle $alpha$ because the above relation always returns the angle which is less than 180 degrees.



Figure 1(Fig1)



In contrast, in Fig2 I desire angle $alpha$ because this time it is "facing" point $P$.



Figure 2(Fig2)



As a final example, in Fig3 below I need angle $theta$, because it is still technically "facing" point $P$.



Figure 3(Fig3)



This problem can occur in any orientation, making it difficult to say, for example, "If point $P$ is to the left of points $A, B, C$, use the leftmost angle, otherwise use the right" or something like that.



Any help would be appreciated!




My Attempted Solution



If anyone's interested, my current solution is to split the angle facing the point $P$ in half and add those two together.



In Fig4 below, I use the grey line to split the angle in half, find $s$ and $t$ using dot product, then add $s$ and $t$ to get the angle facing $P$.



Figure 4(Fig4)



This works until I reach a situation like that in Fig5. What I need is $s+t$, but what I get is $q+t$ because the dot product gives $q$ (since $s$ is greater than $180$ degrees).



Figure 5(Fig5)



It's a conundrum.










share|cite|improve this question









New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$







  • 1




    $begingroup$
    Here’s the MathJax tutorial
    $endgroup$
    – Chase Ryan Taylor
    10 hours ago










  • $begingroup$
    What would you like the results to be if you were to swap points $A$ and $C$ in all of these cases? There’s a fairly simple solution that involves comparing the signs of two $3times3$ determinants, but interpreting them correctly depends on the answer to my question.
    $endgroup$
    – amd
    9 hours ago










  • $begingroup$
    @amd In my implementation, I have a long string of consecutively drawn points (by a user dragging a mouse) and I look at every set of 3 points in the user-drawn-line and label them a, b, and c. a and c can be swapped, namewise, if that is what you mean. But for the sake of your answer, let's say that they can be swapped in the way you suggest. What follows from there?
    $endgroup$
    – retrovius
    9 hours ago










  • $begingroup$
    Let me ask my question a different way: is $alpha$ always measured counterclockwise from $overrightarrowBA$ to $overrightarrowBC$, in which case it might be greater than $pi$, or is it simply the angle measure in the range $[0,pi]$ between the two rays without regard to which ray is “first?” I.e., is $alpha$ always the lesser of the two angles?
    $endgroup$
    – amd
    9 hours ago











  • $begingroup$
    I see. My situation fits the second option, calculating the angle in the range [0,Pi] without regard to which ray is "first", corresponding to equation F in my question.
    $endgroup$
    – retrovius
    9 hours ago















6












$begingroup$


I need a mathematical algorithm for finding the angle, formed by three points, which is open toward a fourth point.



For example, in Fig1 below I desire angle $theta$ because it is "facing" point $P$. However, the formula for the angle between two vectors, $$theta=cos^-1Big(fracvecucdotvecvuvBig)$$ gives angle $alpha$ because the above relation always returns the angle which is less than 180 degrees.



Figure 1(Fig1)



In contrast, in Fig2 I desire angle $alpha$ because this time it is "facing" point $P$.



Figure 2(Fig2)



As a final example, in Fig3 below I need angle $theta$, because it is still technically "facing" point $P$.



Figure 3(Fig3)



This problem can occur in any orientation, making it difficult to say, for example, "If point $P$ is to the left of points $A, B, C$, use the leftmost angle, otherwise use the right" or something like that.



Any help would be appreciated!




My Attempted Solution



If anyone's interested, my current solution is to split the angle facing the point $P$ in half and add those two together.



In Fig4 below, I use the grey line to split the angle in half, find $s$ and $t$ using dot product, then add $s$ and $t$ to get the angle facing $P$.



Figure 4(Fig4)



This works until I reach a situation like that in Fig5. What I need is $s+t$, but what I get is $q+t$ because the dot product gives $q$ (since $s$ is greater than $180$ degrees).



Figure 5(Fig5)



It's a conundrum.










share|cite|improve this question









New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$







  • 1




    $begingroup$
    Here’s the MathJax tutorial
    $endgroup$
    – Chase Ryan Taylor
    10 hours ago










  • $begingroup$
    What would you like the results to be if you were to swap points $A$ and $C$ in all of these cases? There’s a fairly simple solution that involves comparing the signs of two $3times3$ determinants, but interpreting them correctly depends on the answer to my question.
    $endgroup$
    – amd
    9 hours ago










  • $begingroup$
    @amd In my implementation, I have a long string of consecutively drawn points (by a user dragging a mouse) and I look at every set of 3 points in the user-drawn-line and label them a, b, and c. a and c can be swapped, namewise, if that is what you mean. But for the sake of your answer, let's say that they can be swapped in the way you suggest. What follows from there?
    $endgroup$
    – retrovius
    9 hours ago










  • $begingroup$
    Let me ask my question a different way: is $alpha$ always measured counterclockwise from $overrightarrowBA$ to $overrightarrowBC$, in which case it might be greater than $pi$, or is it simply the angle measure in the range $[0,pi]$ between the two rays without regard to which ray is “first?” I.e., is $alpha$ always the lesser of the two angles?
    $endgroup$
    – amd
    9 hours ago











  • $begingroup$
    I see. My situation fits the second option, calculating the angle in the range [0,Pi] without regard to which ray is "first", corresponding to equation F in my question.
    $endgroup$
    – retrovius
    9 hours ago













6












6








6


1



$begingroup$


I need a mathematical algorithm for finding the angle, formed by three points, which is open toward a fourth point.



For example, in Fig1 below I desire angle $theta$ because it is "facing" point $P$. However, the formula for the angle between two vectors, $$theta=cos^-1Big(fracvecucdotvecvuvBig)$$ gives angle $alpha$ because the above relation always returns the angle which is less than 180 degrees.



Figure 1(Fig1)



In contrast, in Fig2 I desire angle $alpha$ because this time it is "facing" point $P$.



Figure 2(Fig2)



As a final example, in Fig3 below I need angle $theta$, because it is still technically "facing" point $P$.



Figure 3(Fig3)



This problem can occur in any orientation, making it difficult to say, for example, "If point $P$ is to the left of points $A, B, C$, use the leftmost angle, otherwise use the right" or something like that.



Any help would be appreciated!




My Attempted Solution



If anyone's interested, my current solution is to split the angle facing the point $P$ in half and add those two together.



In Fig4 below, I use the grey line to split the angle in half, find $s$ and $t$ using dot product, then add $s$ and $t$ to get the angle facing $P$.



Figure 4(Fig4)



This works until I reach a situation like that in Fig5. What I need is $s+t$, but what I get is $q+t$ because the dot product gives $q$ (since $s$ is greater than $180$ degrees).



Figure 5(Fig5)



It's a conundrum.










share|cite|improve this question









New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$endgroup$




I need a mathematical algorithm for finding the angle, formed by three points, which is open toward a fourth point.



For example, in Fig1 below I desire angle $theta$ because it is "facing" point $P$. However, the formula for the angle between two vectors, $$theta=cos^-1Big(fracvecucdotvecvuvBig)$$ gives angle $alpha$ because the above relation always returns the angle which is less than 180 degrees.



Figure 1(Fig1)



In contrast, in Fig2 I desire angle $alpha$ because this time it is "facing" point $P$.



Figure 2(Fig2)



As a final example, in Fig3 below I need angle $theta$, because it is still technically "facing" point $P$.



Figure 3(Fig3)



This problem can occur in any orientation, making it difficult to say, for example, "If point $P$ is to the left of points $A, B, C$, use the leftmost angle, otherwise use the right" or something like that.



Any help would be appreciated!




My Attempted Solution



If anyone's interested, my current solution is to split the angle facing the point $P$ in half and add those two together.



In Fig4 below, I use the grey line to split the angle in half, find $s$ and $t$ using dot product, then add $s$ and $t$ to get the angle facing $P$.



Figure 4(Fig4)



This works until I reach a situation like that in Fig5. What I need is $s+t$, but what I get is $q+t$ because the dot product gives $q$ (since $s$ is greater than $180$ degrees).



Figure 5(Fig5)



It's a conundrum.







trigonometry vectors angle






share|cite|improve this question









New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|cite|improve this question









New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|cite|improve this question




share|cite|improve this question








edited 9 hours ago









infinite-blank-

125 bronze badges




125 bronze badges






New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 10 hours ago









retroviusretrovius

1334 bronze badges




1334 bronze badges




New contributor



retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




retrovius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









  • 1




    $begingroup$
    Here’s the MathJax tutorial
    $endgroup$
    – Chase Ryan Taylor
    10 hours ago










  • $begingroup$
    What would you like the results to be if you were to swap points $A$ and $C$ in all of these cases? There’s a fairly simple solution that involves comparing the signs of two $3times3$ determinants, but interpreting them correctly depends on the answer to my question.
    $endgroup$
    – amd
    9 hours ago










  • $begingroup$
    @amd In my implementation, I have a long string of consecutively drawn points (by a user dragging a mouse) and I look at every set of 3 points in the user-drawn-line and label them a, b, and c. a and c can be swapped, namewise, if that is what you mean. But for the sake of your answer, let's say that they can be swapped in the way you suggest. What follows from there?
    $endgroup$
    – retrovius
    9 hours ago










  • $begingroup$
    Let me ask my question a different way: is $alpha$ always measured counterclockwise from $overrightarrowBA$ to $overrightarrowBC$, in which case it might be greater than $pi$, or is it simply the angle measure in the range $[0,pi]$ between the two rays without regard to which ray is “first?” I.e., is $alpha$ always the lesser of the two angles?
    $endgroup$
    – amd
    9 hours ago











  • $begingroup$
    I see. My situation fits the second option, calculating the angle in the range [0,Pi] without regard to which ray is "first", corresponding to equation F in my question.
    $endgroup$
    – retrovius
    9 hours ago












  • 1




    $begingroup$
    Here’s the MathJax tutorial
    $endgroup$
    – Chase Ryan Taylor
    10 hours ago










  • $begingroup$
    What would you like the results to be if you were to swap points $A$ and $C$ in all of these cases? There’s a fairly simple solution that involves comparing the signs of two $3times3$ determinants, but interpreting them correctly depends on the answer to my question.
    $endgroup$
    – amd
    9 hours ago










  • $begingroup$
    @amd In my implementation, I have a long string of consecutively drawn points (by a user dragging a mouse) and I look at every set of 3 points in the user-drawn-line and label them a, b, and c. a and c can be swapped, namewise, if that is what you mean. But for the sake of your answer, let's say that they can be swapped in the way you suggest. What follows from there?
    $endgroup$
    – retrovius
    9 hours ago










  • $begingroup$
    Let me ask my question a different way: is $alpha$ always measured counterclockwise from $overrightarrowBA$ to $overrightarrowBC$, in which case it might be greater than $pi$, or is it simply the angle measure in the range $[0,pi]$ between the two rays without regard to which ray is “first?” I.e., is $alpha$ always the lesser of the two angles?
    $endgroup$
    – amd
    9 hours ago











  • $begingroup$
    I see. My situation fits the second option, calculating the angle in the range [0,Pi] without regard to which ray is "first", corresponding to equation F in my question.
    $endgroup$
    – retrovius
    9 hours ago







1




1




$begingroup$
Here’s the MathJax tutorial
$endgroup$
– Chase Ryan Taylor
10 hours ago




$begingroup$
Here’s the MathJax tutorial
$endgroup$
– Chase Ryan Taylor
10 hours ago












$begingroup$
What would you like the results to be if you were to swap points $A$ and $C$ in all of these cases? There’s a fairly simple solution that involves comparing the signs of two $3times3$ determinants, but interpreting them correctly depends on the answer to my question.
$endgroup$
– amd
9 hours ago




$begingroup$
What would you like the results to be if you were to swap points $A$ and $C$ in all of these cases? There’s a fairly simple solution that involves comparing the signs of two $3times3$ determinants, but interpreting them correctly depends on the answer to my question.
$endgroup$
– amd
9 hours ago












$begingroup$
@amd In my implementation, I have a long string of consecutively drawn points (by a user dragging a mouse) and I look at every set of 3 points in the user-drawn-line and label them a, b, and c. a and c can be swapped, namewise, if that is what you mean. But for the sake of your answer, let's say that they can be swapped in the way you suggest. What follows from there?
$endgroup$
– retrovius
9 hours ago




$begingroup$
@amd In my implementation, I have a long string of consecutively drawn points (by a user dragging a mouse) and I look at every set of 3 points in the user-drawn-line and label them a, b, and c. a and c can be swapped, namewise, if that is what you mean. But for the sake of your answer, let's say that they can be swapped in the way you suggest. What follows from there?
$endgroup$
– retrovius
9 hours ago












$begingroup$
Let me ask my question a different way: is $alpha$ always measured counterclockwise from $overrightarrowBA$ to $overrightarrowBC$, in which case it might be greater than $pi$, or is it simply the angle measure in the range $[0,pi]$ between the two rays without regard to which ray is “first?” I.e., is $alpha$ always the lesser of the two angles?
$endgroup$
– amd
9 hours ago





$begingroup$
Let me ask my question a different way: is $alpha$ always measured counterclockwise from $overrightarrowBA$ to $overrightarrowBC$, in which case it might be greater than $pi$, or is it simply the angle measure in the range $[0,pi]$ between the two rays without regard to which ray is “first?” I.e., is $alpha$ always the lesser of the two angles?
$endgroup$
– amd
9 hours ago













$begingroup$
I see. My situation fits the second option, calculating the angle in the range [0,Pi] without regard to which ray is "first", corresponding to equation F in my question.
$endgroup$
– retrovius
9 hours ago




$begingroup$
I see. My situation fits the second option, calculating the angle in the range [0,Pi] without regard to which ray is "first", corresponding to equation F in my question.
$endgroup$
– retrovius
9 hours ago










3 Answers
3






active

oldest

votes


















2












$begingroup$

Except if $A,B,C$ are collinear, for any $P$ on the non-reflex side of $angle ABC$, the unique solution $(t,u)$ to $vecBP=tvecBA+uvecBC$ will have $t,uge0$. This leads to the following algorithm:



  1. Translate all the points so $B$ is at the origin.


  2. In these new coordinates, solve the linear system
    $$beginbmatrixx_A&x_C\y_A&y_Cendbmatrixbeginbmatrixt\uendbmatrix=beginbmatrixx_P\y_Pendbmatrix$$


  3. If both $t$ and $u$ are non-negative, take the non-reflex angle $alpha$ resulting from the application of the standard formula for angle between two vectors. Otherwise, take the complementary reflex angle $theta$.


  4. If $A,B,C$ are collinear, the linear system in step 2 will be indeterminate, and it is easy to check whether $angle ABC=0$ (in which case $2pi$ is returned) or $pi$ (in which case $pi$ is returned).






share|cite|improve this answer









$endgroup$












  • $begingroup$
    This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
    $endgroup$
    – retrovius
    8 hours ago










  • $begingroup$
    Will any problems arise when all four points are colinear?
    $endgroup$
    – retrovius
    7 hours ago


















3












$begingroup$

Unless $A-B$ and $C-B$ are linearly dependent, you can uniquely express $P-B$ in terms of them:
$$ P-B=rcdot(A-B)+scdot(C-B).$$
Now $P$ is in the smaller of the two possible angles if and only if $r$ and $s$ are both positive. It is on the ray $BA$ if and only if $s=0$ and $rge0$, and on the ray $BC$ if and only if $r=0$ and $sge 0$. In all other cases, it is in the larger angle.






share|cite|improve this answer









$endgroup$




















    1












    $begingroup$

    You can sort this out by comparing the signs of three determinants. Let $$d_0 = detbeginbmatrixB_x&B_y&1\A_x&A_y&1\C_x&C_y&1endbmatrix.$$ This tells you the direction in which the vertices of $triangleBAC$ are traversed: positive means counterclockwise, negative clockwise, and the points are colinear if it’s zero. Note that the area of this triangle is equal to $frac12lvert d_0rvert = frac12lVert A-BrVert,lVert C-BrVert,lvertsinphirvert$, with $lvertphirvertin[0,pi)$, so when the points aren’t colinear this is another way to find the angle between them. Moreover, unlike the dot product, this determinant can tell left from right. On the other hand, it can’t tell the order of the points when they’re colinear, which the dot product can.



    Now, assuming that $d_0ne0$, compare the signs of the corresponding determinants for $triangleAPB$ and $triangleBPC$ $$d_A=detbeginbmatrixA_x&A_y&1\P_x&P_y&1\B_x&B_y&1endbmatrix text and d_C=detbeginbmatrixB_x&B_y&1\P_x&P_y&1\C_x&C_y&1endbmatrix,$$ respectively, to the sign of $d_0$: If they are all the same, then $P$ lies within the “narrow” side and you can use the angle $theta$ computed in your question; if any differ, then $P$ is on the “wide” side and you want $2pi-theta$. If either $d_A$ or $d_C$ is zero, ignore it; if both are zero, then $P=B$ and you might as well use $theta$.



    If you expand these determinants, you might find that the resulting expressions look familiar. For example, $d_0 = (A-B)wedge(C-B)$, where $mathbf vwedgemathbf w=v_x w_y-v_y w_x$ is the “two-dimensional cross product” of the vectors.






    share|cite|improve this answer









    $endgroup$












    • $begingroup$
      This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
      $endgroup$
      – retrovius
      8 hours ago










    • $begingroup$
      @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
      $endgroup$
      – amd
      8 hours ago














    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "69"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );






    retrovius is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3277979%2fangle-between-two-vectors-facing-a-point%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2












    $begingroup$

    Except if $A,B,C$ are collinear, for any $P$ on the non-reflex side of $angle ABC$, the unique solution $(t,u)$ to $vecBP=tvecBA+uvecBC$ will have $t,uge0$. This leads to the following algorithm:



    1. Translate all the points so $B$ is at the origin.


    2. In these new coordinates, solve the linear system
      $$beginbmatrixx_A&x_C\y_A&y_Cendbmatrixbeginbmatrixt\uendbmatrix=beginbmatrixx_P\y_Pendbmatrix$$


    3. If both $t$ and $u$ are non-negative, take the non-reflex angle $alpha$ resulting from the application of the standard formula for angle between two vectors. Otherwise, take the complementary reflex angle $theta$.


    4. If $A,B,C$ are collinear, the linear system in step 2 will be indeterminate, and it is easy to check whether $angle ABC=0$ (in which case $2pi$ is returned) or $pi$ (in which case $pi$ is returned).






    share|cite|improve this answer









    $endgroup$












    • $begingroup$
      This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
      $endgroup$
      – retrovius
      8 hours ago










    • $begingroup$
      Will any problems arise when all four points are colinear?
      $endgroup$
      – retrovius
      7 hours ago















    2












    $begingroup$

    Except if $A,B,C$ are collinear, for any $P$ on the non-reflex side of $angle ABC$, the unique solution $(t,u)$ to $vecBP=tvecBA+uvecBC$ will have $t,uge0$. This leads to the following algorithm:



    1. Translate all the points so $B$ is at the origin.


    2. In these new coordinates, solve the linear system
      $$beginbmatrixx_A&x_C\y_A&y_Cendbmatrixbeginbmatrixt\uendbmatrix=beginbmatrixx_P\y_Pendbmatrix$$


    3. If both $t$ and $u$ are non-negative, take the non-reflex angle $alpha$ resulting from the application of the standard formula for angle between two vectors. Otherwise, take the complementary reflex angle $theta$.


    4. If $A,B,C$ are collinear, the linear system in step 2 will be indeterminate, and it is easy to check whether $angle ABC=0$ (in which case $2pi$ is returned) or $pi$ (in which case $pi$ is returned).






    share|cite|improve this answer









    $endgroup$












    • $begingroup$
      This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
      $endgroup$
      – retrovius
      8 hours ago










    • $begingroup$
      Will any problems arise when all four points are colinear?
      $endgroup$
      – retrovius
      7 hours ago













    2












    2








    2





    $begingroup$

    Except if $A,B,C$ are collinear, for any $P$ on the non-reflex side of $angle ABC$, the unique solution $(t,u)$ to $vecBP=tvecBA+uvecBC$ will have $t,uge0$. This leads to the following algorithm:



    1. Translate all the points so $B$ is at the origin.


    2. In these new coordinates, solve the linear system
      $$beginbmatrixx_A&x_C\y_A&y_Cendbmatrixbeginbmatrixt\uendbmatrix=beginbmatrixx_P\y_Pendbmatrix$$


    3. If both $t$ and $u$ are non-negative, take the non-reflex angle $alpha$ resulting from the application of the standard formula for angle between two vectors. Otherwise, take the complementary reflex angle $theta$.


    4. If $A,B,C$ are collinear, the linear system in step 2 will be indeterminate, and it is easy to check whether $angle ABC=0$ (in which case $2pi$ is returned) or $pi$ (in which case $pi$ is returned).






    share|cite|improve this answer









    $endgroup$



    Except if $A,B,C$ are collinear, for any $P$ on the non-reflex side of $angle ABC$, the unique solution $(t,u)$ to $vecBP=tvecBA+uvecBC$ will have $t,uge0$. This leads to the following algorithm:



    1. Translate all the points so $B$ is at the origin.


    2. In these new coordinates, solve the linear system
      $$beginbmatrixx_A&x_C\y_A&y_Cendbmatrixbeginbmatrixt\uendbmatrix=beginbmatrixx_P\y_Pendbmatrix$$


    3. If both $t$ and $u$ are non-negative, take the non-reflex angle $alpha$ resulting from the application of the standard formula for angle between two vectors. Otherwise, take the complementary reflex angle $theta$.


    4. If $A,B,C$ are collinear, the linear system in step 2 will be indeterminate, and it is easy to check whether $angle ABC=0$ (in which case $2pi$ is returned) or $pi$ (in which case $pi$ is returned).







    share|cite|improve this answer












    share|cite|improve this answer



    share|cite|improve this answer










    answered 10 hours ago









    Parcly TaxelParcly Taxel

    47.3k13 gold badges77 silver badges116 bronze badges




    47.3k13 gold badges77 silver badges116 bronze badges











    • $begingroup$
      This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
      $endgroup$
      – retrovius
      8 hours ago










    • $begingroup$
      Will any problems arise when all four points are colinear?
      $endgroup$
      – retrovius
      7 hours ago
















    • $begingroup$
      This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
      $endgroup$
      – retrovius
      8 hours ago










    • $begingroup$
      Will any problems arise when all four points are colinear?
      $endgroup$
      – retrovius
      7 hours ago















    $begingroup$
    This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
    $endgroup$
    – retrovius
    8 hours ago




    $begingroup$
    This accomplished exactly what I needed in a simple, intuitive, straightforward fashion. I knew there was something out there, I just didn't know how to ask the question. Thank you!
    $endgroup$
    – retrovius
    8 hours ago












    $begingroup$
    Will any problems arise when all four points are colinear?
    $endgroup$
    – retrovius
    7 hours ago




    $begingroup$
    Will any problems arise when all four points are colinear?
    $endgroup$
    – retrovius
    7 hours ago











    3












    $begingroup$

    Unless $A-B$ and $C-B$ are linearly dependent, you can uniquely express $P-B$ in terms of them:
    $$ P-B=rcdot(A-B)+scdot(C-B).$$
    Now $P$ is in the smaller of the two possible angles if and only if $r$ and $s$ are both positive. It is on the ray $BA$ if and only if $s=0$ and $rge0$, and on the ray $BC$ if and only if $r=0$ and $sge 0$. In all other cases, it is in the larger angle.






    share|cite|improve this answer









    $endgroup$

















      3












      $begingroup$

      Unless $A-B$ and $C-B$ are linearly dependent, you can uniquely express $P-B$ in terms of them:
      $$ P-B=rcdot(A-B)+scdot(C-B).$$
      Now $P$ is in the smaller of the two possible angles if and only if $r$ and $s$ are both positive. It is on the ray $BA$ if and only if $s=0$ and $rge0$, and on the ray $BC$ if and only if $r=0$ and $sge 0$. In all other cases, it is in the larger angle.






      share|cite|improve this answer









      $endgroup$















        3












        3








        3





        $begingroup$

        Unless $A-B$ and $C-B$ are linearly dependent, you can uniquely express $P-B$ in terms of them:
        $$ P-B=rcdot(A-B)+scdot(C-B).$$
        Now $P$ is in the smaller of the two possible angles if and only if $r$ and $s$ are both positive. It is on the ray $BA$ if and only if $s=0$ and $rge0$, and on the ray $BC$ if and only if $r=0$ and $sge 0$. In all other cases, it is in the larger angle.






        share|cite|improve this answer









        $endgroup$



        Unless $A-B$ and $C-B$ are linearly dependent, you can uniquely express $P-B$ in terms of them:
        $$ P-B=rcdot(A-B)+scdot(C-B).$$
        Now $P$ is in the smaller of the two possible angles if and only if $r$ and $s$ are both positive. It is on the ray $BA$ if and only if $s=0$ and $rge0$, and on the ray $BC$ if and only if $r=0$ and $sge 0$. In all other cases, it is in the larger angle.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered 10 hours ago









        Hagen von EitzenHagen von Eitzen

        291k23 gold badges279 silver badges514 bronze badges




        291k23 gold badges279 silver badges514 bronze badges





















            1












            $begingroup$

            You can sort this out by comparing the signs of three determinants. Let $$d_0 = detbeginbmatrixB_x&B_y&1\A_x&A_y&1\C_x&C_y&1endbmatrix.$$ This tells you the direction in which the vertices of $triangleBAC$ are traversed: positive means counterclockwise, negative clockwise, and the points are colinear if it’s zero. Note that the area of this triangle is equal to $frac12lvert d_0rvert = frac12lVert A-BrVert,lVert C-BrVert,lvertsinphirvert$, with $lvertphirvertin[0,pi)$, so when the points aren’t colinear this is another way to find the angle between them. Moreover, unlike the dot product, this determinant can tell left from right. On the other hand, it can’t tell the order of the points when they’re colinear, which the dot product can.



            Now, assuming that $d_0ne0$, compare the signs of the corresponding determinants for $triangleAPB$ and $triangleBPC$ $$d_A=detbeginbmatrixA_x&A_y&1\P_x&P_y&1\B_x&B_y&1endbmatrix text and d_C=detbeginbmatrixB_x&B_y&1\P_x&P_y&1\C_x&C_y&1endbmatrix,$$ respectively, to the sign of $d_0$: If they are all the same, then $P$ lies within the “narrow” side and you can use the angle $theta$ computed in your question; if any differ, then $P$ is on the “wide” side and you want $2pi-theta$. If either $d_A$ or $d_C$ is zero, ignore it; if both are zero, then $P=B$ and you might as well use $theta$.



            If you expand these determinants, you might find that the resulting expressions look familiar. For example, $d_0 = (A-B)wedge(C-B)$, where $mathbf vwedgemathbf w=v_x w_y-v_y w_x$ is the “two-dimensional cross product” of the vectors.






            share|cite|improve this answer









            $endgroup$












            • $begingroup$
              This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
              $endgroup$
              – retrovius
              8 hours ago










            • $begingroup$
              @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
              $endgroup$
              – amd
              8 hours ago
















            1












            $begingroup$

            You can sort this out by comparing the signs of three determinants. Let $$d_0 = detbeginbmatrixB_x&B_y&1\A_x&A_y&1\C_x&C_y&1endbmatrix.$$ This tells you the direction in which the vertices of $triangleBAC$ are traversed: positive means counterclockwise, negative clockwise, and the points are colinear if it’s zero. Note that the area of this triangle is equal to $frac12lvert d_0rvert = frac12lVert A-BrVert,lVert C-BrVert,lvertsinphirvert$, with $lvertphirvertin[0,pi)$, so when the points aren’t colinear this is another way to find the angle between them. Moreover, unlike the dot product, this determinant can tell left from right. On the other hand, it can’t tell the order of the points when they’re colinear, which the dot product can.



            Now, assuming that $d_0ne0$, compare the signs of the corresponding determinants for $triangleAPB$ and $triangleBPC$ $$d_A=detbeginbmatrixA_x&A_y&1\P_x&P_y&1\B_x&B_y&1endbmatrix text and d_C=detbeginbmatrixB_x&B_y&1\P_x&P_y&1\C_x&C_y&1endbmatrix,$$ respectively, to the sign of $d_0$: If they are all the same, then $P$ lies within the “narrow” side and you can use the angle $theta$ computed in your question; if any differ, then $P$ is on the “wide” side and you want $2pi-theta$. If either $d_A$ or $d_C$ is zero, ignore it; if both are zero, then $P=B$ and you might as well use $theta$.



            If you expand these determinants, you might find that the resulting expressions look familiar. For example, $d_0 = (A-B)wedge(C-B)$, where $mathbf vwedgemathbf w=v_x w_y-v_y w_x$ is the “two-dimensional cross product” of the vectors.






            share|cite|improve this answer









            $endgroup$












            • $begingroup$
              This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
              $endgroup$
              – retrovius
              8 hours ago










            • $begingroup$
              @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
              $endgroup$
              – amd
              8 hours ago














            1












            1








            1





            $begingroup$

            You can sort this out by comparing the signs of three determinants. Let $$d_0 = detbeginbmatrixB_x&B_y&1\A_x&A_y&1\C_x&C_y&1endbmatrix.$$ This tells you the direction in which the vertices of $triangleBAC$ are traversed: positive means counterclockwise, negative clockwise, and the points are colinear if it’s zero. Note that the area of this triangle is equal to $frac12lvert d_0rvert = frac12lVert A-BrVert,lVert C-BrVert,lvertsinphirvert$, with $lvertphirvertin[0,pi)$, so when the points aren’t colinear this is another way to find the angle between them. Moreover, unlike the dot product, this determinant can tell left from right. On the other hand, it can’t tell the order of the points when they’re colinear, which the dot product can.



            Now, assuming that $d_0ne0$, compare the signs of the corresponding determinants for $triangleAPB$ and $triangleBPC$ $$d_A=detbeginbmatrixA_x&A_y&1\P_x&P_y&1\B_x&B_y&1endbmatrix text and d_C=detbeginbmatrixB_x&B_y&1\P_x&P_y&1\C_x&C_y&1endbmatrix,$$ respectively, to the sign of $d_0$: If they are all the same, then $P$ lies within the “narrow” side and you can use the angle $theta$ computed in your question; if any differ, then $P$ is on the “wide” side and you want $2pi-theta$. If either $d_A$ or $d_C$ is zero, ignore it; if both are zero, then $P=B$ and you might as well use $theta$.



            If you expand these determinants, you might find that the resulting expressions look familiar. For example, $d_0 = (A-B)wedge(C-B)$, where $mathbf vwedgemathbf w=v_x w_y-v_y w_x$ is the “two-dimensional cross product” of the vectors.






            share|cite|improve this answer









            $endgroup$



            You can sort this out by comparing the signs of three determinants. Let $$d_0 = detbeginbmatrixB_x&B_y&1\A_x&A_y&1\C_x&C_y&1endbmatrix.$$ This tells you the direction in which the vertices of $triangleBAC$ are traversed: positive means counterclockwise, negative clockwise, and the points are colinear if it’s zero. Note that the area of this triangle is equal to $frac12lvert d_0rvert = frac12lVert A-BrVert,lVert C-BrVert,lvertsinphirvert$, with $lvertphirvertin[0,pi)$, so when the points aren’t colinear this is another way to find the angle between them. Moreover, unlike the dot product, this determinant can tell left from right. On the other hand, it can’t tell the order of the points when they’re colinear, which the dot product can.



            Now, assuming that $d_0ne0$, compare the signs of the corresponding determinants for $triangleAPB$ and $triangleBPC$ $$d_A=detbeginbmatrixA_x&A_y&1\P_x&P_y&1\B_x&B_y&1endbmatrix text and d_C=detbeginbmatrixB_x&B_y&1\P_x&P_y&1\C_x&C_y&1endbmatrix,$$ respectively, to the sign of $d_0$: If they are all the same, then $P$ lies within the “narrow” side and you can use the angle $theta$ computed in your question; if any differ, then $P$ is on the “wide” side and you want $2pi-theta$. If either $d_A$ or $d_C$ is zero, ignore it; if both are zero, then $P=B$ and you might as well use $theta$.



            If you expand these determinants, you might find that the resulting expressions look familiar. For example, $d_0 = (A-B)wedge(C-B)$, where $mathbf vwedgemathbf w=v_x w_y-v_y w_x$ is the “two-dimensional cross product” of the vectors.







            share|cite|improve this answer












            share|cite|improve this answer



            share|cite|improve this answer










            answered 8 hours ago









            amdamd

            34.8k2 gold badges10 silver badges56 bronze badges




            34.8k2 gold badges10 silver badges56 bronze badges











            • $begingroup$
              This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
              $endgroup$
              – retrovius
              8 hours ago










            • $begingroup$
              @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
              $endgroup$
              – amd
              8 hours ago

















            • $begingroup$
              This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
              $endgroup$
              – retrovius
              8 hours ago










            • $begingroup$
              @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
              $endgroup$
              – amd
              8 hours ago
















            $begingroup$
            This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
            $endgroup$
            – retrovius
            8 hours ago




            $begingroup$
            This is also a viable solution! It's very intuitive and clever! I implemented @Parcly_Taxel's answer because it was a little bit simpler to translate into C# code, and requires fewer computational steps, but thank you for your answer!
            $endgroup$
            – retrovius
            8 hours ago












            $begingroup$
            @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
            $endgroup$
            – amd
            8 hours ago





            $begingroup$
            @retrovius The determinant (equiv. cross product) approach can be more numerically stable when the angle between the two vectors is small or they’re very short. In solving the linear system, you end up dividing by a small number, which can be problematic.
            $endgroup$
            – amd
            8 hours ago











            retrovius is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            retrovius is a new contributor. Be nice, and check out our Code of Conduct.












            retrovius is a new contributor. Be nice, and check out our Code of Conduct.











            retrovius is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3277979%2fangle-between-two-vectors-facing-a-point%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

            Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

            Ласкавець круглолистий Зміст Опис | Поширення | Галерея | Примітки | Посилання | Навігаційне меню58171138361-22960890446Bupleurum rotundifoliumEuro+Med PlantbasePlants of the World Online — Kew ScienceGermplasm Resources Information Network (GRIN)Ласкавецькн. VI : Літери Ком — Левиправивши або дописавши її