forked from Nate711/propscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Propeller.rb
81 lines (67 loc) · 1.79 KB
/
Propeller.rb
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
class Propeller
@geom
@airfoil
@keyRadii
@name
@radius
@hubFoil
def initialize
end
def name
@name
end
def translate radius
end
def getHubFoil
xFactor = @radius*0.08
yFactor = @radius*0.2
airfoilXYZ(translateShape(scaleShapeXY(@airfoil,xFactor,yFactor),xFactor/2.0,0),0)
end
def getFlatHub
radius = (0.012*@radius).round(0)
hub = roundRect((0.076*@radius).round(0)-radius/2.0,radius,true).clone
hub1 = Marshal.load(Marshal.dump(hub))
first = airfoilXYZ(hub,0)
second = airfoilXYZ(hub1,0.06)
ret = [first,second]
return ret
end
def rotate radius
r = @geom[2][@geom[0].find_index(radius)]#interpPointInSet(radius,[@geom[0],@geom[2]])# passing in radius and cloud of [radius,chord]
#p r
return r
end
def scale radius
#index = @
#print "index #{@geom[0].find_index(radius)}, radius #{radius}\n"
a = @geom[1][@geom[0].find_index(radius)]
return a*@radius
#interpPointInSet(radius,[@geom[0],@geom[1]])*@radius
end
def stiffness_modifier radius, chord
1.0
#custom-ish for 3d printing
end
def getFoil radius # returns pt cloud [[x,y] x n]
scaleFactor = scale(radius)
#p translate(radius)
return translateShape(
rotPoints(
scaleShapeXY(@airfoil,scaleFactor,stiffness_modifier(radius,scaleFactor)), #why so many f(radius)??
rotate(radius)),
translate(radius)[0],
translate(radius)[1])
end
def airfoilXYZ airfoil1,radius #returns array in [all x, all y, all z]
#print "\n\n"
return ((airfoil1.map {|n| n<<radius*@radius}).transpose).dup
end
def getXSections
xSections = getHubFoil() #gethubfoil = [foil1, foil2]
@keyRadii.each do |radius| #because we aren't interpolating we don't really need to use the key radii
foilWithZ = airfoilXYZ(getFoil(radius),radius)
xSections << foilWithZ
end
return xSections
end
end