This repository has been archived by the owner on Oct 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Point.py
66 lines (52 loc) · 1.51 KB
/
Point.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#Point class
from Vector import Vector
import numpy as np
class Point:
pt_id = 0
def __init__(self, coord, normal, dir):
self._id = self._gen_id()
self.coord = coord
self.normal = normal
self.dir = dir
def _gen_id(self):
"""
Increments the Class id variable
"""
Point.pt_id += 1
return Point.pt_id
def copy_translate(self, v):
"""
Copies a point by translating by a given coordinate by copying
the original point
Parameters
----------
v : (3,1) array
translation vector
"""
c = self.coord + v
return c
def move_translate(self, v):
"""
Copies a point by translating by a given coordinate by modifying
the original point
Parameters
----------
v (3,1) array - translation vector
"""
new_v = self.coord + v
return new_v
# Creates new point for L/R offset
def ortho_offset(self, offset):
"""Creates a new point offset in the transverse direction
Parameters
----------
offset : float
offset magnitude
Returns
-------
np.array(3,1)
New coordinate vector
"""
ortho = np.cross(self.normal,self.dir)
ortho *= offset
return self.copy_translate(ortho)