示例#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
示例#2
0
    def Geometry(self):
        theta = 2*npy.pi/Z #theta=theta2 +theta3
        
        R = O.Translation(vm.point2D((self.L8*npy.cos(alphaR),-self.L8*npy.sin(alphaR))))
        
        K = R.Translation(vm.point2D((0,DF/2)))
        H = K.Rotation(R,theta2)
        M = K.Rotation(R,theta2+theta3)
        a1 = vm.Arc2D(K,H,M)
        
        J1 = R.Translation(vm.Point2D((0,DI/2)))
        J=J1.Rotation(R,(theta2-theta1)/2)
        #est ce un probleme de ne pas controler directement la pente du créneau ? (on ne se sert pas de alphaJ)
        #sinon on pourrait remplacer les deux lignes précédentes par:J=K.Translation(vm.point2D((-self.L9*npy.sin(alphaJ),-self.L9*npy.cos(alphaJ))))
        #Dans ce cas il faudrait peut être paramétrer H de la même façon
        I=J.Rotation(R,theta1)
        
        l1=primitives2D.RoundedLineSegments2D([K,J,I,H],{'''je ne sais pas trop quoi mettre ici'''})
        
        L=[a1,l1]
        for i in range(Z-1):
            thetar=(i+1)*theta
            L.append(a1.Rotation(R,thetar,True))
            L.append(l1.Rotation(R,thetar,True))

        c1=vm.Contour2D(L)
        c1.MPLPlot()
示例#3
0
 def __init__(self, start_point, interior_point, end_point,
              diameter,
              heat_exchange=True,
              name=''):
     arc = vm.Arc2D(start_point, interior_point, end_point)
     Bend.__init__(self, start_point, interior_point, end_point,
                   arc, diameter, heat_exchange, name)
示例#4
0
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])
c2.MPLPlot(style='ob')
print(c.Area())
示例#5
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 19:23:27 2019

@author: steven
"""

import volmdlr as vm
import math

r = 0.23

p1 = vm.Point2D((0, 0))
p2 = vm.Point2D((r, r))
p3 = vm.Point2D((2 * r, 0))

a = vm.Arc2D(p1, p2, p3)
l = vm.LineSegment2D(p3, p1)

c = vm.Contour2D([a, l])
f, ax = c.MPLPlot()
cog = c.CenterOfMass()
cog.MPLPlot(ax)

assert math.isclose(a.radius, r)
assert math.isclose(c.Area(), math.pi * r**2 / 2.)
assert math.isclose(cog[0], r)
print(cog[1], 4 * r / 3. * math.pi)
assert math.isclose(cog[1], 4 * r / 3. / math.pi)
示例#6
0
    #    print(center_ball.vector)
    primitives.append(
        primitives3D.Sphere(center_ball, D_balls / 2, 'Ball{}'.format(i + 1)))

# inner
pi1 = vm.Point2D((-B / 2, d / 2))
pi2 = vm.Point2D((-B / 2, d1 / 2))
pi3 = vm.Point2D((-0.5 * D_balls * math.sin(theta_b), d1 / 2))
pi4 = vm.Point2D((0, y_ball0 - D_balls / 2))
pi5 = vm.Point2D((0.5 * D_balls * math.sin(theta_b), d1 / 2))
pi6 = vm.Point2D((B / 2, d1 / 2))
pi7 = vm.Point2D((B / 2, d / 2))

li1 = vm.Line2D(pi1, pi2)
li2 = vm.Line2D(pi2, pi3)
ci3 = vm.Arc2D(pi3, pi4, pi5)
li4 = vm.Line2D(pi5, pi6)
li5 = vm.Line2D(pi6, pi7)
li6 = vm.Line2D(pi7, pi1)

ci = vm.Contour2D([li1, li2, ci3, li4, li5, li6])
inner = primitives3D.RevolvedProfile(center, x, y, [ci], center, x,
                                     math.pi * 2, 'innerring')
primitives.append(inner)

# outter
po1 = vm.Point2D((-B / 2, D / 2))
po2 = vm.Point2D((-B / 2, D1 / 2))
po3 = vm.Point2D((-0.5 * D_balls * math.sin(theta_b), D1 / 2))
po4 = vm.Point2D((0, y_ball0 + D_balls / 2))
po5 = vm.Point2D((0.5 * D_balls * math.sin(theta_b), D1 / 2))
示例#7
0
import volmdlr.primitives3d as p3d
import volmdlr.primitives2d as p2d
import math

#%%

p1 = vm.Point2D((0, 0))
p2 = vm.Point2D((0, 2))
p3 = vm.Point2D((2, 4))
p4 = vm.Point2D((4, 4))
p5 = vm.Point2D((4, 3))
p6 = vm.Point2D((3, 2))
p7 = vm.Point2D((3, 0))

l1 = p2d.OpenedRoundedLineSegments2D([p7, p1, p2], {})
l2 = vm.Arc2D(p2, vm.Point2D((math.sqrt(2) / 2, 3 + math.sqrt(2) / 2)), p3)
l3 = p2d.OpenedRoundedLineSegments2D([p3, p4, p5, p6], {}, adapt_radius=True)
l4 = vm.Arc2D(p6, vm.Point2D((4, 1)), p7)
#l4=vm.Arc2D(p7, vm.Point2D((4, 1)), p6)
c1 = vm.Contour2D([l1, l2, l3, l4])

p8 = vm.Point2D((1, 1))
p9 = vm.Point2D((2, 1))
p10 = vm.Point2D((2, 2))
p11 = vm.Point2D((1, 2))
#inner=vm.Circle2D(vm.Point2D((2,2)), 0.5)
inner = p2d.ClosedRoundedLineSegments2D([p8, p9, p10, p11], {})
c2 = vm.Contour2D([inner])

#ax = l1.MPLPlot()
#l2.MPLPlot(ax=ax)
示例#8
0
文件: areas.py 项目: happydpc/volmdlr
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 14 13:55:59 2017

@author: steven
"""

