Skip to content

Commit 4ddc829

Browse files
committed
Added radius function
no comments yet :(
1 parent f4998a7 commit 4ddc829

File tree

172 files changed

+80
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+80
-56
lines changed
Binary file not shown.

Image_based/bezier_cyl_2d.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828

2929
class BezierCyl2D:
30+
3031
def __init__(self, start_pt=None, end_pt=None, radius=1, mid_pt=None):
3132
""" Create a bezier from 2 points or an optional mid point
3233
@param start_pt - start point
@@ -45,8 +46,13 @@ def __init__(self, start_pt=None, end_pt=None, radius=1, mid_pt=None):
4546
self.p1 = 0.5 * (self.p0 + self.p2)
4647
else:
4748
self.p1 = np.array(mid_pt)
48-
self.radius_2d = radius
49-
49+
self.start_radius = radius
50+
self.end_radius = 100
51+
#want to pass every single point from start to end and return radius along that path
52+
def radius(self, t):
53+
return (1-t)*(self.start_radius) + (t*self.end_radius)
54+
55+
5056
@staticmethod
5157
def _orientation(start_pt, end_pt):
5258
"""Set the orientation and ensure left-right or down-up
@@ -92,7 +98,7 @@ def edge_pts(self, t):
9298
@return 2d pts, left and right edge"""
9399
pt = self.pt_axis(t)
94100
vec = self.tangent_axis(t)
95-
vec_step = self.radius_2d * vec / np.sqrt(vec[0] * vec[0] + vec[1] * vec[1])
101+
vec_step = self.radius(pt) * vec / np.sqrt(vec[0] * vec[0] + vec[1] * vec[1])
96102
left_pt = [pt[0] - vec_step[1], pt[1] + vec_step[0]]
97103
right_pt = [pt[0] + vec_step[1], pt[1] - vec_step[0]]
98104
return left_pt, right_pt
@@ -122,7 +128,7 @@ def _rect_corners(self, t1, t2, perc_width=0.3):
122128
edge_left1, edge_right1 = self.edge_pts(t1)
123129
edge_left2, edge_right2 = self.edge_pts(t2)
124130

125-
vec_step = perc_width * self.radius_2d * vec_ts / np.sqrt(vec_ts[0] * vec_ts[0] + vec_ts[1] * vec_ts[1])
131+
vec_step = perc_width * self.radius(t1) * vec_ts / np.sqrt(vec_ts[0] * vec_ts[0] + vec_ts[1] * vec_ts[1])
126132
rect_left = np.array([[edge_left1[0] + vec_step[1], edge_left1[1] - vec_step[0]],
127133
[edge_left2[0] + vec_step[1], edge_left2[1] - vec_step[0]],
128134
[edge_left2[0] - vec_step[1], edge_left2[1] + vec_step[0]],
@@ -144,7 +150,7 @@ def _rect_corners_interior(self, t1, t2, perc_width=0.3):
144150
pt1 = self.pt_axis(t1)
145151
pt2 = self.pt_axis(t2)
146152

147-
vec_step = perc_width * self.radius_2d * vec_ts / np.sqrt(vec_ts[0] * vec_ts[0] + vec_ts[1] * vec_ts[1])
153+
vec_step = perc_width * self.radius(t1) * vec_ts / np.sqrt(vec_ts[0] * vec_ts[0] + vec_ts[1] * vec_ts[1])
148154
rect = np.array([[pt1[0] + vec_step[1], pt1[1] - vec_step[0]],
149155
[pt2[0] + vec_step[1], pt2[1] - vec_step[0]],
150156
[pt2[0] - vec_step[1], pt2[1] + vec_step[0]],
@@ -231,7 +237,7 @@ def is_wire(self):
231237
@return True/False
232238
"""
233239
rad_clip = 3
234-
if self.radius_2d > rad_clip:
240+
if self.end_radius > rad_clip or self.start_radius > rad_clip:
235241
return False
236242

237243
line_axis = LineSeg2D(self.p0, self.p2)
@@ -487,10 +493,11 @@ def read_json(fname, bezier_crv=None):
487493
axs[2, i_row].imshow(im_debug)
488494
axs[2, i_row].set_title(crv.orientation + f" mask 0.25")
489495

490-
fname_test = "./Data/test_crv.json"
496+
fname_test = "./data/test_crv.json"
491497
crv.write_json(fname_test)
492498

493499
read_back_in_crv = BezierCyl2D.read_json(fname_test)
494500
plt.tight_layout()
501+
plt.show()
495502

496503
print("Done")

Image_based/data/forcindy.zip

-38.5 MB
Binary file not shown.

Image_based/data/forcindy/.DS_Store

6 KB
Binary file not shown.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
x,y,vx,vy
2-
319.2900075812432,255.26239081817556,0.9743718059016622,-0.22494351260690684
3-
273.0784097880878,308.3290172052674,-0.9912667782820428,-0.13187181000630635
1+
x,y,vx,vy
2+
319.2900075812432,255.26239081817556,0.9743718059016622,-0.22494351260690684
3+
273.0784097880878,308.3290172052674,-0.9912667782820428,-0.13187181000630635

Image_based/data/forcindy/0_edges.png

34.7 KB
390 KB

Image_based/data/forcindy/0_mask.png

10.1 KB

Image_based/data/forcindy/0_rects.png

1.03 MB

0 commit comments

Comments
 (0)