Ejemplo n.º 1
0
    def Geometry(self):

        pas = 2 * npy.pi / self.Z
        O = vm.Point2D((self.Ox, self.Oy))
        A = O.Translation(vm.Point2D((0, self.DE / 2.)))
        Bp = O.Translation(vm.Point2D((0, self.DI / 2.)))
        B = Bp.Rotation(O, -self.alpha1, copy=True)
        Bi = B.Rotation(O, -self.alpha2 / 2., copy=True)
        C = B.Rotation(O, -self.alpha2, copy=True)
        D = A.Rotation(O, -self.alpha1 - self.alpha2 - self.alpha3, copy=True)
        Di = D.Rotation(O,
                        (-pas + self.alpha1 + self.alpha2 + self.alpha3) / 2.,
                        copy=True)
        Ap = A.Rotation(O, -pas, copy=True)

        dir1 = (B[1] - A[1]) / (B[0] - A[0])
        ord1 = B[1] - dir1 * B[0]

        def fonct(x, *data):
            Ox, Oy, R, coeff_dir, ord_origine = data
            f = (ord_origine + coeff_dir * x - Oy)**2 + (x - Ox)**2 - R**2
            return f

        x1 = fsolve(fonct,
                    0,
                    args=(self.Ox, self.Oy, self.DF / 2., dir1, ord1))
        R1 = vm.Point2D((x1, ord1 + x1 * dir1))

        dir2 = (D[1] - C[1]) / (D[0] - C[0])
        ord2 = C[1] - dir2 * C[0]
        x2 = fsolve(fonct,
                    1,
                    args=(self.Ox, self.Oy, self.DF / 2., dir2, ord2))
        R2 = vm.Point2D((x2, ord2 + x2 * dir2))

        li = [B, Bi, C, D, Di, Ap]
        AB = vm.LineSegment2D(A, B)
        BC = vm.Arc2D(B, Bi, C)
        CD = vm.LineSegment2D(C, D)

        list_seg = []
        Am = A
        for z in range(self.Z):
            li_point = []
            for pt in li:
                li_point.append(pt.Rotation(O, -pas * z, copy=True))
            AB = vm.LineSegment2D(Am, li_point[0])
            BC = vm.Arc2D(li_point[0], li_point[1], li_point[2])
            CD = vm.LineSegment2D(li_point[2], li_point[3])
            DA = vm.Arc2D(li_point[3], li_point[4], li_point[5])
            list_seg.extend([AB, BC, CD, DA])
            Am = li_point[5]

        c = vm.CompositePrimitive2D(list_seg)
        return c
Ejemplo n.º 2
0
 def Geometry(self):
     
     O  = vm.Point2D((self.Ox, self.Oy))
     A  = O.Translation(vm.Point2D((self.LA*npy.cos(self.alpha0), self.LA*npy.sin(self.alpha0))))
     alpha = self.alpha0 - self.alphaA
     B  = A.Translation(vm.Point2D((self.L1*npy.cos(alpha), self.L1*npy.sin(alpha))))
     alpha = alpha - self.alphaB
     P  = B.Translation(vm.Point2D((self.L2*npy.cos(alpha), self.L2*npy.sin(alpha))))
     alpha = alpha + self.alphaP
     M  = P.Translation(vm.Point2D((self.L5*npy.cos(alpha), self.L5*npy.sin(alpha))))
     
     alpha = self.alpha0 - self.alphaE
     E  = O.Translation(vm.Point2D((self.LE*npy.cos(alpha), self.LE*npy.sin(alpha))))
     alphap = alpha - self.alpha1
     C  = E.Translation(vm.Point2D((self.L4*npy.cos(alphap), self.L4*npy.sin(alphap))))
     D  = E.Translation(vm.Point2D((-self.L3*npy.cos(alphap), -self.L3*npy.sin(alphap))))
     alpha = alphap + npy.pi/2. - self.alphaC
     F  = C.Translation(vm.Point2D((self.L7*npy.cos(alpha), self.L7*npy.sin(alpha))))
     alpha = alphap + npy.pi/2. + self.alphaD
     G  = D.Translation(vm.Point2D((self.L6*npy.cos(alpha), self.L6*npy.sin(alpha))))
     
     AB=vm.LineSegment2D(A, B)
     BP=vm.LineSegment2D(B, P)
     PM=vm.LineSegment2D(P, M)
     DE=vm.LineSegment2D(D, E)
     EC=vm.LineSegment2D(E, C)
     DG=vm.LineSegment2D(D, G)
     CF=vm.LineSegment2D(C, F)
     
     alpha = alphap - npy.pi/2.
     R = E.Translation(vm.Point2D((self.DI/2.*npy.cos(alpha), self.DI/2.*npy.sin(alpha))))
     # recherche du point F1 et F2
     def fonct(alpha, *data):
         line, d = data
         x  = R.Translation(vm.Point2D((d/2.*npy.cos(alpha + npy.pi/2.), d/2.*npy.sin(alpha + npy.pi/2.))))
         p = line.PointProjection(x)
         return p.PointDistance(x)
     sol1 = fsolve(fonct, 0, args=(DG, self.DF))
     F1  = R.Translation(vm.Point2D((self.DF/2.*npy.cos(npy.pi/2. + sol1), self.DF/2.*npy.sin(npy.pi/2. + sol1))))
     sol2 = fsolve(fonct, 0, args=(CF, self.DF))
     F2  = R.Translation(vm.Point2D((self.DF/2.*npy.cos(npy.pi/2. + sol2), self.DF/2.*npy.sin(npy.pi/2. + sol2))))
     
     
     Cr = vm.Circle2D(R, self.DF/2.)
     
     c=vm.CompositePrimitive2D([O, AB, BP, PM, DE, EC, DG, CF, R, Cr, F1, F2])
     c.MPLPlot(style='--ob')
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 14 15:32:37 2018

@author: Steven Masfaraud [email protected]
"""
import volmdlr as vm
import volmdlr.primitives2D as primitives2D
import numpy as npy

#for i in range(20):
triangle_points = [vm.Point2D(npy.random.random(2)) for i in range(3)]
triangle = vm.Polygon2D(triangle_points)

cog_triangle = triangle.CenterOfMass()
c1 = vm.CompositePrimitive2D([triangle, cog_triangle])
c1.MPLPlot()

print(triangle.Area())

p0 = vm.Point2D((-1, 0))
p1 = vm.Point2D((-npy.cos(npy.pi / 4), npy.sin(npy.pi / 4)))
p2 = vm.Point2D((0, 1))

a = vm.Arc2D(p2, p1, p0)
l = vm.LineSegment2D(p2, a.center)
list_node = a.Discretise()

c = vm.Contour2D([a, l] + list_node)
print(c.plot_data())
c2 = vm.CompositePrimitive2D([c])
Ejemplo n.º 4
0
pm2=vm.Point2D((0,-r2))
pc=vm.Point2D((0,0))
p1=pm1.Rotation(pc,-theta2)
p2=pm1.Rotation(pc,-theta1)
p3=pm1.Rotation(pc,theta1)
p4=pm1.Rotation(pc,theta2)

p8=pm2.Rotation(pc,-theta2)
p7=pm2.Rotation(pc,-theta1)
p6=pm2.Rotation(pc,theta1)
p5=pm2.Rotation(pc,theta2)

border=vm.Polygon2D([p1,p2,p3,p4,p5,p6,p7,p8], name='border')

ptest=vm.Point2D((-0.08366,-0.91306))

projections = []
for line in border.basis_primitives:
    projections.append(line.PointProjection(ptest))



#print('test: ',border.PointDistance(ptest)+(ptest.vector[1]-p2.vector[1]))
cog_p = border.CenterOfMass()

ctest=vm.CompositePrimitive2D([border,ptest]+projections)
f, a = ctest.MPLPlot()
cog_p.MPLPlot(a, style = 'ob')


Ejemplo n.º 5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Mar  8 10:58:19 2017

@author: steven
"""

import volmdlr as vm

p1 = vm.Point2D((1,1.45))
p2 = vm.Point2D((0.4,0.1))
l1 = vm.Line2D(p1, p2)

p3 = vm.Point2D((-1,0))
p4 = vm.Point2D((1,-0.5))
l2 = vm.Line2D(p3, p4)

p5,bl1,bl2 = vm.Point2D.LinesIntersection(l1, l2,True)
p6=vm.Point2D.MiddlePoint(p1,p3)

p7=vm.Point2D.LineProjection(p6, l1)
p8=vm.Point2D.LineProjection(p6, l2)

c=vm.CompositePrimitive2D([l1, l2, p5, p6, p7 ,p8])
c.MPLPlot()