-
Notifications
You must be signed in to change notification settings - Fork 1
/
curved_path_test_v2.sage
120 lines (81 loc) · 6.03 KB
/
curved_path_test_v2.sage
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
R = RealField(1000)
u, v = var('u, v')
# There are 44 track pieces.
# The Outer Edge Track Height function was empirically determined to be
# H = 12*cos[pi/11(u-17)] + 39.5, where u is the number of the Track Piece at which
# the height was meaured, and Z is in inches.
# Pieces 8 -- 22 comprise Red Curved portion of the Track.
# The Track Height is parametrized with polar coordinates (u,v) over the interval [-pi/2, pi/2].
# A scale factor (14/pi) maps the interval [-pi/2,pi/2] to the corresponding
# track piece in [8,22]. The interval [8,22] is used to compute the Outer Edge Track Heights.
# The Track Surface is rendered as a linear percentage of the Outer Edge Track
# Height over the 12-foot Track Width, as (v-16)/12, where v ranges over [16,28],
# the radial distance from the center of Curvature.
# Linear Conversion with Slope (14/pi) and initial point (-pi/2,8)
Track_Piece_Conversion(u) = 8+(14/pi)*(u+pi/2)
# X-coordinates of Red Curved Track Surface
Red_Curved_Track_Surface_X(u, v) = v*cos(u)
# Y-coordinates of Red Curved Track Surface
Red_Curved_Track_Surface_Y(u, v) = v*sin(u)
# Z-coordinates of Red Curved Track Surface
Red_Curved_Track_Surface_Z(u, v) = ( ( ( v-16 )/12 )*( 12*cos( (pi/11)*( Track_Piece_Conversion(u) - 17 ) ) + 39.5 ) )/12
# Red Curved Track Surface Plot, rendered over [-pi/2,0] only
# This piece of the Optimal Curve (see below) is defined over [-pi/2,0]
Red_Curved_Track_Surface = parametric_plot3d([Red_Curved_Track_Surface_X, Red_Curved_Track_Surface_Y, Red_Curved_Track_Surface_Z], (u, -pi/2, 0), (v, 16, 28), color="red", opacity=0.5, axes=True, mesh=False)
# Blue Test Path. This is a simple path with radius that decays *linearly* from 28 to 16 over the
# interval [-pi/2,pi/2]. It is parametrized by the angle u over [-pi/2,pi/2], and given "thickness"
# with parameter v, acting as a small epsilon interval around the radial distance of the (x,y)
# coordinate of the Path. This path renders perfectly in the plane of the Red Curved Track Surface.
# Radius of Blue Test Path
Test_Path_Radius(u,v) = v*(16 - (12/pi)*(u-pi/2))
# X-coordinates of Blue Test Path
Test_Path_X(u,v) = v*(16-(12/pi*(u-pi/2)))*cos(u)
# Y-coordinates of Blue Test Path
Test_Path_Y(u,v) = v*(16-(12/pi*(u-pi/2)))*sin(u)
# Z-coordinates of Blue Test Path
Test_Path_Z(u,v) = ( ( (Test_Path_Radius(u,v) - 16)/12 ) * ( 12*cos( (pi/11)*(Track_Piece_Conversion(u) - 17) ) + 39.5 ) )/12
# Blue Test Path Plot
Blue_Test_Path = parametric_plot3d([Test_Path_X, Test_Path_Y, Test_Path_Z], (u, -pi/2, 0), (v, 0.99, 1.01), color="blue", opacity=1)
# Optimal Path Equation. This was determined during our Research Project to be an "optimal" path
# around the Track. The curve is tangent to the Track at its Outer and Inner Edges at specific
# points to simulate a "fastest" circuit around the Track. This path was determined empirically
# through trial & error by modeling curves that conformed within the Track boundaries and met the
# desired tangent conditions. A 2-d model can be seen at https://www.desmos.com/calculator/g4qoelrkco.
# The Optimal Path was first defined in Rectangular coordinates, parametrized by rational powers of
# cosine and sine. The Radius of the Optimal Path needs to be computed. Here, it is done with the
# Sage square root function. Then, as above, Z-coordinates of the Optimal Path are computed as a
# polar function of the Radial distance and angle over [-pi/2,pi/2].
# Currently, the Z-coordinates of the Optimal Path are being computed inaccurately, as the rendered
# path does not remain in the plane of the Red Curved Track Surface.
# X-coordinates of Optimal Path
Optimal_Path_X(u,v) = v*(16*(real_nth_root(cos(u),6)**5))
FC_Optimal_Path_X = fast_callable(Optimal_Path_X, vars=[u,v], domain = R)
# Y-coordinates of Optimal Path
Optimal_Path_Y(u,v) = v*(-28*(real_nth_root(sin(-u),6)**5))
FC_Optimal_Path_Y = fast_callable(Optimal_Path_Y, vars=[u,v], domain = R)
# Radius of Optimal Path Curve (w/Sage square root function)
Optimal_Path_Radius_Sage(u,v) = sqrt( ( Optimal_Path_X(u,v) )**2 + ( Optimal_Path_Y(u,v) )**2 )
FC_Optimal_Path_Radius_Sage = fast_callable(Optimal_Path_Radius_Sage, vars=[u,v], domain = R)
# Z-coordinates of Optimal Path
Optimal_Path_Z(u,v) = ( ( ( Optimal_Path_Radius_Sage(u,v) - 16 ) / 12 )*( 12*cos((pi/11)*( Track_Piece_Conversion(u) - 17 ) ) + 39.5 ) )/12
FC_Optimal_Path_Z = fast_callable(Optimal_Path_Z, vars=[u,v], domain = R)
# Optimal Path Plot
Optimal_Path = parametric_plot3d([Optimal_Path_X, Optimal_Path_Y, Optimal_Path_Z], (u, -pi/2, 0), (v, 0.99, 1.01), color="black", opacity=1)
FC_Optimal_Path = parametric_plot3d([FC_Optimal_Path_X, FC_Optimal_Path_Y, FC_Optimal_Path_Z], (u, -pi/2, 0), (v, 0.99, 1.01), color="green", opacity=0.5)
'''
coordinate_right_curve_x(u) = (16*(cos(u))^(exponent_2))
f_right_curve_x(u,v) = v*(16*(cos(u))^(exponent_2))
g_right_curve_x = fast_callable(f_right_curve_x, vars=[u,v], domain = R)
coordinate_right_curve_y(u) = (-28*(sin(-u))^(exponent_2))
f_right_curve_y(u,v) = v*(-28*(sin(-u))^(exponent_2))
g_right_curve_y = fast_callable(f_right_curve_y, vars=[u,v], domain = R)
f_right_curve_path_radius(u,v) = sqrt((coordinate_right_curve_x(u))^2+(coordinate_right_curve_y(u))^2)
g_right_curve_path_radius = fast_callable(f_right_curve_path_radius, vars=[u,v], domain = R)
f_right_curve_z(u,v) = ( ( (f_right_curve_path_radius(u) - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u(u) - 17) ) + 39.5 ) )/12
g_right_curve_z = fast_callable(f_right_curve_z, vars=[u,v], domain = R)
#right_curve_z_2(u,v) = ( ( (right_curve_path_radius_2 - 16)/12 ) * ( 12*cos( (pi/11)*(right_curve_u - 17) ) + 39.5 ) )/12
right_curve_xy_plane = parametric_plot3d([f_right_curve_x, f_right_curve_y, 0], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="black")
f_right_curve = parametric_plot3d([f_right_curve_x(u,v), f_right_curve_y(u,v), f_right_curve_z(u,v)], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="red")
g_right_curve = parametric_plot3d([g_right_curve_x, g_right_curve_y, g_right_curve_z], (u, -pi/2, -0.01), (v, 0.99, 1.01), color="green")
'''
show(Red_Curved_Track_Surface+Blue_Test_Path+Optimal_Path+FC_Optimal_Path)