Example #1
0
class BallooningBezier(Ballooning):
    def __init__(self, points=None):
        if not points:
            points = [[[0, 0], [0.1, 0], [0.2, 0.14], [0.8, 0.14], [0.9, 0], [1, 0]],
                      [[0, 0], [0.1, 0], [0.2, 0.14], [0.8, 0.14], [0.9, 0], [1, 0]]]
        self.upbez = BezierCurve(points[0])
        self.lowbez = BezierCurve(points[1])
        Ballooning.__init__(self, self.upbez.interpolation(), self.lowbez.interpolation())

    def __mul__(self, other):  # TODO: Check consistency
        """Multiplication of BezierBallooning"""
        # Multiplicate as normal interpolated ballooning, then refit
        return Ballooning.__mul__(self, other)
        #self.upper = temp.upper
        #self.lower = temp.lower
        #self.upbez.fit(numpy.transpose([self.upper.x, self.upper.y]))
        #self.lowbez.fit(numpy.transpose([self.lower.x, self.lower.y]))

    def _setnumpoints(self, numpoints):
        Ballooning.__init__(self, self.upbez.interpolation(numpoints), self.lowbez.interpolation(numpoints))

    def _getnumpoints(self):
        return len(self.upper)

    Numpoints = property(_getnumpoints, _setnumpoints)
Example #2
0
 def __init__(self, points=None):
     if not points:
         points = [[[0, 0], [0.1, 0], [0.2, 0.14], [0.8, 0.14], [0.9, 0], [1, 0]],
                   [[0, 0], [0.1, 0], [0.2, 0.14], [0.8, 0.14], [0.9, 0], [1, 0]]]
     self.upbez = BezierCurve(points[0])
     self.lowbez = BezierCurve(points[1])
     Ballooning.__init__(self, self.upbez.interpolation(), self.lowbez.interpolation())
Example #3
0
class TestMarks(unittest.TestCase):
    def setUp(self):
        self.curve = BezierCurve()
        self.points = [[0., 0.], [0.5, 0.5], [1., 0.]]
        self.profile = openglider.airfoil.Profile2D()
        self.profile.compute_naca(9012, numpoints=100)

    def test_bezier_fit(self):
        nose_ind = self.profile.noseindex
        upper = BezierCurve()
        lower = BezierCurve()
        upper.fit(self.profile.data[:nose_ind+1],numpoints=10)
        lower.fit(self.profile.data[nose_ind:], numpoints=10)

        Graphics2D([
            Red,
            Line(self.profile.data),
            Green,
            Line(map(upper, numpy.linspace(0, 1, 100))),
            Line(map(lower, numpy.linspace(0, 1, 100)))
            ])

    def test_bezier_interpolation(self):
        self.curve.controlpoints = self.points
        interpolation = self.curve.interpolation(num=20)
        func = lambda x: numpy.array([x, interpolation(x)])
        Graphics2D([
            Line(map(func, numpy.linspace(0, 1, 20))),
            Green,
            Line(self.points)
            ])
Example #4
0
    def test_bezier_fit(self):
        nose_ind = self.profile.noseindex
        upper = BezierCurve()
        lower = BezierCurve()
        upper.fit(self.profile.data[:nose_ind+1],numpoints=10)
        lower.fit(self.profile.data[nose_ind:], numpoints=10)

        Graphics2D([
            Red,
            Line(self.profile.data),
            Green,
            Line(map(upper, numpy.linspace(0, 1, 100))),
            Line(map(lower, numpy.linspace(0, 1, 100)))
            ])
Example #5
0
    def test_brake(self):
        glider = self.glider
        brake = BezierCurve([[0., 0.], [1., 0.], [1., -0.2]])
        num = 60
        brakeprof = openglider.Profile2D(
            [brake(i / num) for i in reversed(range(num + 1))][:-1] +
            [brake(i / num) for i in range(num + 1)],
            normalize_root=False)

        for i, rib in enumerate(glider.ribs):
            rib.profile_2d = rib.profile_2d + brakeprof * (3 * i /
                                                           len(glider.ribs))

        self.test_show_3d_green(thaglider=glider)
Example #6
0
    def __init__(self, yvalue, front_cut, back_cut=1, func=None, name="minirib"):
        #Profile3D.__init__(self, [], name)

        if not func:  # Function is a bezier-function depending on front/back
            if front_cut > 0:
                points = [[front_cut, 1], [front_cut * 2. / 3 + back_cut * 1. / 3]]  #
            else:
                points = [[front_cut, 0]]

            if back_cut < 1:
                points = points + [[front_cut * 1. / 3 + back_cut * 2. / 3, 0], [back_cut, 1]]
            else:
                points = points + [[back_cut, 0]]
            func = BezierCurve(points).interpolation()

        self.__function__ = func

        self.y_value = yvalue
        self.front_cut = front_cut
        self.back_cut = back_cut
Example #7
0
 def setUp(self):
     self.curve = BezierCurve()
     self.points = [[0., 0.], [0.5, 0.5], [1., 0.]]
     self.profile = openglider.airfoil.Profile2D()
     self.profile.compute_naca(9012, numpoints=100)