Last active
January 23, 2023 11:48
-
-
Save medicationforall/9596c2251c5e7b8341e91dd371cc54f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cadquery as cq | |
| import math | |
| length = 100 | |
| width = 100 | |
| height = 75 | |
| inset = -10 | |
| def angle(length, height): | |
| ''' | |
| Presumed length and height are part of a right triangle | |
| ''' | |
| hyp = math.hypot(length, height) | |
| angle = length/hyp | |
| angle_radians = math.acos((angle)) | |
| angle_deg = math.degrees(angle_radians) | |
| return angle_deg | |
| wedge = ( | |
| cq.Workplane("XY" ) | |
| .wedge(length,height,width,inset,inset,length-inset,width-inset) | |
| .rotate((1,0,0),(0,0,0),-90) | |
| ) | |
| inset_angle = angle(inset, height) | |
| log(inset_angle) | |
| test = ( | |
| cq.Workplane("XY") | |
| .box(10,10,10) | |
| .rotate((1,0,0),(0,0,0), -1*inset_angle) | |
| .translate((0,-1*(length/2+10),0)) | |
| ) | |
| box = ( | |
| cq.Workplane("XY") | |
| .box(10,10,10) | |
| .rotate((0,1,0),(0,0,0),-1*(inset_angle)) | |
| .translate((length/2+10,0,0)) | |
| ) | |
| show_object(wedge) | |
| show_object(test) | |
| show_object(box) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment