Fast way to compare angles w/o their measures












1














I need an efficient way to compare the measures of two angles in $mathbb{R^2}$ that ideally relies on the smallest number of arithmetic operations and no trigonometric operations (no $arccos$) or square roots. Given two angles $angle{p_1p_0p_2}$ and $angle{p_3p_0p_4}$ whose measures are in the range $big(0,{pi}big)$ radians with vertex $p_0$ at the origin, what is the fastest way to compare the measures of the angles (i.e. find which angle has the largest measure/which one has the smallest measure)?



I understand that the $z$ component of the cross product of two or more pairs of vectors can be used to compare angles where $theta in big(0,frac{pi}{2}big)$ radians. As stated above, however, I need to compare angles with $theta in big(0,{pi}big)$.



Any ideas?










share|cite|improve this question




















  • 1




    What does it mean to "compare"?
    – AlexanderJ93
    Nov 27 '18 at 3:08










  • So the points are given as $(x, y)$ pairs, and you wish to compare what exactly about the angles?
    – Joppy
    Nov 27 '18 at 3:09










  • Compare as in find which angle has the largest measure.
    – rbjacob
    Nov 27 '18 at 3:10










  • As in, when the angles lie in the range $[0, pi]$, which is larger?
    – Joppy
    Nov 27 '18 at 3:16










  • Yes, but for range $big(0,pibig)$, not$big[0,pibig]$.
    – rbjacob
    Nov 27 '18 at 3:20


















1














I need an efficient way to compare the measures of two angles in $mathbb{R^2}$ that ideally relies on the smallest number of arithmetic operations and no trigonometric operations (no $arccos$) or square roots. Given two angles $angle{p_1p_0p_2}$ and $angle{p_3p_0p_4}$ whose measures are in the range $big(0,{pi}big)$ radians with vertex $p_0$ at the origin, what is the fastest way to compare the measures of the angles (i.e. find which angle has the largest measure/which one has the smallest measure)?



I understand that the $z$ component of the cross product of two or more pairs of vectors can be used to compare angles where $theta in big(0,frac{pi}{2}big)$ radians. As stated above, however, I need to compare angles with $theta in big(0,{pi}big)$.



Any ideas?










share|cite|improve this question




















  • 1




    What does it mean to "compare"?
    – AlexanderJ93
    Nov 27 '18 at 3:08










  • So the points are given as $(x, y)$ pairs, and you wish to compare what exactly about the angles?
    – Joppy
    Nov 27 '18 at 3:09










  • Compare as in find which angle has the largest measure.
    – rbjacob
    Nov 27 '18 at 3:10










  • As in, when the angles lie in the range $[0, pi]$, which is larger?
    – Joppy
    Nov 27 '18 at 3:16










  • Yes, but for range $big(0,pibig)$, not$big[0,pibig]$.
    – rbjacob
    Nov 27 '18 at 3:20
















1












1








1







I need an efficient way to compare the measures of two angles in $mathbb{R^2}$ that ideally relies on the smallest number of arithmetic operations and no trigonometric operations (no $arccos$) or square roots. Given two angles $angle{p_1p_0p_2}$ and $angle{p_3p_0p_4}$ whose measures are in the range $big(0,{pi}big)$ radians with vertex $p_0$ at the origin, what is the fastest way to compare the measures of the angles (i.e. find which angle has the largest measure/which one has the smallest measure)?



I understand that the $z$ component of the cross product of two or more pairs of vectors can be used to compare angles where $theta in big(0,frac{pi}{2}big)$ radians. As stated above, however, I need to compare angles with $theta in big(0,{pi}big)$.



Any ideas?










share|cite|improve this question















I need an efficient way to compare the measures of two angles in $mathbb{R^2}$ that ideally relies on the smallest number of arithmetic operations and no trigonometric operations (no $arccos$) or square roots. Given two angles $angle{p_1p_0p_2}$ and $angle{p_3p_0p_4}$ whose measures are in the range $big(0,{pi}big)$ radians with vertex $p_0$ at the origin, what is the fastest way to compare the measures of the angles (i.e. find which angle has the largest measure/which one has the smallest measure)?



I understand that the $z$ component of the cross product of two or more pairs of vectors can be used to compare angles where $theta in big(0,frac{pi}{2}big)$ radians. As stated above, however, I need to compare angles with $theta in big(0,{pi}big)$.



Any ideas?







linear-algebra rotations angle






share|cite|improve this question















share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Nov 27 '18 at 3:11

























asked Nov 27 '18 at 3:01









rbjacob

223




