-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathredBird_OpenSCAD.scad
143 lines (124 loc) · 16.4 KB
/
redBird_OpenSCAD.scad
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Generated by SolidPython 1.1.3 on 2022-10-13 23:23:37
$fn= $preview ? 120 : 360;
union() {
color(alpha = 1.0000000000, c = "red") {
union() {
translate(v = [0, 1.0000000000, 0]) {
rotate(a = 90, v = [1, 0, 0]) {
linear_extrude(height = 2.0000000000) {
polygon(points = [[9.046605001970015, 14.384697649111615], [9.993902324621477, 14.531604720538846], [10.941199647272931, 14.678511791966079], [11.855663333270794, 14.86913450533781], [12.742359143698758, 15.096718512542449], [13.623989193043021, 15.330024953563857], [14.44998968085705, 15.625809114617535], [15.275990168671077, 15.921687086061652], [16.06399744835738, 16.252462522749024], [16.829208803167038, 16.604063866113812], [17.584288635809298, 16.962982419932832], [18.288710857614586, 17.358017974070812], [18.993133079419874, 17.753053528208785], [19.654402521623293, 18.17004071370945], [20.297941800033772, 18.596033696692245], [21.056961669074468, 19.139571098894912], [22.161109964539673, 20.034522223681495], [23.265258260004877, 20.929473348468075], [24.17568809921387, 21.80406761852943], [25.035460327585884, 22.673408506726208], [25.813336085104787, 23.500909960787258], [26.428075573650535, 24.245107788138615], [27.042908872586725, 24.98930561548997], [27.550516895251317, 25.707799395861084], [28.04302144505525, 26.422634571005084], [28.300343346029006, 26.835400288936004], [28.335240811272254, 26.144674384134788], [28.348374265933696, 24.483949042195917], [28.36150772059513, 22.82322370025704], [28.181767012514303, 21.32807369744273], [27.99395861085574, 19.839959473911332], [27.71637366554719, 18.433835531623483], [27.349668849321745, 17.109232818626992], [26.97611587459427, 15.791290643351658], [26.452653895945513, 14.621287453798383], [25.92919191729676, 13.451190453854668], [25.32692921067937, 12.366273288429426], [24.668849321750876, 11.34167620405636], [23.99641644308523, 10.33443404191448], [23.225764085630118, 9.446331075629937], [22.455205538565448, 8.558228109345391], [21.624045479277278, 7.755304977579316], [20.76305371582956, 6.994690331901161], [19.88761515225426, 6.258935439689299], [18.95832942456706, 5.616615696354527], [18.028949886489425, 4.974389763410195], [17.064954314339854, 4.41443554288073], [16.089420064166305, 3.8815925251880894], [15.106850034709844, 3.3782059700932474], [14.107300324583951, 2.945646259779733], [13.107750614458057, 2.5130865494662187], [12.106606127694704, 2.1568884969699242], [11.105086399369595, 1.815700106943845], [10.111259123060467, 1.5055629561530235], [9.13000243907015, 1.2466462785418113], [8.148651944689389, 0.9877296009305992], [6.402277716279855, 0.684534419032252], [4.588735248316104, 0.3773992007354735], [2.9347642544888264, 0.17214206645528057], [1.4673821272444132, 0.08583650725154318], [0.0, 0.0], [-1.474699337698646, 0.10403572299667911], [-2.949492485787727, 0.20807144599335822], [-4.102797425842886, 0.33312069644833864], [-4.987617028462073, 0.4758063003058218], [-5.878346685678907, 0.6247772003227077], [-6.832867408394157, 0.8392277528659073], [-7.787294320718964, 1.053678305409107], [-8.77211579954596, 1.3185988480084057], [-9.774855062946774, 1.6132572843768176], [-10.78219103547909, 1.9230191936058838], [-11.811760070545414, 2.306422259329443], [-12.841329105611738, 2.6898253250530026], [-13.874744366686055, 3.1424604589204295], [-14.909754404397834, 3.622957278748194], [-15.940730595320737, 4.130377680631907], [-16.95969905626747, 4.716505000093811], [-17.97866751721421, 5.302726129946152], [-18.967898084391827, 5.979661907352859], [-19.949436199553464, 6.680050282369275], [-20.911086511942063, 7.4216214187883445], [-21.833805512298543, 8.244526163717893], [-22.75643070226458, 9.067337098257003], [-23.60860428901105, 10.005441002645453], [-24.45092778476144, 10.959305052627629], [-25.25047374247172, 11.97198821741496], [-25.991200585376838, 13.0653483179797], [-26.73183361789152, 14.158802228934876], [-27.3538903168915, 15.394660312576223], [-27.971444117150416, 16.636053209253458], [-28.51601343364791, 17.956340644289764], [-28.988911611850128, 19.354209272218995], [-29.45411733803636, 20.759676541773768], [-29.761064935552263, 22.322370025704046], [-30.067918722677724, 23.885157320024767], [-30.26463911142798, 25.54982269836207], [-30.384059738456635, 27.285971594213777], [-30.48424923544532, 28.965740445411736], [-30.455261824799713, 30.267641043922023], [-30.42636822454455, 31.569541642432313], [-30.344659374472318, 32.784104767444035], [-30.2371526670294, 33.95598416480609], [-30.11510534906846, 35.104223343777555], [-29.939210866995627, 36.16559410120265], [-29.763316384922792, 37.22705866901818], [-29.54323720895326, 38.219854031032476], [-29.308898853637032, 39.19041633051276], [-29.06020750858365, 40.139777481753875], [-28.777556802191413, 41.03913769489108], [-28.49490609579917, 41.93849790802829], [-28.180078425486407, 42.79451772078275], [-27.859059269404682, 43.6422822191786], [-27.387474436668604, 44.78348561886714], [-26.670669243325392, 46.40255914745117], [-25.953864049982176, 48.021632676035196], [-25.20694572130809, 49.667254545113416], [-24.457400701701722, 51.31522167395261], [-23.72999493423892, 53.04930674121465], [-23.02810559297548, 54.88301844312276], [-22.328467701082573, 56.71194581511848], [-22.020488189271845, 57.747424904782456], [-21.712508677461113, 58.78299780483686], [-21.42751271130791, 59.87617028462072], [-21.16156025441378, 61.016904632357075], [-20.90020450665116, 62.1688962269461], [-20.686316816450592, 63.43449220435655], [-20.472429126250024, 64.70018199215745], [-20.297847989643337, 66.0570554794649], [-20.146062777913283, 67.46711945815119], [-20.00900579748213, 68.90316891498904], [-19.94258804105143, 70.46286046642527], [-19.876076474230285, 72.02264582825194], [-19.886677048349878, 73.50879003358412], [-19.928141240923846, 74.96566539709939], [-19.993527083059718, 76.39627385129178], [-20.12852023490122, 77.75061445805737], [-20.263607197133155, 79.10495506482299], [-20.461922362520873, 80.37777444229722], [-20.676185294283197, 81.6298617234845], [-20.912681288579527, 82.84733297059982], [-21.191954820915967, 83.9975421677705], [-21.471322163642846, 85.14775136494117], [-21.79534325221862, 86.20837163924276], [-22.125462016172914, 87.25698418356818], [-22.47087187376874, 88.2626315690726], [-22.837389069213305, 89.20992889172405], [-23.203812454267435, 90.1572262143755], [-23.591624608341622, 91.00696073097056], [-23.980281055929755, 91.85322426311939], [-24.570629842961406, 92.97575939511061], [-25.356948535619807, 94.36659224375691], [-26.139233381489333, 95.73763110002064], [-26.842529878609355, 96.72808120227397], [-27.545826375729376, 97.71843749413685], [-28.132422747143476, 98.47370494756], [-28.63824837238973, 99.06611756318131], [-29.102703615452448, 99.60609017054729], [-29.29670350287998, 99.80299818007843], [-29.49079720069795, 100.0], [-29.349237321525735, 99.94971763072479], [-29.045760708456072, 99.78020225520179], [-28.63355785286778, 99.53188615171017], [-27.82725754704591, 98.99791740933226], [-27.0208634308336, 98.46394866695435], [-25.951612600611643, 97.62481472447888], [-24.798401470946924, 96.68821178633745], [-23.79378599973733, 95.84326159965478], [-23.13589373158971, 95.21201148239179], [-22.47800146344209, 94.58085517551925], [-21.796375166513446, 93.85288654571382], [-21.11024597084373, 93.10671870016324], [-20.42083341150866, 92.31467757368806], [-19.725979849528137, 91.44880766993752], [-19.03122009793805, 90.58293776618699], [-18.34640424773448, 89.60186870297754], [-17.662432691044863, 88.61151241111466], [-16.992626503311506, 87.56074222780916], [-16.338955702733635, 86.44111521792153], [-15.685753954107957, 85.32026867295822], [-15.081896470853113, 84.06668042552393], [-14.478038987598268, 82.81299836769921], [-13.912362333252032, 81.48286084166683], [-13.377830728531492, 80.09033940599261], [-12.851554438169572, 78.68459070526653], [-12.40586127319462, 77.14853937222088], [-11.960168108219667, 75.61248803917522], [-11.583237959436387, 73.98234488451942], [-11.245801985027862, 72.29797932418995], [-10.930974314715098, 70.5865963714141], [-10.721495712865158, 68.74913225388845], [-10.511923300624778, 66.91157432597235], [-10.430308260942983, 65.42289724009832], [-10.39888178014597, 64.07146475543631], [-10.397474624289387, 62.71656128632808], [-10.481810165293908, 61.35199534700464], [-10.56614570629843, 59.98742940768119], [-10.723371920673936, 58.618079138445374], [-10.898797350794576, 57.247509334133845], [-11.097112516182293, 55.87740858177452], [-11.339049513124076, 54.50815212292913], [-11.580986510065857, 53.13889566408375], [-12.126775361639055, 50.58659637141409], [-12.71215219797745, 47.88044803842473], [-13.285146062777915, 45.213137207077054], [-13.84181691964202, 42.59798495281337], [-14.398393966115687, 39.982832698549686], [-14.615565019981615, 38.68449689487608], [-14.821666447775756, 37.429032439633005], [-14.986491303776807, 36.19608247809527], [-15.111728175012667, 34.9848027167489], [-15.231430233212633, 33.77624345672526], [-15.251224225595227, 32.61646559972982], [-15.270924407587385, 31.456593932343946], [-15.213512448638813, 30.33161973020131], [-15.103191429482731, 29.23037955683972], [-14.971950693258787, 28.138145180960244], [-14.707030150659488, 27.102666091296275], [-14.44220341845063, 26.06728081202274], [-14.055892230623463, 25.08123979812004], [-13.611793842285973, 24.11874519221749], [-13.12304170809959, 23.173886939717445], [-12.475187151728926, 22.29150640724967], [-11.827426405748701, 21.40912587478189], [-11.362033058781593, 20.887071051989718], [-10.954051670763054, 20.47815156006679], [-10.527871066999381, 20.076174037036342], [-10.059663408319107, 19.689956659599616], [-9.591549560029272, 19.30383309255333], [-9.257209328505226, 19.052890298129423], [-8.947259798495283, 18.827463929904876], [-8.636559785361829, 18.603069475975158], [-8.325015478714423, 18.380363609073342], [-8.011970205819997, 18.160003001932495], [-7.697330156288111, 17.942550516895253], [-7.380626278166573, 17.728662826694688], [-7.061483329893619, 17.518902793673426], [-6.739619880297942, 17.313833280174116], [-6.414660687817784, 17.11411095892981], [-6.086230510891387, 16.92029869228316], [-5.754047918347437, 16.733053152967226], [-5.417643858233739, 16.552937203324642], [-5.076736899378978, 16.380513705698043], [-4.731045610611833, 16.216533143210942], [-4.380382371151431, 16.06108932625378], [-4.025122422559524, 15.914276065216985], [-3.665922437569187, 15.775624308148371], [-3.3030638473517335, 15.6450402446575], [-2.9371095142497987, 15.522148633182614], [-2.568434679825137, 15.406855663333271], [-2.1976022064203837, 15.298879903938163], [-1.825081145987732, 15.197939923825963], [-1.4513405504793715, 15.103754291825362], [-1.0768494718475017, 15.016229197545922], [-0.7019831516538776, 14.934989399425879], [-0.32730445224113064, 14.859847276684365], [0.04671757443854258, 14.790521398150057], [0.4197076868233942, 14.726824143042082], [0.7912906433516564, 14.66856789057956], [1.1613726336329007, 14.615471209591174], [1.5301412784479975, 14.567440289686484], [1.8975965777969535, 14.524193699694179], [2.2636447212893267, 14.485543818833374], [2.6282857089251173, 14.451396836713634], [2.9917071614852024, 14.42156513255408], [3.353815268579147, 14.39567346479296], [3.7146100302069436, 14.37372183343027], [4.074185256759035, 14.355522617685134], [4.432447137844986, 14.340794386386236], [4.789489483855231, 14.329349518752696], [5.145312294789771, 14.32100039400364], [5.50000938103904, 14.315653201748624], [5.853486932212611, 14.313026510816337], [6.2057449483104765, 14.313026510816337], [6.556877239723071, 14.31537177057731], [6.906977616840838, 14.319874669318374], [7.255858458882906, 14.326441396649091], [7.6037073866301395, 14.33469671100771], [7.9504305896921155, 14.344734422784667], [8.296121878459257, 14.356085480027767], [8.638905045122797, 14.368656072346571], [8.925777219084784, 14.379819508808795]]);
}
}
}
difference() {
color(alpha = 0.7000000000, c = "green") {
translate(v = [-0.5884575695604045, 0, 30.599793617141035]) {
rotate(a = 90, v = [1, 0, 0]) {
sphere(r = 30.599793617141035);
}
}
}
scale(v = [1, 1.4580000000, 1]) {
color(alpha = 0.5000000000, c = "blue") {
translate(v = [4.119202986922832, 0, 34.71899660406387]) {
rotate(a = 90, v = [1, 0, 0]) {
sphere(r = 20.596014934614157);
}
}
}
}
translate(v = [4.119202986922832, 0, 34.130539034503464]) {
rotate(a = 309.5000000000, v = [0, 1, 0]) {
translate(v = [-117.69151391208091, -117.69151391208091, 0]) {
cube(size = [235.38302782416181, 235.38302782416181, 58.845756956040454]);
}
}
}
translate(v = [4.119202986922832, 0, 34.130539034503464]) {
rotate(a = 102.5000000000, v = [0, 1, 0]) {
translate(v = [-117.69151391208091, -117.69151391208091, 0]) {
cube(size = [235.38302782416181, 235.38302782416181, 58.845756956040454]);
}
}
}
}
}
}
color(alpha = 1.0000000000, c = "Ivory") {
union() {
translate(v = [0, 0, -2.3000000000]) {
cylinder(center = true, h = 2.2000000000, r = 23.53830278241618);
}
translate(v = [0, 0, -1.1000000000]) {
cylinder(center = true, h = 3.2000000000, r = 7.846100927472061);
}
}
}
}
/***********************************************
********* SolidPython code: **********
************************************************
# Author: Yang XU <yang.xu@connect.ust.hk>
# LICENSE: MIT
import numpy as np
from solid import *
from solid.utils import *
def genRedBirdBodyPoints(targetHeight):
points = np.genfromtxt("redBird_body_points.csv", delimiter=",")
groundPointIndex = np.where(points == np.min(points[:, 1]))[0][0]
groundPointXDistance = points[groundPointIndex][0]
Xmax = max(points[:, 0])
Xmin = min(points[:, 0])
Ymax = max(points[:, 1])
Ymin = min(points[:, 1])
width = Xmax - Xmin
height = Ymax - Ymin
scaleFactor = targetHeight / height
pointsNormalized = (points - np.array([groundPointXDistance, Ymin])) * scaleFactor
return pointsNormalized, height/width
####################### Prepare geomoetry #######################
mm = 1
deg = 1
bodyHeight = 100*mm
startAngle = 12.5*deg
endAngle = startAngle + 27*deg
## Load points data & scale into `targetHeight` & move to the origin
pointsScaled, aspectRatio = genRedBirdBodyPoints(bodyHeight)
## Generate derivative parameters
bodyWidth = bodyHeight/aspectRatio
bodyThickness = bodyHeight/50
baseRadiusBottom = bodyWidth/2.5
baseRadiusTop = baseRadiusBottom/3
baseHeight = bodyThickness*1.1
dInterference = bodyHeight/100
##################### Generate OpenSCAD code #####################
## Generate redbird: body part
redbirdBody = polygon(pointsScaled)
redbirdBody = linear_extrude(bodyThickness)(redbirdBody)
redbirdBody = rotate(a=90, v=[1, 0, 0])(redbirdBody)
redbirdBody = translate([0, bodyThickness/2, 0])(redbirdBody)
## Generate redbird: wing part
wingSphereOuter = sphere(r=bodyWidth*0.52)
wingSphereOuter = color("green", alpha=0.7)(translate([-bodyWidth*0.01, 0, bodyWidth*0.52])(rotate(a=90, v=[1, 0, 0])((wingSphereOuter))))
wingSphereInner = sphere(r=bodyWidth*0.35)
wingSphereInner = color("blue", alpha=0.5)(translate([bodyWidth*0.07, 0, bodyWidth*0.59])(rotate(a=90, v=[1, 0, 0])((wingSphereInner))))
wingSphereInner = scale([1, 1.458, 1])(wingSphereInner)
xsecSurfaceLower = cube([bodyWidth*4, bodyWidth*4, bodyWidth])
xsecSurfaceLower = translate([-bodyWidth*2, -bodyWidth*2, 0])(xsecSurfaceLower)
xsecSurfaceLower = rotate(a = 90+startAngle, v=[0, 1, 0])(xsecSurfaceLower)
xsecSurfaceLower = translate([bodyWidth*0.07, 0, bodyWidth*0.58])(xsecSurfaceLower)
xsecSurfaceUpper = cube([bodyWidth*4, bodyWidth*4, bodyWidth])
xsecSurfaceUpper = translate([-bodyWidth*2, -bodyWidth*2, 0])(xsecSurfaceUpper)
xsecSurfaceUpper = rotate(a = 270+endAngle, v=[0, 1, 0])(xsecSurfaceUpper)
xsecSurfaceUpper = translate([bodyWidth*0.07, 0, bodyWidth*0.58])(xsecSurfaceUpper)
redbirdWing = wingSphereOuter - wingSphereInner - xsecSurfaceUpper - xsecSurfaceLower
## Generate redbird: merge into a whole redbird
redbird = color("red")(redbirdBody + redbirdWing)
## Generate supporting cylinders
baseTop = translate([0, 0, -baseHeight/2])(cylinder(r=baseRadiusTop, h=baseHeight+dInterference, center=True))
baseBottom = translate([0, 0, dInterference-baseHeight*3/2])(cylinder(r=baseRadiusBottom, h=baseHeight, center=True))
base = color("Ivory")(baseBottom + baseTop)
output = redbird + base
scad_render_to_file(output, "redBird_OpenSCAD.scad", file_header = '$fn= $preview ? 120 : 360;')
############ Please use OpenSCAD to generate 3D model ############
************************************************/