Created
June 2, 2015 10:44
-
-
Save adusak/c7aa945457e34d1bc214 to your computer and use it in GitHub Desktop.
Point class
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 | |
| __author__ = 'Adam' | |
| class Point: | |
| def __init__(self, x, y): | |
| self.x = x | |
| self.y = y | |
| def apply_transformation(self, transformations): | |
| p_mat = np.matrix([[self.x], [self.y], [1]]) | |
| res = np.dot(transformations, p_mat) | |
| self.x = res[0, 0] | |
| self.y = res[1, 0] | |
| return self | |
| def draw_to_svg(self, svg): | |
| svg.add_circle((self.x, self.y), 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment