Esempio n. 1
0
 def animate(self):
     self.index = 0
     catmull = self.openGLWidget.history[0]
     if len(self.openGLWidget.animationObjects) == 1:
         self.openGLWidget.animationObjects.pop()
     ellipse = Ellipse(catmull.userDefinedPoints[1].x,
                       catmull.userDefinedPoints[1].y, 10, 10)
     ellipse.compute()
     self.openGLWidget.animationObjects.append(ellipse)
     self.timer.start(self.delay)
Esempio n. 2
0
    def mousePressEvent(self, event):
        #check the type of object we are drawing
        if self.objectType == "Rectangle":
            # create Rectangle with properties at the clicked point:
            self.object = Rectangle(event.x(), self.height - event.y(),
                                    event.x(), self.height - event.y())

        else:
            # create Ellipse with properties at the clicked point:
            self.object = Ellipse(event.x(), self.height - event.y(),
                                  event.x(), self.height - event.y())
Esempio n. 3
0
 def __init__(self):
     super().__init__()
     self.colorCounter = 1
     self.setMouseTracking(False)
     __ellipseWidth = 100
     __ellipseHeight = 450
     self.object = Ellipse(0, 0, __ellipseWidth, __ellipseHeight)
     self.theta = 0
     self.objectType = None
     self.rotationPointX = self.object.cx
     self.rotationPointY = self.object.cy
Esempio n. 4
0
 def buildEllipse(winner, center, top_votes, num_voters, major_axis, imgSize):
     minor_axis = winner[0]
     theta = winner[1]
     theshold = 0.1
     ratio = 4
     # votes must high enough  and the major/minor rate cant be too much
     if top_votes <= num_voters*theshold or major_axis/minor_axis > ratio:  # 0.15 / 2.5
         print('[No result] {}/{} < {}, major/minor {} > {}'.format(
                 top_votes, num_voters, theshold, 
                 major_axis/minor_axis, ratio))
         e = None
         success = False
     else:
         print('[Detected] minor = {}, theta={}'.format(minor_axis, theta*pi/180))
         e = Ellipse((major_axis, minor_axis), center, theta, imgSize)
         success = True
     return success, e
Esempio n. 5
0
class CreateObjects:
    if __name__ == '__main__':
        figure1 = Circle("red", 12)
        figure2 = Ellipse("pink", 9, 15)
        figure3 = Triangle("black", 4, 7, 10)
        figure4 = IsoscelesTriangle("none", 6, 10)
        figure5 = EquilateralTriangle("millitary", 7)
        figure6 = Square("red", 6)
        figure7 = Rectangle("green", 6, 12)

        listFigures = [
            figure1, figure2, figure3, figure3, figure4, figure5, figure6,
            figure7
        ]
        for shape in listFigures:
            print("========= Number : " + str(listFigures.index(shape) + 1) +
                  " ============")
            shape.informationAboutFigure()
Esempio n. 6
0
from Vector import *
from Ellipse import Ellipse

C = O()
a = 2.0

b1 = 1.0
b2 = 2.0

N = 100

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

b = b1
for n in range(N):
    curve = Ellipse(a, b, C, N)
    curve.Rs()

    curve.Init_Canvas()

    fname = "Ellipse/" + ("%03d" % n) + ".svg"
    options = {
        "stroke": 'blue',
        "style": {
            "stroke-width": 2,
        }
    }

    curve.Curve_SVG_Line_Write(fname, options)
    b += db
Esempio n. 7
0
# Simulation parameters
N, s, T = 64, 10e6, .102
h = 1. / N

dt = .00000003

Time = SimTime(dt = dt, T = T)

# Setup for saving the simulation output
SavePeriod = 100 #int((T / dt) / 120)
Save = SaveData.SaveDataControl(('EllipseRelaxation', 'Explicit'))

    
# Ellipse
X = Ellipse(2 * N, s, [.5,.5], [.8,.5], [.5,.6])
X.UseNativePython = False # If true native python code is used instead of C code

# Initialize the fluid solver
u = Fluid(dt = dt, N = [N,N], dims = [1., 1.])

# The simulation loop        
Time.StartTimer()
while Time.t < Time.T:
    Time.PrintStepInfo()

    X.CheckForExplosion()

    # The FE/BE method
    # First calculate the fiber force F (stored in X.F)
    X.CalcForceDistribution()
Esempio n. 8
0
rectangle = Rectangle('5','8','88','99')
ROIs.append(rectangle.generateXML())

square = Square('55','99','520')
ROIs.append(square.generateXML())

xs=[1,2,3,4,5,6]
ys=[6,5,4,555,2,3]

polygon = Polygon(xs,ys)
ROIs.append(polygon.generateXML())
"""

#Como hemos comentado en el metodo, aqui solo tenemos que llamarlo y el se encarga de generar el xml esperado. Solo queda aniadirlo a la raiz
rois = [
    Ellipse('7', '8', '0.2'),
    Ellipse('55', '55', '0.222'),
    Ellipse('777', '777', '0.777')
]
ROIsofImage.append(generateXMLDocument(rois))
"""
En esta parte es donde creamos el archivo XML que tiene de contenido las regiones que hemos captado de OpenCV.
Al abrir ese archivo, si no esta se crea pero si ya esta generado se machaca el contenido que tuviera, de esta forma es conveniente
que el nombre del archivo sea diferente cada vez que queramos guardar las regiones de una foto.

"""
archi = open('datos.xml', 'w')
archi.flush()
archi.write(
    etree.tostring(ROIsofImage,
                   pretty_print=True,
Esempio n. 9
0
def calculate(value):
  schema = Ellipse(c_aux = value)
  return schema.mas()
Esempio n. 10
0
        * black background
        * white foreground
'''

import sys
import math

from Rectangle import Rectangle
from Ellipse import Ellipse
from PyQt5.QtOpenGL import QGLWidget
from PyQt5.QtCore import QSize
import OpenGL.GL as GL
import OpenGL.GLU as GLU

REC = Rectangle(0, 0, 0, 0)
ELLI = Ellipse(0, 0, 0, 0)


class GLStandardDrawingWindow(QGLWidget):
    def __init__(self):
        super().__init__()
        self.width, self.height = 500, 600
        self.resize(self.width, self.height)
        self.move(100, 100)
        self.history = []
        self.numberOfClicks = 0

    def minimumSizeHint(self):
        return QSize(50, 100)

    def sizeHint(self):
Esempio n. 11
0
def eval_mas(value):
  schema = Ellipse(N=N, a=a, b=b, k=k, c_aux=value, c_obs=2*c_obs)
  return schema.mas(champion=True)
Esempio n. 12
0
def evaluation_function2(value):
  schema = Ellipse(N=N, a=a, b=b, k=k, c_aux=value, c_obs=c_obs)
  return schema.mas(champion=True)
Esempio n. 13
0
"""

from numpy import zeros, float64, floor, array, dot

import IB

from Fluid import Fluid
from Ellipse import Ellipse
from MatrixUtility import Stack, Unstack

# Simulation parameters
N = 128
RestrictToEulerian = False  # If True we restrict the fiber points to Eulerian intersections. When done the matrix should give EXACT results.

# Create the fiber in the shape of an ellipse
X = Ellipse(2 * N, s=10e6, c=[.5, .5], p1=[.8, .5], p2=[.5, .6])
if RestrictToEulerian:
    X.X = floor(X.X * N) / N

# Initialize the fluid solver
u = Fluid(dt=1. / N, N=[N, N], dims=[1., 1.])

# Calculate dX/dt (stored in X.U) using a fluid solve
X.CalcForceDistribution()
X.ToGrid(u)
u.UpdateFluid(u.f)
X.FromGrid(u)

# Calculate dX/dt (stored in U) using the fluid matrix
# First construt the fluid matrix
M = X.ConstructFluidMatrix(u)