Distance(A,B, 1), Distance(A,C, 1), Distance(B,C, 1), ] solve(csts, fixed=[A], afterset=lambda x: print(repr((A,B,C)))) print('final', repr((A,B,C))) show([AB,AC,BC, csts]) print('\ntangent arc') A = Point(0, 0, 0) B = Point(1, 0, 0) C = Point(0, 1, 0) AB = Segment(A,B) AC = Segment(A,C) O = Point(0.8,0.8,0) Z = vec3(0,0,1) BC = ArcCentered((O,Z), B,C) csts = [ Distance(A,B, 1), Distance(A,C, 1), Distance(B,C, 1), # resolution en cas de probleme sous-contraint: enlever cette ligne Tangent(AB,BC,B), Tangent(AC,BC,C), ] solve(csts, fixed=[A,Z], afterset=lambda x: print(repr((A,B,C,O)))) print('final', repr((A,B,C,O))) show([AB, AC, BC, csts]) print('\nangle') A = Point(0, 0, 0)
from time import time from copy import deepcopy from nprint import nprint from madcad import vec3,mat4, rotate, Mesh, quat, transform, normalize from madcad.boolean import difference, booleanwith, intersectwith from madcad import boolean from madcad import show m1 = Mesh( [ vec3(1.0, -1.0, -1.0), vec3(1.0, -1.0, 1.0), vec3(-1.0, -1.0, 1.0), vec3(-1.0, -1.0, -1.0), vec3(1.0, 1.0, -1.0), vec3(1.0, 1.0, 1.0), vec3(-1.0, 1.0, 1.0), vec3(-1.0, 1.0, -1.0)], [ (0, 1, 2), (0, 2, 3), (4, 7, 6), (4, 6, 5), (0, 4, 5), (0, 5, 1), (1, 5, 6), (1, 6, 2), (2, 6, 7), (2, 7, 3), (4, 0, 3),
# test intersections from madcad import vec3, saddle, tube, ArcThrough, Web, web, bevel, chamfer, show from madcad.mesh import suites from madcad.cut import multicut from nprint import nprint from copy import deepcopy m = saddle( Web([ vec3(-2, 1.5, 0), vec3(-1, 1, 0), vec3(0, 0, 0), vec3(1, 1, 0), vec3(1.5, 2, 0) ], [(0, 1), (1, 2), (2, 3), (3, 4)], [0, 1, 2, 3]), #web(vec3(0,1,-1),vec3(0,0,0),vec3(0,1,1)), #web(ArcThrough(vec3(0,1,-1),vec3(0,1.5,0),vec3(0,1,1))), web(ArcThrough(vec3(0, 1, -1), vec3(0, 1.3, -0.5), vec3(0, 1, 0)), ArcThrough(vec3(0, 1, 0), vec3(0, 0.7, 0.5), vec3(0, 1, 1))), ) m.check() #cut.cut_corner(m, 87, 0.6*vec3(0,0.2,0.05)) w = m.frontiers((1, 2)) + m.frontiers((5, 6)) #multicut(m, w, ('depth', 0.6)) #chamfer(m, w, ('depth', 0.6)) bevel(m, w, ('depth', 0.6)) #beveltgt(m, w, ('depth', 0.6)) m.check() #m.check() # TODO fix the face using the same point multiple times
from madcad import vec3, Box, brick, show from madcad.mesh import suites from madcad.cut import * from madcad import scaledir, normalize cube = brick( Box(center=vec3(0), width=vec3(2))) #.transform(scaledir(normalize(vec3(1)), 0.5)) w = [(0, 1), (1, 2), (2, 3), (0, 3), (1, 5), (0, 4)] #multicut(cube, w, ('width', 0.3)) #chamfer(cube, w, ('width', 0.3)) bevel(cube, w, ('width', 0.3)) cube.mergeclose() cube.check() #cube.options = {'debug_display':True, 'debug_points':True} show([cube], options={'display_wire': True})
from madcad import vec3, show from madcad.kinematic import * from madcad.joints import * s1 = Solid() s2 = Solid(pose=(vec3(0,0,0.5), vec3(1,0,0))) s3 = Solid() s4 = Solid() A = vec3(2,0,0) B = vec3(0,2,0) C = vec3(0,-1,1) D = vec3(1,-2,0) x = vec3(1,0,0) y = vec3(0,1,0) csts = [Pivot(s1,s2, (A,x)), Ball(s1,s2, B), Plane(s2,s3, (C,y), position=(C,C)), Punctiform(s3,s4,(D,y))] makescheme(csts) show([s1, s2, s3, s4, A, B, C, D])
from madcad import vec3, Mesh, Web, show from madcad.hashing import * from nprint import nprint triangles = Mesh( [ vec3(1, 1, 0), vec3(3, 1, 0), vec3(1, 3, 0), vec3(0, 1, 1), vec3(0, 3, 1), vec3(0, 1, 4), vec3(1, 0, 1), vec3(3, 0, 1), vec3(1, 0, 4), vec3(1, 2, 5), vec3(-3, 0, 4), vec3(4, -2, 7), vec3(-0.2, -1, 0.452081), vec3(-0.796834, -0.403166, -0.550011), vec3(0.114227, -1.31423, 0.979673), ], [(0, 1, 2), (3, 4, 5), (6, 7, 8), (9, 10, 11), (12, 13, 14)], ) lines = Web( [ vec3(5, 0, 0), vec3(5, 0, 4), vec3(0, 5, 0), vec3(0, 6, 4), #vec3(-6,-8,9), vec3(-2,-5,2),
from random import random, randint from madcad import vec3, Mesh, show, Circle, extrusion, web from madcad.blending import * if False: interface = [ Circle((vec3(0, 0, 3), vec3(0, 0, 1)), 1), Circle((vec3(-1, -1, -1), normalize(vec3(-1, -1, -1))), 1), Circle((vec3(1, -1, -1), normalize(vec3(1, -1, -1))), 1), Circle((vec3(0, 1, 0), normalize(vec3(0, 1, -1))), 1), ] m = junction( interface[0], interface[1], interface[2], (interface[3], 'normal'), tangents='tangent', ) for c in interface: m += extrusion(c.axis[1] * 3, web(c)) if False: z = vec3(0, 0, 1) x = normalize(vec3(1, 1, 0)) interfaces = [ extrusion(2 * z, web(Circle((vec3(0), z), 1))), extrusion(5 * z, web(Circle((vec3(2, 0, -2), z), 0.6))), ] m = junction( interfaces[0],
from madcad import vec3, normalize, show, Box from madcad.kinematic import * from madcad.joints import * O = vec3(0) X = vec3(1,0,0) Y = vec3(0,1,0) Z = vec3(0,0,1) s0 = Solid(name='base') s1 = Solid(pose=(vec3(0,0,0), vec3(0,0,1))) s2 = Solid(pose=(vec3(2,0,1.5), 2*vec3(1,1,0))) s3 = Solid() s4 = Solid() s5 = Solid(name='wrist') s6 = Solid() # basic structure csts = [ #Plane(s0,s1, (O,Z)), #Pivot(s0,s1, (O,Z)), #Track(s0,s1, (vec3(0,0,10),X,Y), (O,X,Y)), Gliding(s0,s1, (O,Z)), Pivot(s1,s2, (vec3(0,0,1), X), (vec3(0,0,-1), X)), #Pivot(s2,s3, (vec3(0,0,2), normalize(vec3(1,1,0))), (O,X)), Pivot(s2,s3, (vec3(0,0,2), X), (O,X)), Pivot(s3,s4, (vec3(0,0,2), X), (O,X)), Pivot(s4,s5, (vec3(0,0,2), X), (O,X)), ]