223








  • 1




    What does it mean to "compare"?
    – AlexanderJ93
    Nov 27 '18 at 3:08










  • So the points are given as $(x, y)$ pairs, and you wish to compare what exactly about the angles?
    – Joppy
    Nov 27 '18 at 3:09










  • Compare as in find which angle has the largest measure.
    – rbjacob
    Nov 27 '18 at 3:10










  • As in, when the angles lie in the range $[0, pi]$, which is larger?
    – Joppy
    Nov 27 '18 at 3:16










  • Yes, but for range $big(0,pibig)$, not$big[0,pibig]$.
    – rbjacob
    Nov 27 '18 at 3:20
















  • 1




    What does it mean to "compare"?
    – AlexanderJ93
    Nov 27 '18 at 3:08










  • So the points are given as $(x, y)$ pairs, and you wish to compare what exactly about the angles?
    – Joppy
    Nov 27 '18 at 3:09










  • Compare as in find which angle has the largest measure.
    – rbjacob
    Nov 27 '18 at 3:10










  • As in, when the angles lie in the range $[0, pi]$, which is larger?
    – Joppy
    Nov 27 '18 at 3:16










  • Yes, but for range $big(0,pibig)$, not$big[0,pibig]$.
    – rbjacob
    Nov 27 '18 at 3:20










1




1




What does it mean to "compare"?
– AlexanderJ93
Nov 27 '18 at 3:08




What does it mean to "compare"?
– AlexanderJ93
Nov 27 '18 at 3:08












So the points are given as $(x, y)$ pairs, and you wish to compare what exactly about the angles?
– Joppy
Nov 27 '18 at 3:09




So the points are given as $(x, y)$ pairs, and you wish to compare what exactly about the angles?
– Joppy
Nov 27 '18 at 3:09












Compare as in find which angle has the largest measure.
– rbjacob
Nov 27 '18 at 3:10




Compare as in find which angle has the largest measure.
– rbjacob
Nov 27 '18 at 3:10












As in, when the angles lie in the range $[0, pi]$, which is larger?
– Joppy
Nov 27 '18 at 3:16




As in, when the angles lie in the range $[0, pi]$, which is larger?
– Joppy
Nov 27 '18 at 3:16












Yes, but for range $big(0,pibig)$, not$big[0,pibig]$.
– rbjacob
Nov 27 '18 at 3:20






Yes, but for range $big(0,pibig)$, not$big[0,pibig]$.
– rbjacob
Nov 27 '18 at 3:20












2 Answers
2






active

oldest

votes


















1














Let $theta$ be the angle between $p_1$ and $p_2$, and $phi$ the one between $p_3$ and $p_4$. Since $p_1 cdot p_2 = |p_1| |p_2| cos theta$, the sign (positive or negative) of $p_1 cdot p_2$ tells you whether $theta in [0, pi/2)$ or $(pi/2, pi)$. Similarly for $phi$, and so you may already be able to tell which is larger.



If both dot products have the same sign, then define
$$ r_theta := (p_1 cdot p_2)^2 |p_3|^2 |p_4|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 theta$$
and
$$ r_phi := (p_3 cdot p_4)^2 |p_1|^2 |p_2|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 phi$$
and so comparing $r_theta$ and $r_phi$ tells you which has the largest cosine squared, from which you can figure out what is the larger angle. At worst, this takes 6 dot products, 4 multiplications, and 4 comparisons.






share|cite|improve this answer





















  • Thanks, this is clever and does the job perfectly!
    – rbjacob
    Nov 27 '18 at 4:16



















-1














Try the dot product. You will like the results.



Because, dot product of two vectors will be equal to the cosine of the angle between the vectors, times the lengths of each of the vectors.



You do the rest.






share|cite|improve this answer























  • The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
    – AlexanderJ93
    Nov 27 '18 at 3:14










  • @AlexanderJ93 The rest was done for the student here. No roots taken.
    – John L Winters
    Nov 27 '18 at 4:17













Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3015267%2ffast-way-to-compare-angles-w-o-their-measures%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Let $theta$ be the angle between $p_1$ and $p_2$, and $phi$ the one between $p_3$ and $p_4$. Since $p_1 cdot p_2 = |p_1| |p_2| cos theta$, the sign (positive or negative) of $p_1 cdot p_2$ tells you whether $theta in [0, pi/2)$ or $(pi/2, pi)$. Similarly for $phi$, and so you may already be able to tell which is larger.



If both dot products have the same sign, then define
$$ r_theta := (p_1 cdot p_2)^2 |p_3|^2 |p_4|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 theta$$
and
$$ r_phi := (p_3 cdot p_4)^2 |p_1|^2 |p_2|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 phi$$
and so comparing $r_theta$ and $r_phi$ tells you which has the largest cosine squared, from which you can figure out what is the larger angle. At worst, this takes 6 dot products, 4 multiplications, and 4 comparisons.






share|cite|improve this answer





















  • Thanks, this is clever and does the job perfectly!
    – rbjacob
    Nov 27 '18 at 4:16
















1














Let $theta$ be the angle between $p_1$ and $p_2$, and $phi$ the one between $p_3$ and $p_4$. Since $p_1 cdot p_2 = |p_1| |p_2| cos theta$, the sign (positive or negative) of $p_1 cdot p_2$ tells you whether $theta in [0, pi/2)$ or $(pi/2, pi)$. Similarly for $phi$, and so you may already be able to tell which is larger.



If both dot products have the same sign, then define
$$ r_theta := (p_1 cdot p_2)^2 |p_3|^2 |p_4|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 theta$$
and
$$ r_phi := (p_3 cdot p_4)^2 |p_1|^2 |p_2|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 phi$$
and so comparing $r_theta$ and $r_phi$ tells you which has the largest cosine squared, from which you can figure out what is the larger angle. At worst, this takes 6 dot products, 4 multiplications, and 4 comparisons.