# Debug of area and inertia

import volmdlr as vm

r = 0.05

p1 = vm.Point2D((0, 0))
p2 = vm.Point2D((0, -r))
p3 = vm.Point2D((r, 0))
p4 = vm.Point2D((0, r))

c1 = vm.Arc2D(p2, p3, p4)

print(c1.SecondMomentArea(p1))

c2 = vm.Circle2D(p1, r)

print(c2.SecondMomentArea(p1))
示例#9
0
            x,
            y,
            outer_contour_floor, [inner_contour_floor],
            (list_height_polyfloor[enum + 1] - height_origin) *
            basis_plane.normal,
            alpha=alpha,
            name='sides_floor')

        list_component_hat.append(sides_floor)
        primitive_of_floor.append(sides_floor)

        if with_borders:
            r = 0.15
            arc = vm.Arc2D(
                vm.Point2D((0, 0)),
                vm.Point2D(
                    ((-1 + math.sqrt(2) / 2) * r, r * math.sqrt(2) / 2)),
                vm.Point2D((-r, r)))

            contour_sweep = outer_contour_floor.Offset(r)

            contour = vm.Contour2D([arc])
            wire_sweep = vm.Wire3D([
                p.To3D(
                    origin +
                    extrusion_vector * list_height_polyfloor[enum + 1], x, y)
                for p in contour_sweep.primitives
            ])
            sweep = primitives3D.Sweep(contour,
                                       wire_sweep,
                                       alpha=alpha,
示例#10
0
#import numpy as npy
import volmdlr as vm
import volmdlr.primitives3D as primitives3D
import volmdlr.primitives2D as primitives2D
#import math

p1=vm.Point2D((0, 0))
p2=vm.Point2D((0.1, 0.))
p3=vm.Point2D((0.1, 0.2))
p4=vm.Point2D((0, 0.1))
p5=vm.Point2D((-0.01, 0.05))

#p6=vm.Point2D((0.1,0.3))

l1=primitives2D.RoundedLineSegments2D([p1, p2, p3, p4], {2: 0.01}, False)
l2=vm.Arc2D(p4, p5, p1)
c1=vm.Contour2D([l1, l2])
c2=c1.Rotation(vm.Point2D((0,0)),npy.pi,True)
c1.MPLPlot()
c2.MPLPlot()
c3=vm.Contour2D([c1, c2])
c3.MPLPlot()

po = vm.Point3D((0, 0, 0))
xp = vm.Vector3D((1, 0, 0))
yp = vm.Vector3D((0, 1, 0))


profile = primitives3D.ExtrudedProfile(po, xp, yp, c1, [], vm.Vector3D((0, 0.1, 0.2)))

model = vm.VolumeModel([('', [profile])])