Beispiel #1
0
    def drawTest(self):
        #get two points and a sweep line position:
        a = np.random.random(2)
        b = np.random.random(2)
        c = max(a[1], b[1]) + np.random.random(1)

        self.ctx.set_source_rgba(1.0, 0, 0, 1)
        utils.drawCircle(self.ctx, a[0], a[1], 0.004)
        utils.drawCircle(self.ctx, b[0], b[1], 0.004)

        self.ctx.set_line_width(0.002)
        self.ctx.move_to(0, c)
        self.ctx.line_to(1, c)
        self.ctx.stroke()

        p1 = Parabola(*a, c)
        p2 = Parabola(*b, c)

        #sample and draw:
        xs = np.linspace(0, 1, 1000)
        p1_xys = p1.calc(xs)
        p2_xys = p2.calc(xs)

        for x, y in p1_xys:
            utils.drawCircle(self.ctx, x, y, 0.002)
        for x, y in p2_xys:
            utils.drawCircle(self.ctx, x, y, 0.002)

        #intersect:
        intersections = p1.intersect(p2)
        print("intersections", intersections)
        self.ctx.set_source_rgba(0.0, 1.0, 0.0, 1)
        for x, y in intersections:
            utils.drawCircle(self.ctx, x, y, 0.004)
    def InsertAndSplit(self, siteEvent, above):
        # Divide this parabola node into 3 parabola nodes by using two internal nodes
        replacer = InternalNode(above.siteEvent, siteEvent, above.parent)
        replacer.left = Parabola(above.siteEvent, replacer)

        subNode = InternalNode(siteEvent, above.siteEvent, replacer)
        replacer.right = subNode

        newParabola = Parabola(siteEvent, subNode)
        subNode.left = newParabola
        subNode.right = Parabola(above.siteEvent, subNode)

        # Replace the above with replacer
        if above.parent is not None:
            if above is above.parent.left:
                above.parent.left = replacer
            else:
                above.parent.right = replacer
        else:
            self.root = replacer

        return newParabola
Beispiel #3
0
    def Base_Curve_Parabola(self):
        if (self.__Base__ == None):
            args = {
                "t1": self.t1,
                "t2": self.t2,
                "N": self.N,
                "a": self.a,
            }

            self.__Base__ = Parabola(args)
            self.__Base__.__Calc__()

        return self.__Base__
Beispiel #4
0
    def Curves2_Curve(self, name=None):
        if (not name): name = self.Curves2_Name()

        self.Calc = True
        if (name == "Circle"):
            self.Curve = Circle()
        elif (name == "Parabola"):
            self.Curve = Parabola()
        elif (name == "Ellipsis"):
            self.Curve = Ellipsis()
        elif (name == "Hyperbola"):
            self.Curve = Hyperbola()
        elif (name == "Descartes"):
            self.Curve = Descartes()
        elif (name == "Rose"):
            self.Curve = Rose()
        elif (name == "Superellipse"):
            self.Curve = Super()
        elif (name == "Cycloid"):
            self.Curve = Cycloid()
        elif (name == "Trochoid"):
            self.Curve = Trochoid()
        elif (name == "Hypocycloid"):
            self.Curve = Hypocycloid()
        elif (name == "Hypotrochoid"):
            self.Curve = Hypotrochoid()
        elif (name == "Epicycloid"):
            self.Curve = Epicycloid()
        elif (name == "Epitrochoid"):
            self.Curve = Epitrochoid()
        elif (name == "Super"):
            self.Curve = Super()

        elif (name == "LatexTables"):
            self.Latex_Curves_Table_Generate()

        elif (name == "Parallel"):
            self.Curve = Parallel()
            self.Curve.Base_Curve()

            self.Curve.Run()
        else:
            self.Calc = False

        self.Name = name

        if (self.Curves2_Args()):
            self.Calc = False

        return self.Curve
Beispiel #5
0
from Vector   import *
from Parabola import Parabola

a=1.0
c=0.0

b1=-2.0
b2=2.0

N=100
NP=100

db=1.0*(b2-b1)/( 1.0*(N-1) )

parabola=Parabola(-a,0.0,c,NP)
parabola.Rs()

b=b1
for n in range(N):
    curve=Parabola(a,b,c,NP)
    curve.Rs()

    curve.Init_Canvas()

    #Transfer Canvas
    parabola.Canvas=curve.Canvas

    fname="Parabola/"+("%03d" % n)+".svg"
    options={
        "stroke": 'blue',
        "style": {
 def InsertRootParabola(self, siteEvent):
     self.root = Parabola(siteEvent, None)
import numpy as np
from numpy.random import random
from beachline import BeachLine
from Parabola import Parabola
import utils
import cairo

bl = BeachLine()
sweep = 0.8
p1 = np.array([0.25, 0.5])
p2 = np.array([0.75, 0.6])
p3 = np.array([0.35, 0.7])

arc1 = Parabola(*p1, sweep)
arc2 = Parabola(*p2, sweep)
arc3 = Parabola(*p3, sweep)
print('Arc1:', arc1)
print('Arc2:', arc2)
print('Arc3:', arc3)

bl.insert_root(arc1)

node1 = bl.search(p2[0], sweep)

new_head1 = bl.split(arc2, node1)
bl.balance(new_head1)
#bl.delete_leaf(bl.root.getMax())

node2 = bl.search(p3[0], sweep)

new_head2 = bl.split(arc3, node2)
Beispiel #8
0
 def __call__(self, x):
     print "Cubic is running"
     return self.c3 * x**3 + Parabola.__call__(self, x)
Beispiel #9
0
 def __init__(self, c0, c1, c2, c3):
     Parabola.__init__(self, c0, c1, c2)
     self.c3 = c3
Beispiel #10
0
 def __call__(self, x):
     return self.c3 * x**3 + Parabola.__call__(x)