share|cite|improve this answer





















  • Thanks, this is clever and does the job perfectly!
    – rbjacob
    Nov 27 '18 at 4:16














1












1








1






Let $theta$ be the angle between $p_1$ and $p_2$, and $phi$ the one between $p_3$ and $p_4$. Since $p_1 cdot p_2 = |p_1| |p_2| cos theta$, the sign (positive or negative) of $p_1 cdot p_2$ tells you whether $theta in [0, pi/2)$ or $(pi/2, pi)$. Similarly for $phi$, and so you may already be able to tell which is larger.



If both dot products have the same sign, then define
$$ r_theta := (p_1 cdot p_2)^2 |p_3|^2 |p_4|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 theta$$
and
$$ r_phi := (p_3 cdot p_4)^2 |p_1|^2 |p_2|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 phi$$
and so comparing $r_theta$ and $r_phi$ tells you which has the largest cosine squared, from which you can figure out what is the larger angle. At worst, this takes 6 dot products, 4 multiplications, and 4 comparisons.






share|cite|improve this answer












Let $theta$ be the angle between $p_1$ and $p_2$, and $phi$ the one between $p_3$ and $p_4$. Since $p_1 cdot p_2 = |p_1| |p_2| cos theta$, the sign (positive or negative) of $p_1 cdot p_2$ tells you whether $theta in [0, pi/2)$ or $(pi/2, pi)$. Similarly for $phi$, and so you may already be able to tell which is larger.



If both dot products have the same sign, then define
$$ r_theta := (p_1 cdot p_2)^2 |p_3|^2 |p_4|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 theta$$
and
$$ r_phi := (p_3 cdot p_4)^2 |p_1|^2 |p_2|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 cos^2 phi$$
and so comparing $r_theta$ and $r_phi$ tells you which has the largest cosine squared, from which you can figure out what is the larger angle. At worst, this takes 6 dot products, 4 multiplications, and 4 comparisons.







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Nov 27 '18 at 3:30









Joppy

5,563420




5,563420












  • Thanks, this is clever and does the job perfectly!
    – rbjacob
    Nov 27 '18 at 4:16


















  • Thanks, this is clever and does the job perfectly!
    – rbjacob
    Nov 27 '18 at 4:16
















Thanks, this is clever and does the job perfectly!
– rbjacob
Nov 27 '18 at 4:16




Thanks, this is clever and does the job perfectly!
– rbjacob
Nov 27 '18 at 4:16











-1














Try the dot product. You will like the results.



Because, dot product of two vectors will be equal to the cosine of the angle between the vectors, times the lengths of each of the vectors.



You do the rest.






share|cite|improve this answer























  • The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
    – AlexanderJ93
    Nov 27 '18 at 3:14










  • @AlexanderJ93 The rest was done for the student here. No roots taken.
    – John L Winters
    Nov 27 '18 at 4:17


















-1














Try the dot product. You will like the results.



Because, dot product of two vectors will be equal to the cosine of the angle between the vectors, times the lengths of each of the vectors.



You do the rest.






share|cite|improve this answer























  • The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
    – AlexanderJ93
    Nov 27 '18 at 3:14










  • @AlexanderJ93 The rest was done for the student here. No roots taken.
    – John L Winters
    Nov 27 '18 at 4:17
















-1












-1








-1






Try the dot product. You will like the results.



Because, dot product of two vectors will be equal to the cosine of the angle between the vectors, times the lengths of each of the vectors.



You do the rest.






share|cite|improve this answer














Try the dot product. You will like the results.



Because, dot product of two vectors will be equal to the cosine of the angle between the vectors, times the lengths of each of the vectors.



You do the rest.







share|cite|improve this answer














share|cite|improve this answer



share|cite|improve this answer








edited Nov 27 '18 at 3:12

























answered Nov 27 '18 at 3:06









John L Winters

829




829












  • The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
    – AlexanderJ93
    Nov 27 '18 at 3:14










  • @AlexanderJ93 The rest was done for the student here. No roots taken.
    – John L Winters
    Nov 27 '18 at 4:17




















  • The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
    – AlexanderJ93
    Nov 27 '18 at 3:14










  • @AlexanderJ93 The rest was done for the student here. No roots taken.
    – John L Winters
    Nov 27 '18 at 4:17


















The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
– AlexanderJ93
Nov 27 '18 at 3:14




The dot product is equal to the product of the magnitudes times the cosine of the angle. Since the magnitude involves taking square roots, I believe this violates the requirements in the question.
– AlexanderJ93
Nov 27 '18 at 3:14












@AlexanderJ93 The rest was done for the student here. No roots taken.
– John L Winters
Nov 27 '18 at 4:17






@AlexanderJ93 The rest was done for the student here. No roots taken.
– John L Winters
Nov 27 '18 at 4:17




















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


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


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%2f3015267%2ffast-way-to-compare-angles-w-o-their-measures%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

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...