ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 25 Jul 2016 18:25:35 +0200The Pleasures of 'Perp Dot' Products in Sagemathhttps://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/Francis S. Hill, Jr. has an vector *operation* he calls *a-Perp*. It is defined as the vector perpendicular to **a** that is rotated 90° counterclockwise (Hill 1994:138). Wolfram also has [a page on the concept here](http://mathworld.wolfram.com/PerpendicularVector.html). Similar to the Normal vector, but not quite.
I wonder if there's a default Sage function, or some handy way, to do this?
Say I have vector **a**
a = vector(QQ, [3, 4])
and I want to get
a_Perp = vector(QQ, [-4, 3])
Hill, F. S. Jr. "The Pleasures of 'Perp Dot' Products." Ch. II.5 in Graphics Gems IV (Ed. P. S. Heckbert). San Diego: Academic Press, pp. 138-148, 1994.Mon, 25 Jul 2016 11:13:01 +0200https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/Answer by calc314 for <p>Francis S. Hill, Jr. has an vector <em>operation</em> he calls <em>a-Perp</em>. It is defined as the vector perpendicular to <strong>a</strong> that is rotated 90° counterclockwise (Hill 1994:138). Wolfram also has <a href="http://mathworld.wolfram.com/PerpendicularVector.html">a page on the concept here</a>. Similar to the Normal vector, but not quite.</p>
<p>I wonder if there's a default Sage function, or some handy way, to do this?</p>
<p>Say I have vector <strong>a</strong></p>
<pre><code>a = vector(QQ, [3, 4])
</code></pre>
<p>and I want to get</p>
<pre><code>a_Perp = vector(QQ, [-4, 3])
</code></pre>
<p>Hill, F. S. Jr. "The Pleasures of 'Perp Dot' Products." Ch. II.5 in Graphics Gems IV (Ed. P. S. Heckbert). San Diego: Academic Press, pp. 138-148, 1994.</p>
https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?answer=34214#post-id-34214Alternatively, you can use the rotation matrix.
a = vector(QQ, [3, 4])
m=matrix(QQ,[[0,-1],[1,0]])
a_perp=m*a
Mon, 25 Jul 2016 15:45:38 +0200https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?answer=34214#post-id-34214Comment by etb for <p>Alternatively, you can use the rotation matrix.</p>
<pre><code>a = vector(QQ, [3, 4])
m=matrix(QQ,[[0,-1],[1,0]])
a_perp=m*a
</code></pre>
https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?comment=34219#post-id-34219I prefer this solution as it seems most flexible to me. Please chime in if if you have comments. I'm eager to learn.Mon, 25 Jul 2016 18:25:35 +0200https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?comment=34219#post-id-34219Answer by B r u n o for <p>Francis S. Hill, Jr. has an vector <em>operation</em> he calls <em>a-Perp</em>. It is defined as the vector perpendicular to <strong>a</strong> that is rotated 90° counterclockwise (Hill 1994:138). Wolfram also has <a href="http://mathworld.wolfram.com/PerpendicularVector.html">a page on the concept here</a>. Similar to the Normal vector, but not quite.</p>
<p>I wonder if there's a default Sage function, or some handy way, to do this?</p>
<p>Say I have vector <strong>a</strong></p>
<pre><code>a = vector(QQ, [3, 4])
</code></pre>
<p>and I want to get</p>
<pre><code>a_Perp = vector(QQ, [-4, 3])
</code></pre>
<p>Hill, F. S. Jr. "The Pleasures of 'Perp Dot' Products." Ch. II.5 in Graphics Gems IV (Ed. P. S. Heckbert). San Diego: Academic Press, pp. 138-148, 1994.</p>
https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?answer=34213#post-id-34213There is no such function defined in Sage. Yet, you can write it as:
sage: a_perp = vector([-a[1], a[0]])
sage: a_perp
(-4, 3)
If you think this function is useful, I urge you to add it (as well as maybe "perp-dot products") into Sage by creating a ticket on trac.sagemath.org.Mon, 25 Jul 2016 14:22:45 +0200https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?answer=34213#post-id-34213Comment by etb for <p>There is no such function defined in Sage. Yet, you can write it as:</p>
<pre><code>sage: a_perp = vector([-a[1], a[0]])
sage: a_perp
(-4, 3)
</code></pre>
<p>If you think this function is useful, I urge you to add it (as well as maybe "perp-dot products") into Sage by creating a ticket on <a href="http://trac.sagemath.org">trac.sagemath.org</a>.</p>
https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?comment=34218#post-id-34218@b-r-u-n-o, thank you for your feedback and your answer.Mon, 25 Jul 2016 18:23:10 +0200https://ask.sagemath.org/question/34212/the-pleasures-of-perp-dot-products-in-sagemath/?comment=34218#post-id-34218