Last active
November 7, 2017 19:38
-
-
Save fedden/b83587c441738b0b5b89b13a1c1208b4 to your computer and use it in GitHub Desktop.
Orthogonal Vectors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import numpy as np | |
>>> # Two vectors, a and b. | |
>>> a = np.array([-3, 4]) | |
>>> b = np.array([4, 3]) | |
>>> # The dot product is 0. | |
>>> a.dot(b) | |
0 | |
>>> # For drawing the origin of the arrows. | |
>>> origin = np.array([0, 0]) | |
>>> # Plot the vectors using matplotlib. | |
>>> plt.figure() | |
>>> ax = plt.gca() | |
>>> ax.quiver(origin, origin, a, b, angles='xy', scale_units='xy', scale=1) | |
>>> ax.axis('equal') | |
>>> ax.set_xlim([-5, 5]) | |
>>> ax.set_ylim([-5, 5]) | |
>>> plt.draw() | |
>>> plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment